Skip to content

Commit

Permalink
Remove --deployOnly option (#14)
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
  • Loading branch information
groeges authored Jul 1, 2020
1 parent fe7dbaa commit 4f53442
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions pkg/odo/cli/component/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type DeployOptions struct {
namespace string
tag string
ManifestSource []byte
deployOnly bool
}

// NewDeployOptions returns new instance of BuildOptions
Expand Down Expand Up @@ -95,42 +94,40 @@ func (do *DeployOptions) Run() (err error) {
return err
}

if !do.deployOnly {
//Download Dockerfile to .odo, build, then delete from .odo dir
//If Dockerfile is present in the project already, use that for the build
//If Dockerfile is present in the project and field is in devfile, build the one already in the project and warn the user.
if dockerfileURL != "" && util.CheckPathExists(filepath.Join(localDir, "Dockerfile")) {
// TODO: make clearer more visible output
log.Warning("Dockerfile already exists in project directory and one is specified in Devfile.")
log.Warningf("Using Dockerfile specified in devfile from '%s'", dockerfileURL)
}
//Download Dockerfile to .odo, build, then delete from .odo dir
//If Dockerfile is present in the project already, use that for the build
//If Dockerfile is present in the project and field is in devfile, build the one already in the project and warn the user.
if dockerfileURL != "" && util.CheckPathExists(filepath.Join(localDir, "Dockerfile")) {
// TODO: make clearer more visible output
log.Warning("Dockerfile already exists in project directory and one is specified in Devfile.")
log.Warningf("Using Dockerfile specified in devfile from '%s'", dockerfileURL)
}

if !util.CheckPathExists(filepath.Join(localDir, ".odo")) {
return errors.Wrap(err, ".odo folder not found")
}
if !util.CheckPathExists(filepath.Join(localDir, ".odo")) {
return errors.Wrap(err, ".odo folder not found")
}

if dockerfileURL != "" {
dockerfileBytes, err := util.DownloadFileInMemory(dockerfileURL)
if err != nil {
return errors.New("unable to download Dockerfile from URL specified in devfile")
}
// If we successfully downloaded the Dockerfile into memory, store it in the DeployOptions
do.DockerfileBytes = dockerfileBytes

// Validate the file that was downloaded is a Dockerfile
err = util.ValidateDockerfile(dockerfileBytes)
if err != nil {
return err
}

} else if !util.CheckPathExists(filepath.Join(localDir, "Dockerfile")) {
return errors.New("dockerfile required for build. No 'dockerfile' field found in devfile, or Dockerfile found in project directory")
if dockerfileURL != "" {
dockerfileBytes, err := util.DownloadFileInMemory(dockerfileURL)
if err != nil {
return errors.New("unable to download Dockerfile from URL specified in devfile")
}
// If we successfully downloaded the Dockerfile into memory, store it in the DeployOptions
do.DockerfileBytes = dockerfileBytes

err = do.DevfileBuild()
// Validate the file that was downloaded is a Dockerfile
err = util.ValidateDockerfile(dockerfileBytes)
if err != nil {
return err
}

} else if !util.CheckPathExists(filepath.Join(localDir, "Dockerfile")) {
return errors.New("dockerfile required for build. No 'dockerfile' field found in devfile, or Dockerfile found in project directory")
}

err = do.DevfileBuild()
if err != nil {
return err
}

manifestURL := metadata.Manifest
Expand Down Expand Up @@ -184,7 +181,6 @@ func NewCmdDeploy(name, fullName string) *cobra.Command {
if experimental.IsExperimentalModeEnabled() {
deployCmd.Flags().StringVar(&do.DevfilePath, "devfile", "./devfile.yaml", "Path to a devfile.yaml")
deployCmd.Flags().StringVar(&do.tag, "tag", "", "Tag used to build the image")
deployCmd.Flags().BoolVar(&do.deployOnly, "deployOnly", false, "Do not build the application, only deploy it")
}

//Adding `--project` flag
Expand Down

0 comments on commit 4f53442

Please sign in to comment.