Skip to content

Commit

Permalink
fix(create-commands): rename function type to google-cloud-function
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Jul 10, 2018
1 parent a8316d1 commit 49c4c93
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Examples:
| Argument | Alias | Type | Description |
| -------- | ----- | ---- | ----------- |
| `--name` | | boolean | Assigns a custom name to the module. (Defaults to name of the current directory.)
| `--type` | | `container` `function` `npm-package` | Type of module.
| `--type` | | `container` `google-cloud-function` `npm-package` | Type of module.

### garden delete config

Expand Down
8 changes: 4 additions & 4 deletions src/commands/create/config-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { BaseModuleSpec, ModuleConfig, baseModuleSpecSchema } from "../../types/
*/
export const MODULE_PROVIDER_MAP = {
container: "local-kubernetes",
function: "local-google-cloud-functions",
"google-cloud-function": "local-google-cloud-functions",
"npm-package": "npm-package",
}

Expand Down Expand Up @@ -72,11 +72,11 @@ export function containerTemplate(moduleName: string): DeepPartial<ContainerModu
}
}

export function functionTemplate(moduleName: string): DeepPartial<GcfModuleSpec> {
export function googleCloudFunctionTemplate(moduleName: string): DeepPartial<GcfModuleSpec> {
return {
functions: [{
name: `${moduleName}-function`,
entrypoint: camelCase(`${moduleName}-function`),
name: `${moduleName}-google-cloud-function`,
entrypoint: camelCase(`${moduleName}-google-cloud-function`),
}],
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/create/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import * as Joi from "joi"
import {
containerTemplate,
functionTemplate,
googleCloudFunctionTemplate,
npmPackageTemplate,
ModuleConfigOpts,
ModuleType,
Expand All @@ -27,7 +27,7 @@ import { MODULE_CONFIG_FILENAME } from "../../constants"
export function prepareNewModuleConfig(name: string, type: ModuleType, path: string): ModuleConfigOpts {
const moduleTypeTemplate = {
container: containerTemplate,
function: functionTemplate,
"google-cloud-function": googleCloudFunctionTemplate,
"npm-package": npmPackageTemplate,
}[type]
return {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/create/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const moduleTypeChoices: ModuleTypeChoice[] = [
},
{
name: `google-cloud-function (${chalk.red.italic("experimental")})`,
value: "function",
value: "google-cloud-function",
},
{
name: `npm package (${chalk.red.italic("experimental")})`,
Expand Down
6 changes: 3 additions & 3 deletions test/src/commands/create/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ describe("CreateModuleCommand", () => {
path: ctx.projectRoot,
})
})
// garden create module --type=function
// garden create module --type=google-cloud-function
it("should optionally create a module of a specific type (without prompting)", async () => {
const ctx = await makeTestContext(projectRoot)
const { result } = await cmd.action(ctx, { "module-dir": "" }, { name: "", type: "function" })
const { result } = await cmd.action(ctx, { "module-dir": "" }, { name: "", type: "google-cloud-function" })
expect(pick(result.module, ["name", "type", "path"])).to.eql({
name: "test-project-create-command",
type: "function",
type: "google-cloud-function",
path: ctx.projectRoot,
})
})
Expand Down

0 comments on commit 49c4c93

Please sign in to comment.