Skip to content

Commit

Permalink
refactor: rename project.global to project.environmentDefaults (#131)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Existing garden.yml files will need to be updated if they use the
project.global key.
  • Loading branch information
edvald authored and eysi09 committed Jun 8, 2018
1 parent 52f91e8 commit 3ebe1dc
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/hello-world/garden.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project:
name: hello-world
global:
environmentDefaults:
providers:
- name: container
- name: npm-package
Expand Down
6 changes: 3 additions & 3 deletions src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export class Garden {
}

const projectName = parsedConfig.project.name
const globalConfig = parsedConfig.project.global || {}
const environmentDefaults = parsedConfig.project.environmentDefaults || {}

const parts = env.split(".")
const environment = parts[0]
Expand Down Expand Up @@ -248,15 +248,15 @@ export class Garden {

const mergedProviders = merge(
{},
keyBy(globalConfig.providers, "name"),
keyBy(environmentDefaults.providers, "name"),
keyBy(envConfig.providers, "name"),
)

// Resolve the project configuration based on selected environment
const projectEnvConfig: EnvironmentConfig = {
name: environment,
providers: values(mergedProviders),
variables: merge({}, globalConfig.variables, envConfig.variables),
variables: merge({}, environmentDefaults.variables, envConfig.variables),
}

const buildDir = await BuildDir.factory(projectRoot)
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kubernetes/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function getSystemGarden(provider: KubernetesProvider): Promise<Gar
path: systemProjectPath,
project: {
name: "garden-system",
global: {
environmentDefaults: {
providers: [
{ name: "container" },
],
Expand Down
8 changes: 4 additions & 4 deletions src/types/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface EnvironmentConfig extends CommonEnvironmentConfig {
export interface ProjectConfig {
name: string
defaultEnvironment: string
global: CommonEnvironmentConfig
environmentDefaults: CommonEnvironmentConfig
environments: EnvironmentConfig[]
}

Expand Down Expand Up @@ -75,7 +75,7 @@ export const environmentSchema = Joi.object().keys({
.description("A key/value map of variables that modules can reference when using this environment."),
})

const defaultGlobal = {
const environmentDefaults = {
providers: defaultProviders,
variables: {},
}
Expand All @@ -88,8 +88,8 @@ export const projectSchema = Joi.object()
defaultEnvironment: Joi.string()
.default("", "<first specified environment>")
.description("The default environment to use when calling commands without the `--env` parameter."),
global: environmentSchema
.default(() => defaultGlobal, JSON.stringify(defaultGlobal))
environmentDefaults: environmentSchema
.default(() => environmentDefaults, JSON.stringify(environmentDefaults))
.description(
"Default environment settings, that are inherited (but can be overridden) by each configured environment",
),
Expand Down
2 changes: 1 addition & 1 deletion test/data/test-project-a/garden.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project:
name: test-project-a
global:
environmentDefaults:
variables:
some: variable
environments:
Expand Down
2 changes: 1 addition & 1 deletion test/data/test-project-b/garden.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project:
name: test-project-b
global:
environmentDefaults:
providers: []
environments:
- name: local
Expand Down
2 changes: 1 addition & 1 deletion test/data/test-project-templated/garden.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project:
name: test-project-templated
global:
environmentDefaults:
variables:
some: ${local.env.TEST_VARIABLE}
service-a-build-command: echo OK
Expand Down
2 changes: 1 addition & 1 deletion test/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("loadConfig", () => {
expect(parsed.project).to.eql({
name: "test-project-a",
defaultEnvironment: "local",
global: {
environmentDefaults: {
providers: [],
variables: { some: "variable" },
},
Expand Down

0 comments on commit 3ebe1dc

Please sign in to comment.