Skip to content

Commit

Permalink
Make Devfile the default deployment mechanism for odo (redhat-develop…
Browse files Browse the repository at this point in the history
…er#3691)

* Update to 1.1.5 image (redhat-developer#3688)

**What type of PR is this?**
> Uncomment only one ` /kind` line, and delete the rest.
> For example, `> /kind bug` would simply become: `/kind bug`

/kind feature

**What does does this PR do / why we need it**:

Updates to 1.1.5 odo-init-image.

**Which issue(s) this PR fixes**:

N/A

**PR acceptance criteria**:

N/A

**How to test changes / Special notes to the reviewer**:

N/A

Signed-off-by: Charlie Drage <charlie@charliedrage.com>

* Release 1.2.5 (redhat-developer#3689)

**What type of PR is this?**
> Uncomment only one ` /kind` line, and delete the rest.
> For example, `> /kind bug` would simply become: `/kind bug`

/kind feature

**What does does this PR do / why we need it**:

Release 1.2.5 of odo

**Which issue(s) this PR fixes**:

N/A

**PR acceptance criteria**:

N/A

**How to test changes / Special notes to the reviewer**:

N/A

Signed-off-by: Charlie Drage <charlie@charliedrage.com>

* added --s2i flag for `odo create` command

* corrected error messages

* Corrected flag description and validation

* added --s2i flag for `odo create` command

* Make Devfile the default deployment mechanism for odo

**What type of PR is this?**
> Uncomment only one ` /kind` line, and delete the rest.
> For example, `> /kind bug` would simply become: `/kind bug`

/kind feature

**What does does this PR do / why we need it**:

Makes Devfile the default deployment mechanism, removing S2I in favour
of Devfile deployment.

**Which issue(s) this PR fixes**:

Closes redhat-developer#3550

**How to test changes / Special notes to the reviewer**:

Run:

```sh
odo preference set experimental false
odo create --starter nodejs
odo push
```

Co-authored-by: Devang Gaur <devang.gaur.7@gmail.com>
  • Loading branch information
cdrage and devang-gaur committed Aug 7, 2020
1 parent d72ec60 commit d72ddb7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pkg/component/component_full_description.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ func (cfd *ComponentFullDescription) Print(client *occlient.Client) error {
if len(cfd.Spec.URL.Items) > 0 {
var output string

// For S2I Only..
// if the component is not pushed
// FOR S2I ONLY.
// This part *needs* to be edited before merge.. This will still try to output S2I info
for i, componentURL := range cfd.Spec.URL.Items {
if componentURL.Status.State == urlpkg.StateTypePushed {
output += fmt.Sprintf(" · %v exposed via %v\n", urlpkg.GetURLString(componentURL.Spec.Protocol, componentURL.Spec.Host, "", true), componentURL.Spec.Port)
Expand Down
34 changes: 24 additions & 10 deletions pkg/odo/cli/component/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ func (co *CreateOptions) Complete(name string, cmd *cobra.Command, args []string

// Validate user specify devfile path
if co.devfileMetadata.devfilePath.value != "" {
if co.forceS2i {
return errors.New("You can't set --s2i flag as true if you want to use the devfile that is specified via --devfile")
}
fileErr := util.ValidateFile(co.devfileMetadata.devfilePath.value)
urlErr := util.ValidateURL(co.devfileMetadata.devfilePath.value)
if fileErr != nil && urlErr != nil {
Expand All @@ -405,6 +408,10 @@ func (co *CreateOptions) Complete(name string, cmd *cobra.Command, args []string
// Validate user specify registry
if co.devfileMetadata.devfileRegistry.Name != "" {

if co.forceS2i {
return errors.New("You can't specify registry via --registry if you want to force the S2I build with --s2i")
}

if co.devfileMetadata.devfilePath.value != "" {
return errors.New("you can't specify registry via --registry if you want to use the devfile that is specified via --devfile")
}
Expand Down Expand Up @@ -1019,6 +1026,23 @@ func (co *CreateOptions) Run() (err error) {
}
}

if !util.CheckPathExists(DevfilePath) {
// Download devfile from registry
params := util.DownloadParams{
Request: util.HTTPRequestParams{
URL: co.devfileMetadata.devfileRegistry.URL + co.devfileMetadata.devfileLink,
},
Filepath: DevfilePath,
}
if registryUtil.IsSecure(co.devfileMetadata.devfileRegistry.Name) {
token, err := keyring.Get(util.CredentialPrefix+co.devfileMetadata.devfileRegistry.Name, "default")
if err != nil {
return errors.Wrap(err, "unable to get secure registry credential from keyring")
}
params.Request.Token = token
}
}

if !util.CheckPathExists(DevfilePath) {
// Download devfile from registry
params := util.DownloadParams{
Expand Down Expand Up @@ -1067,11 +1091,6 @@ func (co *CreateOptions) Run() (err error) {
return err
}

err = util.AddFileToIgnoreFile(ignoreFile, filepath.Join(co.componentContext, envDir))
if err != nil {
return err
}

log.Italic("\nPlease use `odo push` command to create the component with source deployed")
return nil
}
Expand Down Expand Up @@ -1162,11 +1181,6 @@ func NewCmdCreate(name, fullName string) *cobra.Command {
componentCreateCmd.Flags().StringSliceVarP(&co.componentPorts, "port", "p", []string{}, "Ports to be used when the component is created (ex. 8080,8100/tcp,9100/udp)")
componentCreateCmd.Flags().StringSliceVar(&co.componentEnvVars, "env", []string{}, "Environmental variables for the component. For example --env VariableName=Value")

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")
componentCreateCmd.Flags().StringVar(&co.devfileMetadata.token, "token", "", "Token to be used when downloading devfile from the devfile path that is specified via --devfile")
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")
Expand Down
9 changes: 3 additions & 6 deletions pkg/odo/cli/component/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (do *DeleteOptions) Complete(name string, cmd *cobra.Command, args []string
do.devfilePath = filepath.Join(do.componentContext, DevfilePath)
ConfigFilePath = filepath.Join(do.componentContext, configFile)

// if experimental mode is enabled and devfile is present
// If devfile is present
if !do.componentDeleteS2iFlag && util.CheckPathExists(do.devfilePath) {
do.EnvSpecificInfo, err = envinfo.NewEnvSpecificInfo(do.componentContext)
if err != nil {
Expand All @@ -103,7 +103,7 @@ func (do *DeleteOptions) Complete(name string, cmd *cobra.Command, args []string
// Validate validates the list parameters
func (do *DeleteOptions) Validate() (err error) {

// if experimental mode is enabled and devfile is present
// If devfile is present
if !do.componentDeleteS2iFlag && util.CheckPathExists(do.devfilePath) {
return nil
}
Expand Down Expand Up @@ -311,10 +311,7 @@ func NewCmdDelete(name, fullName string) *cobra.Command {
componentDeleteCmd.Flags().BoolVarP(&do.componentDeleteWaitFlag, "wait", "w", false, "Wait for complete deletion of component and its dependent")
componentDeleteCmd.Flags().BoolVarP(&do.componentDeleteS2iFlag, "s2i", "", false, "Delete s2i component if devfile and s2i both component present with same name")

// enable show flag if experimental mode is enabled
if experimental.IsExperimentalModeEnabled() {
componentDeleteCmd.Flags().BoolVar(&do.show, "show-log", false, "If enabled, logs will be shown when deleted")
}
componentDeleteCmd.Flags().BoolVar(&do.show, "show-log", false, "If enabled, logs will be shown when deleted")

componentDeleteCmd.SetUsageTemplate(odoutil.CmdUsageTemplate)
completion.RegisterCommandHandler(componentDeleteCmd, completion.ComponentNameCompletionHandler)
Expand Down
2 changes: 1 addition & 1 deletion pkg/odo/cli/service/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func NewCmdServiceCreate(name, fullName string) *cobra.Command {
serviceCreateCmd.Use += fmt.Sprintf(" [flags]\n %s <operator_type>/<crd_name> [service_name] [flags]", o.CmdFullName)
serviceCreateCmd.Short = createShortDescExperimental
serviceCreateCmd.Long = createLongDescExperimental
serviceCreateCmd.Example += fmt.Sprintf("\n\n") + fmt.Sprintf(createOperatorExample, fullName)
serviceCreateCmd.Example += "\n\n" + fmt.Sprintf(createOperatorExample, fullName)
serviceCreateCmd.Flags().BoolVar(&o.DryRun, "dry-run", false, "Print the yaml specificiation that will be used to create the service")
// remove this feature after enabling service create interactive mode for operator backed services
serviceCreateCmd.Flags().StringVar(&o.fromFile, "from-file", "", "Path to the file containing yaml specification to use to start operator backed service")
Expand Down

0 comments on commit d72ddb7

Please sign in to comment.