Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(k8s): validation error on maven-container modules #642

Merged
merged 1 commit into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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