Skip to content

Commit

Permalink
Rename --downloadSource to --starter (#3425)
Browse files Browse the repository at this point in the history
* Rename --downloadSource to --starter

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Updates help text to be less ambiguous

Signed-off-by: John Collier <John.J.Collier@ibm.com>
  • Loading branch information
johnmcollier authored Jul 3, 2020
1 parent 20f84de commit 0ec74bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/public/deploying-a-devfile-using-odo.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ In this example we will be deploying an https://github.com/odo-devfiles/springbo
----
$ git clone https://github.com/odo-devfiles/springboot-ex
----
Alternatively, you can pass in `--downloadSource` to `odo create` to have odo download a sample project.
Alternatively, you can pass in `--starter` to `odo create` to have odo download a project specified in the devfile.

. Change the current directory to the component directory:
+
Expand Down Expand Up @@ -325,7 +325,7 @@ In this example, we will be deploying the same Java Spring Boot® component we d
----
$ git clone https://github.com/odo-devfiles/springboot-ex
----
Alternatively, you can pass in `--downloadSource` to `odo create` to have odo download a sample project.
Alternatively, you can pass in `--starter` to `odo create` to have odo download a project specified in the devfile.

. Change the current directory to the component directory:
+
Expand Down
16 changes: 8 additions & 8 deletions pkg/odo/cli/component/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type DevfileMetadata struct {
devfileLink string
devfileRegistry catalog.Registry
devfilePath devfilePath
downloadSource string
starter string
}

// CreateRecommendedCommandName is the recommended watch command name
Expand Down Expand Up @@ -137,7 +137,7 @@ Note: When you use odo with experimental mode enabled and create devfile compone
%[1]s nodejs --port 8080,8100/tcp,9100/udp --env key=value,key1=value1 --memory 4Gi --cpu 2
# Create new Node.js component and download the sample project named nodejs-starter
%[1]s nodejs --downloadSource=nodejs-starter`)
%[1]s nodejs --starter=nodejs-starter`)

const defaultProjectName = "devfile-project-name"

Expand Down Expand Up @@ -846,7 +846,7 @@ func (co *CreateOptions) downloadProject(projectPassed string) error {
project = projects[0]
} else if nOfProjects > 1 && projectPassed == defaultProjectName {
project = projects[0]
log.Warning("There are multiple projects in this devfile but none have been specified in --downloadSource. Downloading the first: " + project.Name)
log.Warning("There are multiple projects in this devfile but none have been specified in --starter. Downloading the first: " + project.Name)
} else { //If the user has specified a project
projectFound := false
for indexOfProject, projectInfo := range projects {
Expand All @@ -857,7 +857,7 @@ func (co *CreateOptions) downloadProject(projectPassed string) error {
}

if !projectFound {
return errors.Errorf("The project: %s specified in --downloadSource does not exist", projectPassed)
return errors.Errorf("The project: %s specified in --starter does not exist", projectPassed)
}
}

Expand Down Expand Up @@ -952,8 +952,8 @@ func (co *CreateOptions) Run() (err error) {
}
}

if util.CheckPathExists(DevfilePath) && co.devfileMetadata.downloadSource != "" {
err = co.downloadProject(co.devfileMetadata.downloadSource)
if util.CheckPathExists(DevfilePath) && co.devfileMetadata.starter != "" {
err = co.downloadProject(co.devfileMetadata.starter)
if err != nil {
return errors.Wrap(err, "failed to download project for devfile component")
}
Expand Down Expand Up @@ -1105,8 +1105,8 @@ func NewCmdCreate(name, fullName string) *cobra.Command {
componentCreateCmd.Flags().StringSliceVar(&co.componentEnvVars, "env", []string{}, "Environmental variables for the component. For example --env VariableName=Value")

if experimental.IsExperimentalModeEnabled() {
componentCreateCmd.Flags().StringVar(&co.devfileMetadata.downloadSource, "downloadSource", "", "Download sample project from devfile.")
componentCreateCmd.Flags().Lookup("downloadSource").NoOptDefVal = defaultProjectName //Default value to pass to the flag if one is not specified.
componentCreateCmd.Flags().StringVar(&co.devfileMetadata.starter, "starter", "", "Download a project specified in the devfile")
componentCreateCmd.Flags().Lookup("starter").NoOptDefVal = defaultProjectName //Default value to pass to the flag if one is not specified.
componentCreateCmd.Flags().StringVar(&co.devfileMetadata.devfileRegistry.Name, "registry", "", "Create devfile component from specific registry")
componentCreateCmd.Flags().StringVar(&co.devfileMetadata.devfilePath.value, "devfile", "", "Path to the user specify devfile")
}
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/devfile/cmd_devfile_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ var _ = Describe("odo devfile create command tests", func() {
})
})

Context("When executing odo create with devfile component and --downloadSource flag", func() {
Context("When executing odo create with devfile component and --starter flag", func() {
It("should successfully create the component and download the source", func() {
contextDevfile := helper.CreateNewContext()
helper.Chdir(contextDevfile)
helper.CmdShouldPass("odo", "create", "nodejs", "--downloadSource")
helper.CmdShouldPass("odo", "create", "nodejs", "--starter")
expectedFiles := []string{"package.json", "package-lock.json", "README.md", devfile}
Expect(helper.VerifyFilesExist(contextDevfile, expectedFiles)).To(Equal(true))
helper.DeleteDir(contextDevfile)
Expand All @@ -226,30 +226,30 @@ var _ = Describe("odo devfile create command tests", func() {
})
})

Context("When executing odo create with devfile component and --downloadSource flag with a valid project", func() {
Context("When executing odo create with devfile component and --starter flag with a valid project", func() {
It("should successfully create the component specified and download the source", func() {
contextDevfile := helper.CreateNewContext()
helper.Chdir(contextDevfile)
helper.CmdShouldPass("odo", "create", "nodejs", "--downloadSource=nodejs-starter")
helper.CmdShouldPass("odo", "create", "nodejs", "--starter=nodejs-starter")
expectedFiles := []string{"package.json", "package-lock.json", "README.md", devfile}
Expect(helper.VerifyFilesExist(contextDevfile, expectedFiles)).To(Equal(true))
helper.DeleteDir(contextDevfile)
helper.Chdir(context)
})
})

Context("When executing odo create with an invalid project specified in --downloadSource", func() {
It("should fail with please run 'The project: invalid-project-name specified in --downloadSource does not exist'", func() {
Context("When executing odo create with an invalid project specified in --starter", func() {
It("should fail with please run 'The project: invalid-project-name specified in --starter does not exist'", func() {
invalidProjectName := "invalid-project-name"
output := helper.CmdShouldFail("odo", "create", "nodejs", "--downloadSource=invalid-project-name")
expectedString := "The project: " + invalidProjectName + " specified in --downloadSource does not exist"
output := helper.CmdShouldFail("odo", "create", "nodejs", "--starter=invalid-project-name")
expectedString := "The project: " + invalidProjectName + " specified in --starter does not exist"
helper.MatchAllInOutput(output, []string{expectedString})
})
})

Context("When executing odo create using --downloadSource with a devfile component that contains no projects", func() {
Context("When executing odo create using --starter with a devfile component that contains no projects", func() {
It("should fail with please run 'No project found in devfile component.'", func() {
output := helper.CmdShouldFail("odo", "create", "maven", "--downloadSource")
output := helper.CmdShouldFail("odo", "create", "maven", "--starter")
expectedString := "No project found in devfile component."
helper.MatchAllInOutput(output, []string{expectedString})
})
Expand Down

0 comments on commit 0ec74bd

Please sign in to comment.