Skip to content

Commit

Permalink
Merge pull request #642 from garden-io/maven-container-validation-error
Browse files Browse the repository at this point in the history
fix(k8s): validation error on maven-container modules
  • Loading branch information
eysi09 authored Mar 18, 2019
2 parents 7cea864 + 3c41c8e commit d8ef17a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 24 deletions.
2 changes: 1 addition & 1 deletion garden-service/src/plugins/container/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export const containerTaskSchema = baseTaskSpecSchema
})
.description("A task that can be run in the container.")

interface ContainerBuildSpec extends BaseBuildSpec {
export interface ContainerBuildSpec extends BaseBuildSpec {
targetImage?: string
}

Expand Down
52 changes: 34 additions & 18 deletions garden-service/src/plugins/kubernetes/container/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,45 @@ import { ConfigureModuleParams } from "../../../types/plugin/params"
import { getContainerServiceStatus } from "./status"
import { getTestResult } from "../test"
import { ContainerModule } from "../../container/config"
import { configureMavenContainerModule, MavenContainerModule } from "../../maven-container/maven-container"

async function configure(params: ConfigureModuleParams<ContainerModule>) {
const config = await configureContainerModule(params)
await validateConfig(params)
return config
}

// TODO: avoid having to special-case this (needs framework improvements)
async function configureMaven(params: ConfigureModuleParams<MavenContainerModule>) {
const config = await configureMavenContainerModule(params)
await validateConfig(params)
return config
}

export const containerHandlers = {
configure,
deployService: deployContainerService,
deleteService,
execInService,
getServiceLogs,
getServiceStatus: getContainerServiceStatus,
getTestResult,
hotReloadService: hotReloadContainer,
pushModule,
runModule: runContainerModule,
runService: runContainerService,
runTask: runContainerTask,
testModule: testContainerModule,
}

export const mavenContainerHandlers = {
...containerHandlers,
configure: configureMaven,
}

async function validateConfig(params: ConfigureModuleParams<ContainerModule>) {
// validate ingress specs
const config = params.moduleConfig
const provider = <KubernetesProvider>params.ctx.provider

for (const serviceConfig of config.serviceConfigs) {
Expand All @@ -44,22 +78,4 @@ async function configure(params: ConfigureModuleParams<ContainerModule>) {
ingressSpec.hostname = hostname
}
}

return config
}

export const containerHandlers = {
configure,
deployService: deployContainerService,
deleteService,
execInService,
getServiceLogs,
getServiceStatus: getContainerServiceStatus,
getTestResult,
hotReloadService: hotReloadContainer,
pushModule,
runModule: runContainerModule,
runService: runContainerService,
runTask: runContainerTask,
testModule: testContainerModule,
}
4 changes: 2 additions & 2 deletions garden-service/src/plugins/kubernetes/kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { helmHandlers } from "./helm/handlers"
import { getSecret, setSecret, deleteSecret } from "./secrets"
import { containerRegistryConfigSchema, ContainerRegistryConfig } from "../container/config"
import { getRemoteEnvironmentStatus, prepareRemoteEnvironment, cleanupEnvironment } from "./init"
import { containerHandlers } from "./container/handlers"
import { containerHandlers, mavenContainerHandlers } from "./container/handlers"
import { PluginContext } from "../../plugin-context"

export const name = "kubernetes"
Expand Down Expand Up @@ -156,7 +156,7 @@ export function gardenPlugin(): GardenPlugin {
moduleActions: {
"container": containerHandlers,
// TODO: we should find a way to avoid having to explicitly specify the key here
"maven-container": containerHandlers,
"maven-container": mavenContainerHandlers,
"helm": helmHandlers,
},
}
Expand Down
6 changes: 3 additions & 3 deletions garden-service/src/plugins/maven-container/maven-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface MavenContainerModuleSpec extends ContainerModuleSpec {

// type MavenContainerModuleConfig = ModuleConfig<MavenContainerModuleSpec>

interface MavenContainerModule<
export interface MavenContainerModule<
M extends MavenContainerModuleSpec = MavenContainerModuleSpec,
S extends ContainerServiceSpec = ContainerServiceSpec,
T extends ContainerTestSpec = ContainerTestSpec,
Expand Down Expand Up @@ -78,15 +78,15 @@ export const gardenPlugin = (): GardenPlugin => {
moduleActions: {
"maven-container": {
...basePlugin.moduleActions!.container,
configure,
configure: configureMavenContainerModule,
getBuildStatus,
build,
},
},
}
}

async function configure(params: ConfigureModuleParams<MavenContainerModule>) {
export async function configureMavenContainerModule(params: ConfigureModuleParams<MavenContainerModule>) {
const { ctx, moduleConfig } = params

const mavenFields = validateWithPath({
Expand Down

0 comments on commit d8ef17a

Please sign in to comment.