From 1b473620b930a9d5702240f8b3e3639f83b525d1 Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Tue, 1 Sep 2020 10:29:37 -0400 Subject: [PATCH] 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 https://github.com/openshift/odo/issues/3550 **How to test changes / Special notes to the reviewer**: Run: ```sh odo preference set experimental false odo create --starter nodejs odo push ``` --- pkg/component/component.go | 23 +- pkg/component/component_full_description.go | 23 +- pkg/debug/portforward.go | 6 +- .../adapters/kubernetes/component/adapter.go | 2 +- pkg/devfile/validate/components_test.go | 2 +- pkg/occlient/occlient.go | 7 +- pkg/odo/cli/catalog/describe/component.go | 109 ++++---- pkg/odo/cli/catalog/list/services.go | 76 +++--- pkg/odo/cli/catalog/search/service.go | 79 +++--- pkg/odo/cli/cli.go | 13 +- pkg/odo/cli/component/common_link.go | 11 +- pkg/odo/cli/component/common_push.go | 2 +- pkg/odo/cli/component/component.go | 5 +- pkg/odo/cli/component/create.go | 191 +++++++------- pkg/odo/cli/component/delete.go | 12 +- pkg/odo/cli/component/devfile.go | 13 + pkg/odo/cli/component/exec.go | 4 +- pkg/odo/cli/component/link.go | 33 +-- pkg/odo/cli/component/list.go | 15 +- pkg/odo/cli/component/log.go | 5 +- pkg/odo/cli/component/push.go | 32 +-- pkg/odo/cli/component/update.go | 12 +- pkg/odo/cli/component/watch.go | 26 +- pkg/odo/cli/debug/info.go | 3 +- pkg/odo/cli/debug/portforward.go | 14 +- pkg/odo/cli/service/create.go | 43 ++-- pkg/odo/cli/service/delete.go | 14 +- pkg/odo/cli/service/list.go | 16 +- pkg/odo/cli/url/create.go | 42 ++-- pkg/odo/cli/url/delete.go | 10 +- pkg/odo/cli/url/describe.go | 26 +- pkg/odo/cli/url/list.go | 14 +- pkg/odo/util/cmdutils.go | 35 ++- pkg/url/url.go | 39 ++- pkg/url/url_test.go | 238 +++++++++--------- pkg/version/version.go | 2 +- tests/e2escenarios/e2e_beta_test.go | 10 +- tests/e2escenarios/e2e_java_test.go | 8 +- tests/e2escenarios/e2e_source_test.go | 10 +- tests/integration/cmd_app_test.go | 8 +- tests/integration/cmd_debug_test.go | 10 +- tests/integration/cmd_link_unlink_test.go | 22 +- tests/integration/cmd_pref_config_test.go | 14 +- tests/integration/cmd_push_test.go | 40 ++- tests/integration/cmd_storage_test.go | 10 +- tests/integration/cmd_url_test.go | 14 +- tests/integration/cmd_watch_test.go | 6 +- tests/integration/component.go | 99 ++++---- tests/integration/debug/cmd_debug_test.go | 2 +- .../devfile/cmd_devfile_catalog_test.go | 6 +- .../devfile/cmd_devfile_create_test.go | 50 +--- .../devfile/cmd_devfile_debug_test.go | 3 - .../devfile/cmd_devfile_delete_test.go | 3 - .../devfile/cmd_devfile_env_test.go | 1 - .../devfile/cmd_devfile_exec_test.go | 3 - .../devfile/cmd_devfile_log_test.go | 3 - .../devfile/cmd_devfile_push_test.go | 7 - .../devfile/cmd_devfile_registry_test.go | 2 - .../devfile/cmd_devfile_storage_test.go | 3 - .../devfile/cmd_devfile_test_test.go | 2 - .../devfile/cmd_devfile_url_test.go | 3 - .../devfile/cmd_devfile_watch_test.go | 3 - .../devfile/debug/cmd_devfile_debug_test.go | 3 - tests/integration/generic_test.go | 18 +- .../servicecatalog/cmd_service_test.go | 20 +- 65 files changed, 715 insertions(+), 865 deletions(-) diff --git a/pkg/component/component.go b/pkg/component/component.go index 3ecde110a77..d10c5764d97 100644 --- a/pkg/component/component.go +++ b/pkg/component/component.go @@ -25,7 +25,6 @@ import ( parsercommon "github.com/openshift/odo/pkg/devfile/parser/data/common" "github.com/openshift/odo/pkg/log" "github.com/openshift/odo/pkg/occlient" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/odo/util/validation" "github.com/openshift/odo/pkg/preference" "github.com/openshift/odo/pkg/storage" @@ -565,10 +564,10 @@ func ensureAndLogProperResourceUsage(resourceMin, resourceMax *string, resourceN // envSpecificInfo: Component environment specific information, available if uses devfile // cmpExist: true if components exists in the cluster // endpointMap: value is devfile endpoint entry, key is the TargetPort for each enpoint entry +// isS2I: Legacy option. Set as true if you want to use the old S2I method as it differentiates slightly. // Returns: // err: Errors if any else nil -func ApplyConfig(client *occlient.Client, kClient *kclient.Client, componentConfig config.LocalConfigInfo, envSpecificInfo envinfo.EnvSpecificInfo, stdout io.Writer, cmpExist bool, endpointMap map[int32]parsercommon.Endpoint) (err error) { - isExperimentalModeEnabled := experimental.IsExperimentalModeEnabled() +func ApplyConfig(client *occlient.Client, kClient *kclient.Client, componentConfig config.LocalConfigInfo, envSpecificInfo envinfo.EnvSpecificInfo, stdout io.Writer, cmpExist bool, endpointMap map[int32]parsercommon.Endpoint, isS2I bool) (err error) { if client == nil { var err error @@ -580,7 +579,7 @@ func ApplyConfig(client *occlient.Client, kClient *kclient.Client, componentConf client.Namespace = kClient.Namespace } - if !isExperimentalModeEnabled { + if isS2I { // if component exist then only call the update function if cmpExist { if err = Update(client, componentConfig, componentConfig.GetSourceLocation(), stdout); err != nil { @@ -591,7 +590,7 @@ func ApplyConfig(client *occlient.Client, kClient *kclient.Client, componentConf var componentName string var applicationName string - if !isExperimentalModeEnabled || kClient == nil { + if isS2I || kClient == nil { componentName = componentConfig.GetName() applicationName = componentConfig.GetApplication() } else { @@ -605,13 +604,13 @@ func ApplyConfig(client *occlient.Client, kClient *kclient.Client, componentConf } return urlpkg.Push(client, kClient, urlpkg.PushParameters{ - ComponentName: componentName, - ApplicationName: applicationName, - ConfigURLs: componentConfig.GetURL(), - EnvURLS: envSpecificInfo.GetURL(), - IsRouteSupported: isRouteSupported, - IsExperimentalModeEnabled: isExperimentalModeEnabled, - EndpointMap: endpointMap, + ComponentName: componentName, + ApplicationName: applicationName, + ConfigURLs: componentConfig.GetURL(), + EnvURLS: envSpecificInfo.GetURL(), + IsRouteSupported: isRouteSupported, + EndpointMap: endpointMap, + IsS2I: isS2I, }) } diff --git a/pkg/component/component_full_description.go b/pkg/component/component_full_description.go index e9f7e3986d6..00d9bd25a1d 100644 --- a/pkg/component/component_full_description.go +++ b/pkg/component/component_full_description.go @@ -8,7 +8,6 @@ import ( "github.com/openshift/odo/pkg/config" "github.com/openshift/odo/pkg/log" "github.com/openshift/odo/pkg/occlient" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/storage" urlpkg "github.com/openshift/odo/pkg/url" corev1 "k8s.io/api/core/v1" @@ -192,22 +191,20 @@ func (cfd *ComponentFullDescription) Print(client *occlient.Client) error { if len(cfd.Spec.URL.Items) > 0 { var output string - if !experimental.IsExperimentalModeEnabled() { - // if the component is not pushed - 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, "", experimental.IsExperimentalModeEnabled()), componentURL.Spec.Port) + 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) + } else { + var p string + if i >= len(cfd.Spec.Ports) { + p = cfd.Spec.Ports[len(cfd.Spec.Ports)-1] } else { - var p string - if i >= len(cfd.Spec.Ports) { - p = cfd.Spec.Ports[len(cfd.Spec.Ports)-1] - } else { - p = cfd.Spec.Ports[i] - } - output += fmt.Sprintf(" · URL named %s will be exposed via %v\n", componentURL.Name, p) + p = cfd.Spec.Ports[i] } + output += fmt.Sprintf(" · URL named %s will be exposed via %v\n", componentURL.Name, p) } } + // Cut off the last newline and output if len(output) > 0 { output = output[:len(output)-1] diff --git a/pkg/debug/portforward.go b/pkg/debug/portforward.go index e76fc37addb..3c20d558569 100644 --- a/pkg/debug/portforward.go +++ b/pkg/debug/portforward.go @@ -41,12 +41,12 @@ func NewDefaultPortForwarder(componentName, appName string, projectName string, // portPair is a pair of port in format "localPort:RemotePort" that is to be forwarded // stop Chan is used to stop port forwarding // ready Chan is used to signal failure to the channel receiver -func (f *DefaultPortForwarder) ForwardPorts(portPair string, stopChan, readyChan chan struct{}, isExperimental bool) error { +func (f *DefaultPortForwarder) ForwardPorts(portPair string, stopChan, readyChan chan struct{}, isDevfile bool) error { var pod *corev1.Pod var conf *rest.Config var err error - if f.kClient != nil && isExperimental { + if f.kClient != nil && isDevfile { conf, err = f.kClient.KubeConfig.ClientConfig() if err != nil { return err @@ -78,7 +78,7 @@ func (f *DefaultPortForwarder) ForwardPorts(portPair string, stopChan, readyChan } var req *rest.Request - if f.kClient != nil && isExperimental { + if f.kClient != nil && isDevfile { req = f.kClient.GeneratePortForwardReq(pod.Name) } else { req = f.client.BuildPortForwardReq(pod.Name) diff --git a/pkg/devfile/adapters/kubernetes/component/adapter.go b/pkg/devfile/adapters/kubernetes/component/adapter.go index 7914469056f..c3df07c5663 100644 --- a/pkg/devfile/adapters/kubernetes/component/adapter.go +++ b/pkg/devfile/adapters/kubernetes/component/adapter.go @@ -170,7 +170,7 @@ func (a Adapter) Push(parameters common.PushParameters) (err error) { return errors.Wrapf(err, "unable to get pod for component %s", a.ComponentName) } - err = component.ApplyConfig(nil, &a.Client, config.LocalConfigInfo{}, parameters.EnvSpecificInfo, color.Output, componentExists, endpointsMap) + err = component.ApplyConfig(nil, &a.Client, config.LocalConfigInfo{}, parameters.EnvSpecificInfo, color.Output, componentExists, endpointsMap, false) if err != nil { odoutil.LogErrorAndExit(err, "Failed to update config to component deployed.") } diff --git a/pkg/devfile/validate/components_test.go b/pkg/devfile/validate/components_test.go index 539a01a4367..b26e5704903 100644 --- a/pkg/devfile/validate/components_test.go +++ b/pkg/devfile/validate/components_test.go @@ -126,7 +126,7 @@ func TestValidateComponents(t *testing.T) { got := validateComponents(components) want := "size randomgarbage for volume component myvol is invalid" - if !strings.Contains(got.Error(), want) { + if got != nil && !strings.Contains(got.Error(), want) { t.Errorf("TestValidateComponents error - got: '%v', want substring: '%v'", got.Error(), want) } }) diff --git a/pkg/occlient/occlient.go b/pkg/occlient/occlient.go index 97c2d3cfe3d..3ab6edd1760 100644 --- a/pkg/occlient/occlient.go +++ b/pkg/occlient/occlient.go @@ -22,7 +22,6 @@ import ( "github.com/openshift/odo/pkg/config" "github.com/openshift/odo/pkg/devfile/adapters/common" "github.com/openshift/odo/pkg/log" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/preference" "github.com/openshift/odo/pkg/util" @@ -719,11 +718,7 @@ func (c *Client) GetImageStream(imageNS string, imageName string, imageTag strin } } if e != nil && err != nil { - // Imagestream not found in openshift and current namespaces - if experimental.IsExperimentalModeEnabled() { - return nil, fmt.Errorf("component type %q not found", imageName) - } - return nil, err + return nil, fmt.Errorf("component type %q not found", imageName) } // Required tag not in openshift and current namespaces diff --git a/pkg/odo/cli/catalog/describe/component.go b/pkg/odo/cli/catalog/describe/component.go index 18b0f3a8be4..3c30524090e 100644 --- a/pkg/odo/cli/catalog/describe/component.go +++ b/pkg/odo/cli/catalog/describe/component.go @@ -13,7 +13,6 @@ import ( "github.com/openshift/odo/pkg/log" "github.com/openshift/odo/pkg/machineoutput" "github.com/openshift/odo/pkg/odo/genericclioptions" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/odo/util/pushtarget" "github.com/openshift/odo/pkg/util" "github.com/pkg/errors" @@ -62,11 +61,11 @@ func (o *DescribeComponentOptions) Complete(name string, cmd *cobra.Command, arg tasks.Add(util.ConcurrentTask{ToRun: func(errChannel chan error) { catalogList, err := catalog.ListComponents(o.Client) if err != nil { - if experimental.IsExperimentalModeEnabled() { - klog.V(4).Info("Please log in to an OpenShift cluster to list OpenShift/s2i components") - } else { - errChannel <- err - } + // TODO: + // This MAY have to change in the future.. There is no good way to determine whether the user + // wants to list OpenShift or Kubernetes components. So we simply just warn in debug V(4) if + // we are unable to list anything from OpenShift. + klog.V(4).Info("Please log in to an OpenShift cluster to list OpenShift/s2i components") } for _, image := range catalogList.Items { if image.Name == o.componentName { @@ -76,18 +75,16 @@ func (o *DescribeComponentOptions) Complete(name string, cmd *cobra.Command, arg }}) } - if experimental.IsExperimentalModeEnabled() { - tasks.Add(util.ConcurrentTask{ToRun: func(errChannel chan error) { - catalogDevfileList, err := catalog.ListDevfileComponents("") - if catalogDevfileList.DevfileRegistries == nil { - log.Warning("Please run 'odo registry add ' to add registry for listing devfile components\n") - } - if err != nil { - errChannel <- err - } - o.GetDevfileComponentsByName(catalogDevfileList) - }}) - } + tasks.Add(util.ConcurrentTask{ToRun: func(errChannel chan error) { + catalogDevfileList, err := catalog.ListDevfileComponents("") + if catalogDevfileList.DevfileRegistries == nil { + log.Warning("Please run 'odo registry add ' to add registry for listing devfile components\n") + } + if err != nil { + errChannel <- err + } + o.GetDevfileComponentsByName(catalogDevfileList) + }}) return tasks.Run() } @@ -103,50 +100,48 @@ func (o *DescribeComponentOptions) Validate() (err error) { // Run contains the logic for the command associated with DescribeComponentOptions func (o *DescribeComponentOptions) Run() (err error) { - if experimental.IsExperimentalModeEnabled() { - w := tabwriter.NewWriter(os.Stdout, 5, 2, 3, ' ', tabwriter.TabIndent) - if log.IsJSON() { - if len(o.devfileComponents) > 0 { - for _, devfileComponent := range o.devfileComponents { - devObj, err := GetDevfile(devfileComponent) - if err != nil { - return err - } - - machineoutput.OutputSuccess(devObj) + w := tabwriter.NewWriter(os.Stdout, 5, 2, 3, ' ', tabwriter.TabIndent) + if log.IsJSON() { + if len(o.devfileComponents) > 0 { + for _, devfileComponent := range o.devfileComponents { + devObj, err := GetDevfile(devfileComponent) + if err != nil { + return err } + + machineoutput.OutputSuccess(devObj) } - } else { - if len(o.devfileComponents) > 1 { - log.Warningf("There are multiple components named \"%s\" in different multiple devfile registries.\n", o.componentName) - } - if len(o.devfileComponents) > 0 { - fmt.Fprintln(w, "Devfile Component(s):") - - for _, devfileComponent := range o.devfileComponents { - fmt.Fprintln(w, "\n* Registry: "+devfileComponent.Registry.Name) - - devObj, err := GetDevfile(devfileComponent) - if err != nil { - return err - } - - projects := devObj.Data.GetStarterProjects() - // only print project info if there is at least one project in the devfile - err = o.PrintDevfileStarterProjects(w, projects, devObj) - if err != nil { - return err - } + } + } else { + if len(o.devfileComponents) > 1 { + log.Warningf("There are multiple components named \"%s\" in different multiple devfile registries.\n", o.componentName) + } + if len(o.devfileComponents) > 0 { + fmt.Fprintln(w, "Devfile Component(s):") + + for _, devfileComponent := range o.devfileComponents { + fmt.Fprintln(w, "\n* Registry: "+devfileComponent.Registry.Name) + + devObj, err := GetDevfile(devfileComponent) + if err != nil { + return err + } + + projects := devObj.Data.GetStarterProjects() + // only print project info if there is at least one project in the devfile + err = o.PrintDevfileStarterProjects(w, projects, devObj) + if err != nil { + return err } - } else { - fmt.Fprintln(w, "There are no Odo devfile components with the name \""+o.componentName+"\"") - } - if o.component != "" { - fmt.Fprintln(w, "\nS2I Based Components:") - fmt.Fprintln(w, "-"+o.component) } - fmt.Fprintln(w) + } else { + fmt.Fprintln(w, "There are no Odo devfile components with the name \""+o.componentName+"\"") + } + if o.component != "" { + fmt.Fprintln(w, "\nS2I Based Components:") + fmt.Fprintln(w, "-"+o.component) } + fmt.Fprintln(w) } return nil diff --git a/pkg/odo/cli/catalog/list/services.go b/pkg/odo/cli/catalog/list/services.go index 76c32490c5e..8a4929c1073 100644 --- a/pkg/odo/cli/catalog/list/services.go +++ b/pkg/odo/cli/catalog/list/services.go @@ -2,14 +2,14 @@ package list import ( "fmt" - "k8s.io/apimachinery/pkg/apis/meta/v1" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/openshift/odo/pkg/catalog" "github.com/openshift/odo/pkg/log" "github.com/openshift/odo/pkg/machineoutput" "github.com/openshift/odo/pkg/odo/cli/catalog/util" "github.com/openshift/odo/pkg/odo/genericclioptions" - "github.com/openshift/odo/pkg/odo/util/experimental" olm "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" "github.com/spf13/cobra" ) @@ -36,57 +36,41 @@ func NewListServicesOptions() *ListServicesOptions { // Complete completes ListServicesOptions after they've been created func (o *ListServicesOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) { - if experimental.IsExperimentalModeEnabled() { - var noCsvs, noServices bool - o.Context = genericclioptions.NewContext(cmd) - o.csvs, err = o.KClient.GetClusterServiceVersionList() - if err != nil { - // Error only occurs when OperatorHub is not installed/enabled on the - // Kubernetes or OpenShift 4.x cluster. It doesn't occur when there are - // no operators installed. - noCsvs = true - } - - o.services, err = catalog.ListServices(o.Client) - if err != nil { - // Error occurs if Service Catalog is not enabled on the OpenShift - // 3.x/4.x cluster - noServices = true - // But we don't care about the Service Catalog not being enabled if - // it's 4.x or k8s cluster - if !noCsvs { - err = nil - } - } + var noCsvs, noServices bool + o.Context = genericclioptions.NewContext(cmd) + o.csvs, err = o.KClient.GetClusterServiceVersionList() + if err != nil { + // Error only occurs when OperatorHub is not installed/enabled on the + // Kubernetes or OpenShift 4.x cluster. It doesn't occur when there are + // no operators installed. + noCsvs = true + } - if noCsvs && noServices { - // Neither OperatorHub nor Service Catalog is enabled on the cluster - return fmt.Errorf("unable to list services because neither Service Catalog nor Operator Hub is enabled in your cluster: %v", err) + o.services, err = catalog.ListServices(o.Client) + if err != nil { + // Error occurs if Service Catalog is not enabled on the OpenShift + // 3.x/4.x cluster + noServices = true + // But we don't care about the Service Catalog not being enabled if + // it's 4.x or k8s cluster + if !noCsvs { + err = nil } - o.services = util.FilterHiddenServices(o.services) - } else { - o.Context = genericclioptions.NewContext(cmd) - o.services, err = catalog.ListServices(o.Client) - if err != nil { - return fmt.Errorf("unable to list services because Service Catalog is not enabled in your cluster: %v", err) + } - } - o.services = util.FilterHiddenServices(o.services) + if noCsvs && noServices { + // Neither OperatorHub nor Service Catalog is enabled on the cluster + return fmt.Errorf("unable to list services because neither Service Catalog nor Operator Hub is enabled in your cluster: %v", err) } + o.services = util.FilterHiddenServices(o.services) return } // Validate validates the ListServicesOptions based on completed values func (o *ListServicesOptions) Validate() (err error) { - if experimental.IsExperimentalModeEnabled() { - if len(o.services.Items) == 0 && len(o.csvs.Items) == 0 { - return fmt.Errorf("no deployable services/operators found") - } - } else { - if len(o.services.Items) == 0 { - return fmt.Errorf("no deployable services found") - } + if len(o.services.Items) == 0 && len(o.csvs.Items) == 0 { + return fmt.Errorf("no deployable services/operators found") } return } @@ -96,10 +80,8 @@ func (o *ListServicesOptions) Run() (err error) { if log.IsJSON() { machineoutput.OutputSuccess(newCatalogListOutput(&o.services, o.csvs)) } else { - if experimental.IsExperimentalModeEnabled() { - if len(o.csvs.Items) > 0 { - util.DisplayClusterServiceVersions(o.csvs) - } + if len(o.csvs.Items) > 0 { + util.DisplayClusterServiceVersions(o.csvs) } if len(o.services.Items) > 0 { util.DisplayServices(o.services) diff --git a/pkg/odo/cli/catalog/search/service.go b/pkg/odo/cli/catalog/search/service.go index 427f5c7062d..cd3ffdb641c 100644 --- a/pkg/odo/cli/catalog/search/service.go +++ b/pkg/odo/cli/catalog/search/service.go @@ -6,7 +6,6 @@ import ( "github.com/openshift/odo/pkg/catalog" "github.com/openshift/odo/pkg/odo/cli/catalog/util" "github.com/openshift/odo/pkg/odo/genericclioptions" - "github.com/openshift/odo/pkg/odo/util/experimental" olm "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" "github.com/spf13/cobra" ) @@ -32,69 +31,51 @@ func NewSearchServiceOptions() *SearchServiceOptions { // Complete completes SearchServiceOptions after they've been created func (o *SearchServiceOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) { - if experimental.IsExperimentalModeEnabled() { - var noCsvs, noServices bool - o.Context = genericclioptions.NewContext(cmd) - o.searchTerm = args[0] - o.csvs, err = o.KClient.SearchClusterServiceVersionList(o.searchTerm) - if err != nil { - // Error only occurs when OperatorHub is not installed/enabled on the - // Kubernetes or OpenShift 4.x cluster. It doesn't occur when there are - // no operators installed. - noCsvs = true - } + var noCsvs, noServices bool + o.Context = genericclioptions.NewContext(cmd) + o.searchTerm = args[0] + o.csvs, err = o.KClient.SearchClusterServiceVersionList(o.searchTerm) + if err != nil { + // Error only occurs when OperatorHub is not installed/enabled on the + // Kubernetes or OpenShift 4.x cluster. It doesn't occur when there are + // no operators installed. + noCsvs = true + } - o.services, err = catalog.SearchService(o.Client, o.searchTerm) - if err != nil { - // Error occurs if Service Catalog is not enabled on the OpenShift - // 3.x/4.x cluster - noServices = true - // But we don't care about the Service Catalog not being enabled if - // it's 4.x or k8s cluster - if !noCsvs { - err = nil - } + // Checks service catalog, but if its not available, we do not error. + o.services, err = catalog.SearchService(o.Client, o.searchTerm) + if err != nil { + // Error occurs if Service Catalog is not enabled on the OpenShift + // 3.x/4.x cluster + noServices = true + // But we don't care about the Service Catalog not being enabled if + // it's 4.x or k8s cluster + if !noCsvs { + err = nil } + } - if noCsvs && noServices { - // Neither OperatorHub nor Service Catalog is enabled on the cluster - return fmt.Errorf("unable to list services because neither Service Catalog nor Operator Hub is enabled in your cluster: %v", err) - } - o.services = util.FilterHiddenServices(o.services) - } else { - o.Context = genericclioptions.NewContext(cmd) - o.searchTerm = args[0] - - o.services, err = catalog.SearchService(o.Client, o.searchTerm) - if err != nil { - return fmt.Errorf("unable to list services because Service Catalog is not enabled in your cluster: %v", err) - } - o.services = util.FilterHiddenServices(o.services) + if noCsvs && noServices { + // Neither OperatorHub nor Service Catalog is enabled on the cluster + return fmt.Errorf("unable to list services because neither Service Catalog nor Operator Hub is enabled in your cluster: %v", err) } + o.services = util.FilterHiddenServices(o.services) + return err } // Validate validates the SearchServiceOptions based on completed values func (o *SearchServiceOptions) Validate() (err error) { - if experimental.IsExperimentalModeEnabled() { - if len(o.services.Items) == 0 && len(o.csvs.Items) == 0 { - return fmt.Errorf("no service matched the query: %s", o.searchTerm) - } - } else { - if len(o.services.Items) == 0 { - return fmt.Errorf("no service matched the query: %s", o.searchTerm) - } + if len(o.services.Items) == 0 && len(o.csvs.Items) == 0 { + return fmt.Errorf("no service matched the query: %s", o.searchTerm) } - return } // Run contains the logic for the command associated with SearchServiceOptions func (o *SearchServiceOptions) Run() (err error) { - if experimental.IsExperimentalModeEnabled() { - if len(o.csvs.Items) > 0 { - util.DisplayClusterServiceVersions(o.csvs) - } + if len(o.csvs.Items) > 0 { + util.DisplayClusterServiceVersions(o.csvs) } if len(o.services.Items) > 0 { util.DisplayServices(o.services) diff --git a/pkg/odo/cli/cli.go b/pkg/odo/cli/cli.go index 8216a995f25..ca0087e4a35 100644 --- a/pkg/odo/cli/cli.go +++ b/pkg/odo/cli/cli.go @@ -25,7 +25,6 @@ import ( "github.com/openshift/odo/pkg/odo/cli/version" "github.com/openshift/odo/pkg/odo/util" odoutil "github.com/openshift/odo/pkg/odo/util" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -204,15 +203,13 @@ func odoRootCmd(name, fullName string) *cobra.Command { config.NewCmdConfiguration(config.RecommendedCommandName, util.GetFullName(fullName, config.RecommendedCommandName)), preference.NewCmdPreference(preference.RecommendedCommandName, util.GetFullName(fullName, preference.RecommendedCommandName)), debug.NewCmdDebug(debug.RecommendedCommandName, util.GetFullName(fullName, debug.RecommendedCommandName)), + registry.NewCmdRegistry(registry.RecommendedCommandName, util.GetFullName(fullName, registry.RecommendedCommandName)), + component.NewCmdTest(component.TestRecommendedCommandName, util.GetFullName(fullName, component.TestRecommendedCommandName)), ) - if experimental.IsExperimentalModeEnabled() { - rootCmd.AddCommand( - registry.NewCmdRegistry(registry.RecommendedCommandName, util.GetFullName(fullName, registry.RecommendedCommandName)), - component.NewCmdTest(component.TestRecommendedCommandName, util.GetFullName(fullName, component.TestRecommendedCommandName)), - env.NewCmdEnv(env.RecommendedCommandName, util.GetFullName(fullName, env.RecommendedCommandName)), - ) - } + rootCmd.AddCommand( + env.NewCmdEnv(env.RecommendedCommandName, util.GetFullName(fullName, env.RecommendedCommandName)), + ) odoutil.VisitCommands(rootCmd, reconfigureCmdWithSubcmd) diff --git a/pkg/odo/cli/component/common_link.go b/pkg/odo/cli/component/common_link.go index b50daa52032..650d349a234 100644 --- a/pkg/odo/cli/component/common_link.go +++ b/pkg/odo/cli/component/common_link.go @@ -12,7 +12,6 @@ import ( "github.com/openshift/odo/pkg/log" "github.com/openshift/odo/pkg/occlient" "github.com/openshift/odo/pkg/odo/genericclioptions" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/secret" svc "github.com/openshift/odo/pkg/service" "github.com/openshift/odo/pkg/util" @@ -40,6 +39,8 @@ type commonLinkOptions struct { secretName string isTargetAService bool + devfilePath string + suppliedName string operation func(secretName, componentName, applicationName string) error operationName string @@ -57,12 +58,13 @@ func newCommonLinkOptions() *commonLinkOptions { // Complete completes LinkOptions after they've been created func (o *commonLinkOptions) complete(name string, cmd *cobra.Command, args []string) (err error) { + o.operationName = name suppliedName := args[0] o.suppliedName = suppliedName - if experimental.IsExperimentalModeEnabled() { + if util.CheckPathExists(o.devfilePath) { o.Context = genericclioptions.NewDevfileContext(cmd) oclient, err := occlient.New() @@ -168,7 +170,7 @@ func (o *commonLinkOptions) complete(name string, cmd *cobra.Command, args []str func (o *commonLinkOptions) validate(wait bool) (err error) { - if experimental.IsExperimentalModeEnabled() { + if util.CheckPathExists(o.devfilePath) { // let's validate if the service exists svcFullName := strings.Join([]string{o.serviceType, o.serviceName}, "/") svcExists, err := svc.OperatorSvcExists(o.KClient, svcFullName) @@ -263,7 +265,7 @@ func (o *commonLinkOptions) validate(wait bool) (err error) { } func (o *commonLinkOptions) run() (err error) { - if experimental.IsExperimentalModeEnabled() { + if util.CheckPathExists(o.devfilePath) { if o.operationName == unlink { sbrName := getSBRName(o.EnvSpecificInfo.GetName(), o.serviceType, o.serviceName) svcFullName := getSvcFullName(sbrKind, sbrName) @@ -282,6 +284,7 @@ func (o *commonLinkOptions) run() (err error) { return } + // convert service binding request into a ma[string]interface{} type so // as to use it with dynamic client sbrMap := make(map[string]interface{}) diff --git a/pkg/odo/cli/component/common_push.go b/pkg/odo/cli/component/common_push.go index d9357ba4786..cb6d696ea64 100644 --- a/pkg/odo/cli/component/common_push.go +++ b/pkg/odo/cli/component/common_push.go @@ -128,7 +128,7 @@ func (cpo *CommonPushOptions) createCmpIfNotExistsAndApplyCmpConfig(stdout io.Wr } } // Apply config - err := component.ApplyConfig(cpo.Context.Client, nil, *cpo.LocalConfigInfo, envinfo.EnvSpecificInfo{}, stdout, cpo.doesComponentExist, map[int32]parsercommon.Endpoint{}) + err := component.ApplyConfig(cpo.Context.Client, nil, *cpo.LocalConfigInfo, envinfo.EnvSpecificInfo{}, stdout, cpo.doesComponentExist, map[int32]parsercommon.Endpoint{}, true) if err != nil { odoutil.LogErrorAndExit(err, "Failed to update config to component deployed.") } diff --git a/pkg/odo/cli/component/component.go b/pkg/odo/cli/component/component.go index 763a7a8d559..7443ece2592 100644 --- a/pkg/odo/cli/component/component.go +++ b/pkg/odo/cli/component/component.go @@ -9,7 +9,6 @@ import ( "github.com/openshift/odo/pkg/log" "github.com/openshift/odo/pkg/occlient" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/url" "github.com/pkg/errors" @@ -73,9 +72,7 @@ func NewCmdComponent(name, fullName string) *cobra.Command { componentCmd.Flags().AddFlagSet(componentGetCmd.Flags()) componentCmd.AddCommand(componentGetCmd, createCmd, deleteCmd, describeCmd, linkCmd, unlinkCmd, listCmd, logCmd, pushCmd, updateCmd, watchCmd, execCmd) - if experimental.IsExperimentalModeEnabled() { - componentCmd.AddCommand(testCmd) - } + componentCmd.AddCommand(testCmd) // Add a defined annotation in order to appear in the help menu componentCmd.Annotations = map[string]string{"command": "main"} diff --git a/pkg/odo/cli/component/create.go b/pkg/odo/cli/component/create.go index 404f1e7ed0e..c3740bd6a26 100644 --- a/pkg/odo/cli/component/create.go +++ b/pkg/odo/cli/component/create.go @@ -30,7 +30,6 @@ import ( "github.com/openshift/odo/pkg/odo/genericclioptions" odoutil "github.com/openshift/odo/pkg/odo/util" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/odo/util/pushtarget" "github.com/openshift/odo/pkg/preference" "github.com/openshift/odo/pkg/util" @@ -82,24 +81,12 @@ const CreateRecommendedCommandName = "create" // since the application will always be in the same directory as `.odo`, we will always set this as: ./ const LocalDirectoryDefaultLocation = "./" -// Constants for devfile component -const ( - devFile = "devfile.yaml" -) - var ( envFile = filepath.Join(".odo", "env", "env.yaml") configFile = filepath.Join(".odo", "config.yaml") envDir = filepath.Join(".odo", "env") ) -// DevfilePath is the devfile path that is used by odo, -// which means odo can: -// 1. Directly use the devfile in DevfilePath -// 2. Download devfile from registry to DevfilePath then use the devfile in DevfilePath -// 3. Copy user's own devfile (path is specified via --devfile flag) to DevfilePath then use the devfile in DevfilePath -var DevfilePath = filepath.Join(LocalDirectoryDefaultLocation, devFile) - // EnvFilePath is the path of env file for devfile component var EnvFilePath = filepath.Join(LocalDirectoryDefaultLocation, envFile) @@ -307,7 +294,7 @@ func (co *CreateOptions) checkConflictingFlags() (err error) { func (co *CreateOptions) checkConflictingS2IFlags() error { if !co.forceS2i { - errorString := "flag --%s, requires --s2i flag to be set, when in experimental mode." + errorString := "flag --%s, requires --s2i flag to be set, when deploying S2I (Source-to-Image)." var flagName string if co.now { @@ -356,9 +343,8 @@ func (co *CreateOptions) Complete(name string, cmd *cobra.Command, args []string // this populates the LocalConfigInfo as well co.Context = genericclioptions.NewContextCreatingAppIfNeeded(cmd) - if experimental.IsExperimentalModeEnabled() { - // Add a disclaimer that we are in *experimental mode* - log.Experimental("Experimental mode is enabled, use at your own risk") + // If not using --s2i + if !co.forceS2i { err = co.checkConflictingFlags() if err != nil { @@ -838,29 +824,27 @@ func (co *CreateOptions) Complete(name string, cmd *cobra.Command, args []string // Validate validates the create parameters func (co *CreateOptions) Validate() (err error) { - if experimental.IsExperimentalModeEnabled() { - if !co.forceS2i && co.devfileMetadata.devfileSupport { - // Validate if the devfile component that user wants to create already exists - spinner := log.Spinner("Validating devfile component") - defer spinner.End(false) + if !co.forceS2i && co.devfileMetadata.devfileSupport { + // Validate if the devfile component that user wants to create already exists + spinner := log.Spinner("Validating devfile component") + defer spinner.End(false) + + err = util.ValidateK8sResourceName("component name", co.devfileMetadata.componentName) + if err != nil { + return err + } - err = util.ValidateK8sResourceName("component name", co.devfileMetadata.componentName) + // Only validate namespace if pushtarget isn't docker + if !pushtarget.IsPushTargetDocker() { + err := util.ValidateK8sResourceName("component namespace", co.devfileMetadata.componentNamespace) if err != nil { return err } + } - // Only validate namespace if pushtarget isn't docker - if !pushtarget.IsPushTargetDocker() { - err := util.ValidateK8sResourceName("component namespace", co.devfileMetadata.componentNamespace) - if err != nil { - return err - } - } - - spinner.End(true) + spinner.End(true) - return nil - } + return nil } log.Info("Validation") @@ -984,97 +968,96 @@ func (co *CreateOptions) downloadStarterProject(projectPassed string, interactiv // Run has the logic to perform the required actions as part of command func (co *CreateOptions) Run() (err error) { - if experimental.IsExperimentalModeEnabled() { - if !co.forceS2i && co.devfileMetadata.devfileSupport { - // Use existing devfile directly from --devfile flag - if co.devfileMetadata.devfilePath.value != "" { - if co.devfileMetadata.devfilePath.protocol == "http(s)" { - // User specify devfile path is http(s) URL - params := util.DownloadParams{ - Request: util.HTTPRequestParams{ - URL: co.devfileMetadata.devfilePath.value, - Token: co.devfileMetadata.token, - }, - Filepath: DevfilePath, - } - err = util.DownloadFile(params) - if err != nil { - return errors.Wrapf(err, "failed to download devfile for devfile component from %s", co.devfileMetadata.devfilePath.value) - } - } else if co.devfileMetadata.devfilePath.protocol == "file" { - // User specify devfile path is file system link - info, err := os.Stat(co.devfileMetadata.devfilePath.value) - if err != nil { - return err - } - err = util.CopyFile(co.devfileMetadata.devfilePath.value, DevfilePath, info) - if err != nil { - return errors.Wrapf(err, "failed to copy devfile from %s to %s", co.devfileMetadata.devfilePath, DevfilePath) - } - } - } - if !util.CheckPathExists(DevfilePath) { - // Download devfile from registry + if !co.forceS2i && co.devfileMetadata.devfileSupport { + // Use existing devfile directly from --devfile flag + if co.devfileMetadata.devfilePath.value != "" { + if co.devfileMetadata.devfilePath.protocol == "http(s)" { + // User specify devfile path is http(s) URL params := util.DownloadParams{ Request: util.HTTPRequestParams{ - URL: co.devfileMetadata.devfileRegistry.URL + co.devfileMetadata.devfileLink, + URL: co.devfileMetadata.devfilePath.value, + Token: co.devfileMetadata.token, }, 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 + err = util.DownloadFile(params) + if err != nil { + return errors.Wrapf(err, "failed to download devfile for devfile component from %s", co.devfileMetadata.devfilePath.value) } - - cfg, err := preference.New() + } else if co.devfileMetadata.devfilePath.protocol == "file" { + // User specify devfile path is file system link + info, err := os.Stat(co.devfileMetadata.devfilePath.value) if err != nil { return err } - err = util.DownloadFileWithCache(params, cfg.GetRegistryCacheTime()) + err = util.CopyFile(co.devfileMetadata.devfilePath.value, DevfilePath, info) if err != nil { - return errors.Wrapf(err, "failed to download devfile for devfile component from %s", co.devfileMetadata.devfileRegistry.URL+co.devfileMetadata.devfileLink) + return errors.Wrapf(err, "failed to copy devfile from %s to %s", co.devfileMetadata.devfilePath, DevfilePath) } } + } - if util.CheckPathExists(DevfilePath) { - err = co.downloadStarterProject(co.devfileMetadata.starter, co.interactive) + 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, "failed to download project for devfile component") + return errors.Wrap(err, "unable to get secure registry credential from keyring") } + params.Request.Token = token } - // Generate env file - err = co.EnvSpecificInfo.SetComponentSettings(envinfo.ComponentSettings{ - Name: co.devfileMetadata.componentName, - Namespace: co.devfileMetadata.componentNamespace, - AppName: co.appName, - }) + cfg, err := preference.New() if err != nil { - return errors.Wrap(err, "failed to create env file for devfile component") + return err } - - sourcePath, err := util.GetAbsPath(co.componentContext) + err = util.DownloadFileWithCache(params, cfg.GetRegistryCacheTime()) if err != nil { - return errors.Wrap(err, "unable to get source path") + return errors.Wrapf(err, "failed to download devfile for devfile component from %s", co.devfileMetadata.devfileRegistry.URL+co.devfileMetadata.devfileLink) } + } - ignoreFile, err := util.CheckGitIgnoreFile(sourcePath) + if util.CheckPathExists(DevfilePath) { + err = co.downloadStarterProject(co.devfileMetadata.starter, co.interactive) if err != nil { - return err + return errors.Wrap(err, "failed to download project for devfile component") } + } - err = util.AddFileToIgnoreFile(ignoreFile, filepath.Join(co.componentContext, envDir)) - if err != nil { - return err - } + // Generate env file + err = co.EnvSpecificInfo.SetComponentSettings(envinfo.ComponentSettings{ + Name: co.devfileMetadata.componentName, + Namespace: co.devfileMetadata.componentNamespace, + AppName: co.appName, + }) + if err != nil { + return errors.Wrap(err, "failed to create env file for devfile component") + } - log.Italic("\nPlease use `odo push` command to create the component with source deployed") - return nil + sourcePath, err := util.GetAbsPath(co.componentContext) + if err != nil { + return errors.Wrap(err, "unable to get source path") + } + + ignoreFile, err := util.CheckGitIgnoreFile(sourcePath) + if err != nil { + 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 } err = co.LocalConfigInfo.SetComponentSettings(co.componentSettings) @@ -1217,14 +1200,12 @@ 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") - if experimental.IsExperimentalModeEnabled() { - componentCreateCmd.Flags().StringVar(&co.devfileMetadata.starter, "starter", "", "Download a project specified in the devfile") - componentCreateCmd.Flags().Lookup("starter").NoOptDefVal = defaultStarterProjectName //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 specified 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().BoolVar(&co.forceS2i, "s2i", false, "Enforce S2I type components") - } + componentCreateCmd.Flags().StringVar(&co.devfileMetadata.starter, "starter", "", "Download a project specified in the devfile") + componentCreateCmd.Flags().Lookup("starter").NoOptDefVal = defaultStarterProjectName //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 specified 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().BoolVar(&co.forceS2i, "s2i", false, "Enforce S2I type components") componentCreateCmd.SetUsageTemplate(odoutil.CmdUsageTemplate) diff --git a/pkg/odo/cli/component/delete.go b/pkg/odo/cli/component/delete.go index cb510adc155..675eb975b7a 100644 --- a/pkg/odo/cli/component/delete.go +++ b/pkg/odo/cli/component/delete.go @@ -6,7 +6,6 @@ import ( "path/filepath" "github.com/openshift/odo/pkg/envinfo" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/odo/util/pushtarget" "github.com/openshift/odo/pkg/util" @@ -80,7 +79,7 @@ func (do *DeleteOptions) Complete(name string, cmd *cobra.Command, args []string ConfigFilePath = filepath.Join(do.componentContext, configFile) // if experimental mode is enabled and devfile is present - if !do.componentDeleteS2iFlag && experimental.IsExperimentalModeEnabled() && util.CheckPathExists(do.devfilePath) { + if !do.componentDeleteS2iFlag && util.CheckPathExists(do.devfilePath) { do.EnvSpecificInfo, err = envinfo.NewEnvSpecificInfo(do.componentContext) if err != nil { return err @@ -105,7 +104,7 @@ func (do *DeleteOptions) Complete(name string, cmd *cobra.Command, args []string func (do *DeleteOptions) Validate() (err error) { // if experimental mode is enabled and devfile is present - if !do.componentDeleteS2iFlag && experimental.IsExperimentalModeEnabled() && util.CheckPathExists(do.devfilePath) { + if !do.componentDeleteS2iFlag && util.CheckPathExists(do.devfilePath) { return nil } @@ -132,7 +131,7 @@ func (do *DeleteOptions) Run() (err error) { klog.V(4).Infof("component delete called") klog.V(4).Infof("args: %#v", do) - if !do.componentDeleteS2iFlag && experimental.IsExperimentalModeEnabled() && util.CheckPathExists(do.devfilePath) { + if !do.componentDeleteS2iFlag && util.CheckPathExists(do.devfilePath) { return do.DevFileRun() } @@ -312,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) diff --git a/pkg/odo/cli/component/devfile.go b/pkg/odo/cli/component/devfile.go index af449821696..790abc907fb 100644 --- a/pkg/odo/cli/component/devfile.go +++ b/pkg/odo/cli/component/devfile.go @@ -2,6 +2,7 @@ package component import ( "os" + "path/filepath" "strings" "github.com/openshift/odo/pkg/devfile" @@ -32,6 +33,18 @@ The behaviour of this feature is subject to change as development for this feature progresses. */ +// Constants for devfile component +const ( + devFile = "devfile.yaml" +) + +// DevfilePath is the devfile path that is used by odo, +// which means odo can: +// 1. Directly use the devfile in DevfilePath +// 2. Download devfile from registry to DevfilePath then use the devfile in DevfilePath +// 3. Copy user's own devfile (path is specified via --devfile flag) to DevfilePath then use the devfile in DevfilePath +var DevfilePath = filepath.Join(LocalDirectoryDefaultLocation, devFile) + // DevfilePush has the logic to perform the required actions for a given devfile func (po *PushOptions) DevfilePush() error { diff --git a/pkg/odo/cli/component/exec.go b/pkg/odo/cli/component/exec.go index 213147cf96b..a4dc3849c79 100644 --- a/pkg/odo/cli/component/exec.go +++ b/pkg/odo/cli/component/exec.go @@ -8,8 +8,8 @@ import ( "github.com/openshift/odo/pkg/odo/genericclioptions" odoutil "github.com/openshift/odo/pkg/odo/util" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/odo/util/pushtarget" + "github.com/openshift/odo/pkg/util" "path/filepath" @@ -64,7 +64,7 @@ Please provide a command to execute, odo exec -- `) eo.devfilePath = filepath.Join(eo.componentContext, devFile) // if experimental mode is enabled and devfile is present - if experimental.IsExperimentalModeEnabled() { + if util.CheckPathExists(eo.devfilePath) { eo.componentOptions.Context = genericclioptions.NewDevfileContext(cmd) if !pushtarget.IsPushTargetDocker() { diff --git a/pkg/odo/cli/component/link.go b/pkg/odo/cli/component/link.go index 5a9620f14f2..bf54cac7621 100644 --- a/pkg/odo/cli/component/link.go +++ b/pkg/odo/cli/component/link.go @@ -2,17 +2,17 @@ package component import ( "fmt" + "path/filepath" "github.com/openshift/odo/pkg/component" "github.com/openshift/odo/pkg/odo/genericclioptions" sbo "github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1" - appCmd "github.com/openshift/odo/pkg/odo/cli/application" projectCmd "github.com/openshift/odo/pkg/odo/cli/project" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" + "github.com/openshift/odo/pkg/util" - "github.com/openshift/odo/pkg/odo/util" + odoutil "github.com/openshift/odo/pkg/odo/util" ktemplates "k8s.io/kubectl/pkg/util/templates" "github.com/spf13/cobra" @@ -88,6 +88,7 @@ odo link EtcdCluster/myetcd type LinkOptions struct { waitForTarget bool componentContext string + *commonLinkOptions } @@ -101,8 +102,10 @@ func NewLinkOptions() *LinkOptions { // Complete completes LinkOptions after they've been created func (o *LinkOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) { + o.commonLinkOptions.devfilePath = filepath.Join(o.componentContext, DevfilePath) + err = o.complete(name, cmd, args) - if !experimental.IsExperimentalModeEnabled() { + if !util.CheckPathExists(o.commonLinkOptions.devfilePath) { o.operation = o.Client.LinkSecret } return err @@ -115,7 +118,8 @@ func (o *LinkOptions) Validate() (err error) { return err } - if experimental.IsExperimentalModeEnabled() { + // Wat? + if util.CheckPathExists(o.commonLinkOptions.devfilePath) { return } @@ -160,22 +164,19 @@ func NewCmdLink(name, fullName string) *cobra.Command { linkCmd.PersistentFlags().BoolVarP(&o.wait, "wait", "w", false, "If enabled the link will return only when the component is fully running after the link is created") linkCmd.PersistentFlags().BoolVar(&o.waitForTarget, "wait-for-target", false, "If enabled, the link command will wait for the service to be provisioned (has no effect when linking to a component)") - linkCmd.SetUsageTemplate(util.CmdUsageTemplate) + linkCmd.SetUsageTemplate(odoutil.CmdUsageTemplate) + + // Update the use / example / long to the Devfile description + linkCmd.Use = fmt.Sprintf("%s /", name) + linkCmd.Example = fmt.Sprintf(linkExampleExperimental, fullName) + linkCmd.Long = linkLongDescExperimental - // Modifications for the case when experimental mode is enabled - if experimental.IsExperimentalModeEnabled() { - linkCmd.Use = fmt.Sprintf("%s /", name) - linkCmd.Example = fmt.Sprintf(linkExampleExperimental, fullName) - linkCmd.Long = linkLongDescExperimental - } //Adding `--project` flag projectCmd.AddProjectFlag(linkCmd) - //Adding `--application` flag - if !experimental.IsExperimentalModeEnabled() { - appCmd.AddApplicationFlag(linkCmd) - } + //Adding `--component` flag AddComponentFlag(linkCmd) + //Adding context flag genericclioptions.AddContextFlag(linkCmd, &o.componentContext) diff --git a/pkg/odo/cli/component/list.go b/pkg/odo/cli/component/list.go index 28ad0402559..4332b87851b 100644 --- a/pkg/odo/cli/component/list.go +++ b/pkg/odo/cli/component/list.go @@ -27,7 +27,6 @@ import ( "github.com/openshift/odo/pkg/odo/genericclioptions" odoutil "github.com/openshift/odo/pkg/odo/util" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" ktemplates "k8s.io/kubectl/pkg/util/templates" ) @@ -51,7 +50,6 @@ type ListOptions struct { hasDCSupport bool hasDevfileComponents bool hasS2IComponents bool - isExperimentalMode bool devfilePath string *genericclioptions.Context } @@ -63,11 +61,10 @@ func NewListOptions() *ListOptions { // Complete completes log args func (lo *ListOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) { - lo.isExperimentalMode = experimental.IsExperimentalModeEnabled() + lo.devfilePath = filepath.Join(lo.componentContext, DevfilePath) - if lo.isExperimentalMode && util.CheckPathExists(lo.devfilePath) { - // Add a disclaimer that we are in *experimental mode* - log.Experimental("Experimental mode is enabled, use at your own risk") + + if util.CheckPathExists(lo.devfilePath) { lo.Context = genericclioptions.NewDevfileContext(cmd) lo.Client = genericclioptions.Client(cmd) @@ -113,7 +110,7 @@ func (lo *ListOptions) Validate() (err error) { klog.V(4).Infof("either --app and --all-apps both provided or provided --all-apps in a folder has app, use --all-apps anyway") } - if lo.isExperimentalMode { + if util.CheckPathExists(lo.devfilePath) { if lo.Context.Application == "" && lo.Context.KClient.Namespace == "" { return odoutil.ThrowContextError() } @@ -144,7 +141,7 @@ func (lo *ListOptions) Run() (err error) { if len(lo.pathFlag) != 0 { - if lo.isExperimentalMode && util.CheckPathExists(lo.devfilePath) { + if util.CheckPathExists(lo.devfilePath) { log.Experimental("--path flag is not supported for devfile components") } components, err := component.ListIfPathGiven(lo.Context.Client, filepath.SplitList(lo.pathFlag)) @@ -176,7 +173,7 @@ func (lo *ListOptions) Run() (err error) { // experimental workflow - if lo.isExperimentalMode && util.CheckPathExists(lo.devfilePath) { + if util.CheckPathExists(lo.devfilePath) { var deploymentList *appsv1.DeploymentList var err error diff --git a/pkg/odo/cli/component/log.go b/pkg/odo/cli/component/log.go index 57ac5c8afbc..71ac2bb05f4 100644 --- a/pkg/odo/cli/component/log.go +++ b/pkg/odo/cli/component/log.go @@ -11,7 +11,6 @@ import ( appCmd "github.com/openshift/odo/pkg/odo/cli/application" projectCmd "github.com/openshift/odo/pkg/odo/cli/project" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" ktemplates "k8s.io/kubectl/pkg/util/templates" odoutil "github.com/openshift/odo/pkg/odo/util" @@ -48,7 +47,7 @@ func (lo *LogOptions) Complete(name string, cmd *cobra.Command, args []string) ( lo.devfilePath = filepath.Join(lo.componentContext, lo.devfilePath) // if experimental mode is enabled and devfile is present - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(lo.devfilePath) { + if util.CheckPathExists(lo.devfilePath) { lo.ComponentOptions.Context = genericclioptions.NewDevfileContext(cmd) return nil } @@ -66,7 +65,7 @@ func (lo *LogOptions) Run() (err error) { stdout := os.Stdout // If experimental mode is enabled, use devfile push - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(lo.devfilePath) { + if util.CheckPathExists(lo.devfilePath) { err = lo.DevfileComponentLog() } else { // Retrieve the log diff --git a/pkg/odo/cli/component/push.go b/pkg/odo/cli/component/push.go index 8cc99399fb1..864689de7a4 100644 --- a/pkg/odo/cli/component/push.go +++ b/pkg/odo/cli/component/push.go @@ -15,7 +15,6 @@ import ( projectCmd "github.com/openshift/odo/pkg/odo/cli/project" "github.com/openshift/odo/pkg/odo/genericclioptions" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/util" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -85,7 +84,7 @@ func (po *PushOptions) Complete(name string, cmd *cobra.Command, args []string) po.CompleteDevfilePath() // if experimental mode is enabled and devfile is present - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(po.DevfilePath) { + if util.CheckPathExists(po.DevfilePath) { po.Devfile, err = devfile.ParseAndValidate(po.DevfilePath) if err != nil { @@ -176,7 +175,7 @@ func (po *PushOptions) Validate() (err error) { // If the experimental flag is set and devfile is present, then we do *not* validate // TODO: We need to clean this section up a bit.. We should also validate Devfile here // too. - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(po.DevfilePath) { + if util.CheckPathExists(po.DevfilePath) { return nil } @@ -208,7 +207,7 @@ func (po *PushOptions) Validate() (err error) { // Run has the logic to perform the required actions as part of command func (po *PushOptions) Run() (err error) { // If experimental mode is enabled, use devfile push - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(po.DevfilePath) { + if util.CheckPathExists(po.DevfilePath) { // Return Devfile push return po.DevfilePush() } @@ -224,14 +223,8 @@ func NewCmdPush(name, fullName string) *cobra.Command { annotations := map[string]string{"command": "component"} pushCmdExampleText := pushCmdExample - - if experimental.IsExperimentalModeEnabled() { - // The '-o json' option should only appear in help output when experimental mode is enabled. - annotations["machineoutput"] = "json" - - // The '-o json' example should likewise only appear in experimental only. - pushCmdExampleText += pushCmdExampleExperimentalOnly - } + annotations["machineoutput"] = "json" + pushCmdExampleText += pushCmdExampleExperimentalOnly var pushCmd = &cobra.Command{ Use: fmt.Sprintf("%s [component name]", name), @@ -252,15 +245,12 @@ func NewCmdPush(name, fullName string) *cobra.Command { pushCmd.Flags().BoolVar(&po.pushSource, "source", false, "Use source flag to only push latest source on to cluster") pushCmd.Flags().BoolVarP(&po.forceBuild, "force-build", "f", false, "Use force-build flag to force building the component") - // enable devfile flag if experimental mode is enabled - if experimental.IsExperimentalModeEnabled() { - pushCmd.Flags().StringVar(&po.namespace, "namespace", "", "Namespace to push the component to") - pushCmd.Flags().StringVar(&po.devfileInitCommand, "init-command", "", "Devfile Init Command to execute") - pushCmd.Flags().StringVar(&po.devfileBuildCommand, "build-command", "", "Devfile Build Command to execute") - pushCmd.Flags().StringVar(&po.devfileRunCommand, "run-command", "", "Devfile Run Command to execute") - pushCmd.Flags().BoolVar(&po.debugRun, "debug", false, "Runs the component in debug mode") - pushCmd.Flags().StringVar(&po.devfileDebugCommand, "debug-command", "", "Devfile Debug Command to execute") - } + pushCmd.Flags().StringVar(&po.namespace, "namespace", "", "Namespace to push the component to") + pushCmd.Flags().StringVar(&po.devfileInitCommand, "init-command", "", "Devfile Init Command to execute") + pushCmd.Flags().StringVar(&po.devfileBuildCommand, "build-command", "", "Devfile Build Command to execute") + pushCmd.Flags().StringVar(&po.devfileRunCommand, "run-command", "", "Devfile Run Command to execute") + pushCmd.Flags().BoolVar(&po.debugRun, "debug", false, "Runs the component in debug mode") + pushCmd.Flags().StringVar(&po.devfileDebugCommand, "debug-command", "", "Devfile Debug Command to execute") //Adding `--project` flag projectCmd.AddProjectFlag(pushCmd) diff --git a/pkg/odo/cli/component/update.go b/pkg/odo/cli/component/update.go index 9ec01a79b92..76c8d5a292d 100644 --- a/pkg/odo/cli/component/update.go +++ b/pkg/odo/cli/component/update.go @@ -18,7 +18,6 @@ import ( "github.com/openshift/odo/pkg/odo/genericclioptions" odoutil "github.com/openshift/odo/pkg/odo/util" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/util" ktemplates "k8s.io/kubectl/pkg/util/templates" @@ -78,10 +77,7 @@ func NewUpdateOptions() *UpdateOptions { func (uo *UpdateOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) { uo.devfilePath = filepath.Join(uo.componentContext, DevfilePath) - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(uo.devfilePath) { - // Add a disclaimer that we are in *experimental mode* - log.Experimental("Experimental mode is enabled, use at your own risk") - + if util.CheckPathExists(uo.devfilePath) { // Configure the devfile context uo.Context = genericclioptions.NewDevfileContext(cmd) return @@ -99,7 +95,7 @@ func (uo *UpdateOptions) Complete(name string, cmd *cobra.Command, args []string func (uo *UpdateOptions) Validate() (err error) { // if experimental mode is enabled and devfile is present - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(uo.devfilePath) { + if util.CheckPathExists(uo.devfilePath) { return nil } @@ -171,8 +167,8 @@ func (uo *UpdateOptions) Validate() (err error) { // Run has the logic to perform the required actions as part of command func (uo *UpdateOptions) Run() (err error) { - // if experimental mode is enabled and devfile is present - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(uo.devfilePath) { + // if devfile is present + if util.CheckPathExists(uo.devfilePath) { return errors.New(devfileErrorString) } diff --git a/pkg/odo/cli/component/watch.go b/pkg/odo/cli/component/watch.go index 4587b7345c9..3f9898461d2 100644 --- a/pkg/odo/cli/component/watch.go +++ b/pkg/odo/cli/component/watch.go @@ -15,7 +15,6 @@ import ( "github.com/openshift/odo/pkg/occlient" appCmd "github.com/openshift/odo/pkg/odo/cli/application" projectCmd "github.com/openshift/odo/pkg/odo/cli/project" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/odo/util/pushtarget" "github.com/pkg/errors" ktemplates "k8s.io/kubectl/pkg/util/templates" @@ -41,10 +40,6 @@ var watchExampleWithDevfile = ktemplates.Examples(` # Watch for changes in dire %[1]s --build-command="mybuild" --run-command="myrun" `) -var watchExample = ktemplates.Examples(` # Watch for changes in directory for current component -%[1]s - `) - // WatchOptions contains attributes of the watch command type WatchOptions struct { ignores []string @@ -82,7 +77,7 @@ func (wo *WatchOptions) Complete(name string, cmd *cobra.Command, args []string) wo.devfilePath = filepath.Join(wo.componentContext, DevfilePath) // if experimental mode is enabled and devfile is present - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(wo.devfilePath) { + if util.CheckPathExists(wo.devfilePath) { wo.Context = genericclioptions.NewDevfileContext(cmd) // Set the source path to either the context or current working directory (if context not set) @@ -161,7 +156,7 @@ func (wo *WatchOptions) Validate() (err error) { } // if experimental mode is enabled and devfile is present, return. The rest of the validation is for non-devfile components - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(wo.devfilePath) { + if util.CheckPathExists(wo.devfilePath) { exists, err := wo.initialDevfileHandler.DoesComponentExist(wo.componentName) if err != nil { return err @@ -203,7 +198,7 @@ func (wo *WatchOptions) Validate() (err error) { // Run has the logic to perform the required actions as part of command func (wo *WatchOptions) Run() (err error) { // if experimental mode is enabled and devfile is present - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(wo.devfilePath) { + if util.CheckPathExists(wo.devfilePath) { err = watch.DevfileWatchAndPush( os.Stdout, @@ -255,12 +250,10 @@ func (wo *WatchOptions) Run() (err error) { func NewCmdWatch(name, fullName string) *cobra.Command { wo := NewWatchOptions() - example := fmt.Sprintf(watchExample, fullName) usage := name - if experimental.IsExperimentalModeEnabled() { - example = fmt.Sprintf(watchExampleWithDevfile, fullName) - } + // Add information on Devfile + example := fmt.Sprintf(watchExampleWithDevfile, fullName) var watchCmd = &cobra.Command{ Use: usage, @@ -280,12 +273,9 @@ func NewCmdWatch(name, fullName string) *cobra.Command { watchCmd.SetUsageTemplate(odoutil.CmdUsageTemplate) - // enable devfile flag if experimental mode is enabled - if experimental.IsExperimentalModeEnabled() { - watchCmd.Flags().StringVar(&wo.devfileInitCommand, "init-command", "", "Devfile Init Command to execute") - watchCmd.Flags().StringVar(&wo.devfileBuildCommand, "build-command", "", "Devfile Build Command to execute") - watchCmd.Flags().StringVar(&wo.devfileRunCommand, "run-command", "", "Devfile Run Command to execute") - } + watchCmd.Flags().StringVar(&wo.devfileInitCommand, "init-command", "", "Devfile Init Command to execute") + watchCmd.Flags().StringVar(&wo.devfileBuildCommand, "build-command", "", "Devfile Build Command to execute") + watchCmd.Flags().StringVar(&wo.devfileRunCommand, "run-command", "", "Devfile Run Command to execute") // Adding context flag genericclioptions.AddContextFlag(watchCmd, &wo.componentContext) diff --git a/pkg/odo/cli/debug/info.go b/pkg/odo/cli/debug/info.go index b9fc2427c33..fcd75c163f2 100644 --- a/pkg/odo/cli/debug/info.go +++ b/pkg/odo/cli/debug/info.go @@ -8,7 +8,6 @@ import ( "github.com/openshift/odo/pkg/log" "github.com/openshift/odo/pkg/machineoutput" "github.com/openshift/odo/pkg/odo/genericclioptions" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/util" "github.com/spf13/cobra" k8sgenclioptions "k8s.io/cli-runtime/pkg/genericclioptions" @@ -47,7 +46,7 @@ func NewInfoOptions() *InfoOptions { // Complete completes all the required options for port-forward cmd. func (o *InfoOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) { - if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(filepath.Join(o.contextDir, devfile)) { + if util.CheckPathExists(filepath.Join(o.contextDir, devfile)) { o.Context = genericclioptions.NewDevfileContext(cmd) // a small shortcut diff --git a/pkg/odo/cli/debug/portforward.go b/pkg/odo/cli/debug/portforward.go index 1bb5248c041..28a33d8681b 100644 --- a/pkg/odo/cli/debug/portforward.go +++ b/pkg/odo/cli/debug/portforward.go @@ -12,8 +12,8 @@ import ( "github.com/openshift/odo/pkg/config" "github.com/openshift/odo/pkg/debug" "github.com/openshift/odo/pkg/log" + "github.com/openshift/odo/pkg/odo/cli/component" "github.com/openshift/odo/pkg/odo/genericclioptions" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/util" "github.com/spf13/cobra" @@ -39,9 +39,9 @@ type PortForwardOptions struct { StopChannel chan struct{} // ReadChannel is used to receive status of port forwarding ( ready or not ready ) ReadyChannel chan struct{} - *genericclioptions.Context - isExperimental bool + *genericclioptions.Context + devfilePath string } var ( @@ -72,12 +72,11 @@ func NewPortForwardOptions() *PortForwardOptions { // Complete completes all the required options for port-forward cmd. func (o *PortForwardOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) { + o.devfilePath = filepath.Join(o.contextDir, component.DevfilePath) var remotePort int - o.isExperimental = experimental.IsExperimentalModeEnabled() - - if o.isExperimental && util.CheckPathExists(filepath.Join(o.contextDir, devfile)) { + if util.CheckPathExists(o.devfilePath) { o.Context = genericclioptions.NewDevfileContext(cmd) // a small shortcut @@ -166,7 +165,7 @@ func (o PortForwardOptions) Run() error { return err } - return o.PortForwarder.ForwardPorts(o.PortPair, o.StopChannel, o.ReadyChannel, o.isExperimental) + return o.PortForwarder.ForwardPorts(o.PortPair, o.StopChannel, o.ReadyChannel, util.CheckPathExists(o.devfilePath)) } // NewCmdPortForward implements the port-forward odo command @@ -182,6 +181,7 @@ func NewCmdPortForward(name, fullName string) *cobra.Command { genericclioptions.GenericRun(opts, cmd, args) }, } + genericclioptions.AddContextFlag(cmd, &opts.contextDir) cmd.Flags().IntVarP(&opts.localPort, "local-port", "l", config.DefaultDebugPort, "Set the local port") diff --git a/pkg/odo/cli/service/create.go b/pkg/odo/cli/service/create.go index de967f532c1..77cf639c9d6 100644 --- a/pkg/odo/cli/service/create.go +++ b/pkg/odo/cli/service/create.go @@ -6,17 +6,19 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "strings" "text/template" "github.com/openshift/odo/pkg/log" + "github.com/openshift/odo/pkg/odo/cli/component" "github.com/openshift/odo/pkg/odo/cli/service/ui" commonui "github.com/openshift/odo/pkg/odo/cli/ui" "github.com/openshift/odo/pkg/odo/genericclioptions" "github.com/openshift/odo/pkg/odo/util/completion" - "github.com/openshift/odo/pkg/odo/util/experimental" "github.com/openshift/odo/pkg/odo/util/validation" svc "github.com/openshift/odo/pkg/service" + "github.com/openshift/odo/pkg/util" "github.com/ghodss/yaml" "github.com/pkg/errors" @@ -107,6 +109,9 @@ type ServiceCreateOptions struct { // Location of the file in which yaml specification of CR is stored. // TODO: remove this after service create's interactive mode supports creating operator backed services fromFile string + + // Devfile + devfilePath string } // NewServiceCreateOptions creates a new ServiceCreateOptions instance @@ -128,11 +133,13 @@ func NewDynamicCRD() *DynamicCRD { // Complete completes ServiceCreateOptions after they've been created func (o *ServiceCreateOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) { + o.devfilePath = filepath.Join(o.componentContext, component.DevfilePath) + if len(args) == 0 || !cmd.HasFlags() { o.interactive = true } - if experimental.IsExperimentalModeEnabled() { + if util.CheckPathExists(o.devfilePath) { o.Context = genericclioptions.NewDevfileContext(cmd) } else if o.componentContext != "" { o.Context = genericclioptions.NewContext(cmd) @@ -144,8 +151,7 @@ func (o *ServiceCreateOptions) Complete(name string, cmd *cobra.Command, args [] var class scv1beta1.ClusterServiceClass - if experimental.IsExperimentalModeEnabled() { - // we don't support interactive mode for Operator Hub yet + if util.CheckPathExists(o.devfilePath) { o.interactive = false // if user has just used "odo service create", simply return @@ -198,18 +204,19 @@ func (o *ServiceCreateOptions) Complete(name string, cmd *cobra.Command, args [] o.outputCLI = commonui.Proceed("Output the non-interactive version of the selected options") o.wait = commonui.Proceed("Wait for the service to be ready") } else { - if experimental.IsExperimentalModeEnabled() { - // split the name provided on CLI and populate servicetype & customresource + // split the name provided on CLI and populate servicetype & customresource + if util.CheckPathExists(o.devfilePath) { o.ServiceType, o.CustomResource, err = svc.SplitServiceKindName(args[0]) if err != nil { return fmt.Errorf("invalid service name, use the format /") } + } else { o.ServiceType = args[0] } // if only one arg is given, then it is considered as service name and service type both // ONLY if not running in Experimental mode - if !experimental.IsExperimentalModeEnabled() { + if !util.CheckPathExists(o.devfilePath) { // This is because an operator with name // "etcdoperator.v0.9.4-clusterwide" would lead to creation of a // serice with name like @@ -277,7 +284,7 @@ func (o *ServiceCreateOptions) Validate() (err error) { } // we want to find an Operator only if something's passed to the crd flag on CLI - if experimental.IsExperimentalModeEnabled() { + if util.CheckPathExists(o.devfilePath) { d := NewDynamicCRD() // if the user wants to create service from a file, we check for // existence of file and validate if the requested operator and CR @@ -430,7 +437,7 @@ func (o *ServiceCreateOptions) Validate() (err error) { // Run contains the logic for the odo service create command func (o *ServiceCreateOptions) Run() (err error) { s := &log.Status{} - if experimental.IsExperimentalModeEnabled() { + if util.CheckPathExists(o.devfilePath) { // in case of an opertor backed service, name of the service is // provided by the yaml specification in alm-examples. It might also // happen that a user spins up Service Catalog based service in @@ -445,7 +452,7 @@ func (o *ServiceCreateOptions) Run() (err error) { log.Infof("Deploying service %s of type: %s", o.ServiceName, o.ServiceType) } - if experimental.IsExperimentalModeEnabled() && o.CustomResource != "" { + if util.CheckPathExists(o.devfilePath) && o.CustomResource != "" { // if experimental mode is enabled and o.CustomResource is not empty, we're expected to create an Operator backed service if o.DryRun { // if it's dry run, only print the alm-example (o.CustomResourceDefinition) and exit @@ -512,15 +519,13 @@ func NewCmdServiceCreate(name, fullName string) *cobra.Command { }, } - if experimental.IsExperimentalModeEnabled() { - serviceCreateCmd.Use += fmt.Sprintf(" [flags]\n %s / [service_name] [flags]", o.CmdFullName) - serviceCreateCmd.Short = createShortDescExperimental - serviceCreateCmd.Long = createLongDescExperimental - 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") - } + serviceCreateCmd.Use += fmt.Sprintf(" [flags]\n %s / [service_name] [flags]", o.CmdFullName) + serviceCreateCmd.Short = createShortDescExperimental + serviceCreateCmd.Long = createLongDescExperimental + 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") serviceCreateCmd.Flags().StringVar(&o.Plan, "plan", "", "The name of the plan of the service to be created") serviceCreateCmd.Flags().StringArrayVarP(&o.parameters, "parameters", "p", []string{}, "Parameters of the plan where a parameter is expressed as = 0 { output = output[:len(output)-1] diff --git a/pkg/url/url.go b/pkg/url/url.go index 726a4ef0391..96827f6206a 100644 --- a/pkg/url/url.go +++ b/pkg/url/url.go @@ -245,7 +245,7 @@ type CreateParameters struct { // Create creates a URL and returns url string and error if any // portNumber is the target port number for the route and is -1 in case no port number is specified in which case it is automatically detected for components which expose only one service port) -func Create(client *occlient.Client, kClient *kclient.Client, parameters CreateParameters, isRouteSupported bool, isExperimental bool) (string, error) { +func Create(client *occlient.Client, kClient *kclient.Client, parameters CreateParameters, isRouteSupported bool, isS2I bool) (string, error) { if parameters.urlKind != envinfo.INGRESS && parameters.urlKind != envinfo.ROUTE { return "", fmt.Errorf("urlKind %s is not supported for URL creation", parameters.urlKind) @@ -259,7 +259,7 @@ func Create(client *occlient.Client, kClient *kclient.Client, parameters CreateP serviceName := "" - if isExperimental && parameters.urlKind == envinfo.INGRESS && kClient != nil { + if !isS2I && parameters.urlKind == envinfo.INGRESS && kClient != nil { if parameters.host == "" { return "", errors.Errorf("the host cannot be empty") } @@ -322,14 +322,14 @@ func Create(client *occlient.Client, kClient *kclient.Client, parameters CreateP if err != nil { return "", errors.Wrap(err, "unable to create ingress") } - return GetURLString(GetProtocol(routev1.Route{}, *ingress), "", ingressDomain, isExperimental), nil + return GetURLString(GetProtocol(routev1.Route{}, *ingress), "", ingressDomain, false), nil } else { if !isRouteSupported { return "", errors.Errorf("routes are not available on non OpenShift clusters") } var ownerReference metav1.OwnerReference - if !isExperimental || kClient == nil { + if isS2I || kClient == nil { var err error parameters.urlName, err = util.NamespaceOpenShiftObject(parameters.urlName, parameters.applicationName) if err != nil { @@ -366,7 +366,7 @@ func Create(client *occlient.Client, kClient *kclient.Client, parameters CreateP if err != nil { return "", errors.Wrap(err, "unable to create route") } - return GetURLString(GetProtocol(*route, iextensionsv1.Ingress{}), route.Spec.Host, "", isExperimental), nil + return GetURLString(GetProtocol(*route, iextensionsv1.Ingress{}), route.Spec.Host, "", true), nil } } @@ -691,8 +691,8 @@ func ConvertEnvinfoURL(envinfoURL envinfo.EnvInfoURL, serviceName string) URL { } // GetURLString returns a string representation of given url -func GetURLString(protocol, URL string, ingressDomain string, isExperimentalMode bool) string { - if isExperimentalMode && URL == "" { +func GetURLString(protocol, URL string, ingressDomain string, isS2I bool) string { + if !isS2I && URL == "" { return protocol + "://" + ingressDomain } return protocol + "://" + URL @@ -869,13 +869,13 @@ func getMachineReadableFormatDocker(internalPort int, externalPort int, hostIP s } type PushParameters struct { - ComponentName string - ApplicationName string - ConfigURLs []config.ConfigURL - EnvURLS []envinfo.EnvInfoURL - IsRouteSupported bool - IsExperimentalModeEnabled bool - EndpointMap map[int32]parsercommon.Endpoint + ComponentName string + ApplicationName string + ConfigURLs []config.ConfigURL + EnvURLS []envinfo.EnvInfoURL + IsRouteSupported bool + EndpointMap map[int32]parsercommon.Endpoint + IsS2I bool } // Push creates and deletes the required URLs @@ -884,7 +884,7 @@ func Push(client *occlient.Client, kClient *kclient.Client, parameters PushParam // in case the component is a s2i one // kClient will be nil - if parameters.IsExperimentalModeEnabled && kClient != nil { + if !parameters.IsS2I && kClient != nil { urls := parameters.EnvURLS for _, url := range urls { if url.Kind != envinfo.DOCKER { @@ -934,7 +934,7 @@ func Push(client *occlient.Client, kClient *kclient.Client, parameters PushParam // iterate through endpoints defined in devfile // add the url defination into urlLOCAL if it's not defined in env.yaml - if parameters.IsExperimentalModeEnabled && parameters.EndpointMap != nil { + if !parameters.IsS2I && parameters.EndpointMap != nil { for port, endpoint := range parameters.EndpointMap { // should not create URL if Exposure is none or internal if endpoint.Exposure == "none" || endpoint.Exposure == "internal" { @@ -976,7 +976,7 @@ func Push(client *occlient.Client, kClient *kclient.Client, parameters PushParam } urlCLUSTER := make(map[string]URL) - if parameters.IsExperimentalModeEnabled && kClient != nil { + if !parameters.IsS2I && kClient != nil { urlList, err := ListPushedIngress(kClient, parameters.ComponentName) if err != nil { return err @@ -1036,7 +1036,7 @@ func Push(client *occlient.Client, kClient *kclient.Client, parameters PushParam } // delete the url deleteURLName := urlName - if parameters.IsExperimentalModeEnabled && kClient != nil { + if !parameters.IsS2I && kClient != nil { // route/ingress name is defined as - // to avoid error due to duplicate ingress name defined in different devfile components deleteURLName = fmt.Sprintf("%s-%s", urlName, parameters.ComponentName) @@ -1070,8 +1070,7 @@ func Push(client *occlient.Client, kClient *kclient.Client, parameters PushParam urlKind: urlInfo.Spec.Kind, path: urlInfo.Spec.Path, } - - host, err := Create(client, kClient, createParameters, parameters.IsRouteSupported, parameters.IsExperimentalModeEnabled) + host, err := Create(client, kClient, createParameters, parameters.IsRouteSupported, parameters.IsS2I) if err != nil { return err } diff --git a/pkg/url/url_test.go b/pkg/url/url_test.go index 175a2070814..78359381cf9 100644 --- a/pkg/url/url_test.go +++ b/pkg/url/url_test.go @@ -37,16 +37,16 @@ import ( func TestCreate(t *testing.T) { type args struct { - componentName string - applicationName string - urlName string - portNumber int - secure bool - host string - urlKind envinfo.URLKind - isRouteSupported bool - isExperimentalModeEnabled bool - tlsSecret string + componentName string + applicationName string + urlName string + portNumber int + secure bool + host string + urlKind envinfo.URLKind + isRouteSupported bool + isS2I bool + tlsSecret string } tests := []struct { name string @@ -66,6 +66,7 @@ func TestCreate(t *testing.T) { urlName: "nodejs", portNumber: 8080, isRouteSupported: true, + isS2I: true, urlKind: envinfo.ROUTE, }, returnedRoute: &routev1.Route{ @@ -101,6 +102,7 @@ func TestCreate(t *testing.T) { urlName: "example-url", portNumber: 9100, isRouteSupported: true, + isS2I: true, urlKind: envinfo.ROUTE, }, returnedRoute: &routev1.Route{ @@ -137,6 +139,7 @@ func TestCreate(t *testing.T) { portNumber: 9100, secure: true, isRouteSupported: true, + isS2I: true, urlKind: envinfo.ROUTE, }, returnedRoute: &routev1.Route{ @@ -172,13 +175,12 @@ func TestCreate(t *testing.T) { { name: "Case 4: Create a ingress, with same name as component,instead of route on openshift cluster", args: args{ - componentName: "nodejs", - urlName: "nodejs", - portNumber: 8080, - host: "com", - isRouteSupported: true, - isExperimentalModeEnabled: true, - urlKind: envinfo.INGRESS, + componentName: "nodejs", + urlName: "nodejs", + portNumber: 8080, + host: "com", + isRouteSupported: true, + urlKind: envinfo.INGRESS, }, returnedIngress: fake.GetSingleIngress("nodejs-nodejs", "nodejs"), want: "http://nodejs.com", @@ -187,13 +189,12 @@ func TestCreate(t *testing.T) { { name: "Case 5: Create a ingress, with different name as component,instead of route on openshift cluster", args: args{ - componentName: "nodejs", - urlName: "example", - portNumber: 8080, - host: "com", - isRouteSupported: true, - isExperimentalModeEnabled: true, - urlKind: envinfo.INGRESS, + componentName: "nodejs", + urlName: "example", + portNumber: 8080, + host: "com", + isRouteSupported: true, + urlKind: envinfo.INGRESS, }, returnedRoute: &routev1.Route{ ObjectMeta: metav1.ObjectMeta{ @@ -224,14 +225,13 @@ func TestCreate(t *testing.T) { { name: "Case 6: Create a secure ingress, instead of route on openshift cluster, default tls exists", args: args{ - componentName: "nodejs", - urlName: "example", - portNumber: 8080, - host: "com", - isRouteSupported: true, - isExperimentalModeEnabled: true, - secure: true, - urlKind: envinfo.INGRESS, + componentName: "nodejs", + urlName: "example", + portNumber: 8080, + host: "com", + isRouteSupported: true, + secure: true, + urlKind: envinfo.INGRESS, }, returnedIngress: fake.GetSingleIngress("example-nodejs", "nodejs"), defaultTLSExists: true, @@ -241,14 +241,13 @@ func TestCreate(t *testing.T) { { name: "Case 7: Create a secure ingress, instead of route on openshift cluster and default tls doesn't exist", args: args{ - componentName: "nodejs", - urlName: "example", - portNumber: 8080, - host: "com", - isRouteSupported: true, - isExperimentalModeEnabled: true, - secure: true, - urlKind: envinfo.INGRESS, + componentName: "nodejs", + urlName: "example", + portNumber: 8080, + host: "com", + isRouteSupported: true, + secure: true, + urlKind: envinfo.INGRESS, }, returnedIngress: fake.GetSingleIngress("example-nodejs", "nodejs"), defaultTLSExists: false, @@ -258,15 +257,14 @@ func TestCreate(t *testing.T) { { name: "Case 8: Fail when while creating ingress when user given tls secret doesn't exists", args: args{ - componentName: "nodejs", - urlName: "example", - portNumber: 8080, - host: "com", - isRouteSupported: true, - isExperimentalModeEnabled: true, - secure: true, - tlsSecret: "user-secret", - urlKind: envinfo.INGRESS, + componentName: "nodejs", + urlName: "example", + portNumber: 8080, + host: "com", + isRouteSupported: true, + secure: true, + tlsSecret: "user-secret", + urlKind: envinfo.INGRESS, }, returnedIngress: fake.GetSingleIngress("example", "nodejs"), defaultTLSExists: false, @@ -277,15 +275,14 @@ func TestCreate(t *testing.T) { { name: "Case 9: Create a secure ingress, instead of route on openshift cluster, user tls secret does exists", args: args{ - componentName: "nodejs", - urlName: "example", - portNumber: 8080, - host: "com", - isRouteSupported: true, - isExperimentalModeEnabled: true, - secure: true, - tlsSecret: "user-secret", - urlKind: envinfo.INGRESS, + componentName: "nodejs", + urlName: "example", + portNumber: 8080, + host: "com", + isRouteSupported: true, + secure: true, + tlsSecret: "user-secret", + urlKind: envinfo.INGRESS, }, returnedIngress: fake.GetSingleIngress("example-nodejs", "nodejs"), defaultTLSExists: false, @@ -297,15 +294,14 @@ func TestCreate(t *testing.T) { { name: "Case 10: invalid url kind", args: args{ - componentName: "nodejs", - urlName: "example", - portNumber: 8080, - host: "com", - isRouteSupported: true, - isExperimentalModeEnabled: true, - secure: true, - tlsSecret: "user-secret", - urlKind: "blah", + componentName: "nodejs", + urlName: "example", + portNumber: 8080, + host: "com", + isRouteSupported: true, + secure: true, + tlsSecret: "user-secret", + urlKind: "blah", }, returnedIngress: fake.GetSingleIngress("example-nodejs", "nodejs"), defaultTLSExists: false, @@ -316,12 +312,11 @@ func TestCreate(t *testing.T) { { name: "Case 11: route is not supported on the cluster", args: args{ - componentName: "nodejs", - applicationName: "app", - urlName: "example", - isRouteSupported: false, - isExperimentalModeEnabled: true, - urlKind: envinfo.ROUTE, + componentName: "nodejs", + applicationName: "app", + urlName: "example", + isRouteSupported: false, + urlKind: envinfo.ROUTE, }, returnedIngress: fake.GetSingleIngress("example", "nodejs"), defaultTLSExists: false, @@ -332,13 +327,12 @@ func TestCreate(t *testing.T) { { name: "Case 11: secretName used without secure flag", args: args{ - componentName: "nodejs", - applicationName: "app", - urlName: "example", - isRouteSupported: false, - isExperimentalModeEnabled: true, - tlsSecret: "secret", - urlKind: envinfo.ROUTE, + componentName: "nodejs", + applicationName: "app", + urlName: "example", + isRouteSupported: false, + tlsSecret: "secret", + urlKind: envinfo.ROUTE, }, returnedIngress: fake.GetSingleIngress("example", "nodejs"), defaultTLSExists: false, @@ -414,7 +408,7 @@ func TestCreate(t *testing.T) { urlKind: tt.args.urlKind, } - got, err := Create(client, fakeKClient, urlCreateParameters, tt.args.isRouteSupported, tt.args.isExperimentalModeEnabled) + got, err := Create(client, fakeKClient, urlCreateParameters, tt.args.isRouteSupported, tt.args.isS2I) if err == nil && !tt.wantErr { if tt.args.urlKind == envinfo.INGRESS { @@ -743,8 +737,8 @@ func TestGetValidPortNumber(t *testing.T) { func TestPush(t *testing.T) { type args struct { - isRouteSupported bool - isExperimentalModeEnabled bool + isRouteSupported bool + isS2I bool } tests := []struct { name string @@ -764,6 +758,7 @@ func TestPush(t *testing.T) { name: "no urls on local config and cluster", args: args{ isRouteSupported: true, + isS2I: true, }, componentName: "nodejs", applicationName: "app", @@ -773,7 +768,10 @@ func TestPush(t *testing.T) { name: "2 urls on local config and 0 on openshift cluster", componentName: "nodejs", applicationName: "app", - args: args{isRouteSupported: true}, + args: args{ + isRouteSupported: true, + isS2I: true, + }, existingConfigURLs: []config.ConfigURL{ { Name: "example", @@ -814,7 +812,7 @@ func TestPush(t *testing.T) { name: "0 url on local config and 2 on openshift cluster", componentName: "wildfly", applicationName: "app", - args: args{isRouteSupported: true}, + args: args{isRouteSupported: true, isS2I: true}, returnedRoutes: testingutil.GetRouteListWithMultiple("wildfly", "app"), deletedURLs: []URL{ getMachineReadableFormat(testingutil.GetSingleRoute("example-app", 8080, "nodejs", "app")), @@ -825,7 +823,7 @@ func TestPush(t *testing.T) { name: "2 url on local config and 2 on openshift cluster, but they are different", componentName: "nodejs", applicationName: "app", - args: args{isRouteSupported: true}, + args: args{isRouteSupported: true, isS2I: true}, existingConfigURLs: []config.ConfigURL{ { Name: "example-local-0", @@ -870,7 +868,7 @@ func TestPush(t *testing.T) { name: "2 url on local config and openshift cluster are in sync", componentName: "nodejs", applicationName: "app", - args: args{isRouteSupported: true}, + args: args{isRouteSupported: true, isS2I: true}, existingConfigURLs: []config.ConfigURL{ { Name: "example", @@ -891,7 +889,7 @@ func TestPush(t *testing.T) { { name: "0 urls on env file and cluster", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{}, returnedRoutes: &routev1.RouteList{}, returnedIngress: &extensionsv1.IngressList{}, @@ -899,7 +897,7 @@ func TestPush(t *testing.T) { { name: "2 urls on env file and 0 on openshift cluster", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -956,7 +954,7 @@ func TestPush(t *testing.T) { { name: "0 urls on env file and 2 on openshift cluster", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{}, returnedRoutes: &routev1.RouteList{}, returnedIngress: fake.GetIngressListWithMultiple("nodejs"), @@ -976,7 +974,7 @@ func TestPush(t *testing.T) { { name: "2 urls on env file and 2 on openshift cluster, but they are different", componentName: "wildfly", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example-local-0", @@ -1045,7 +1043,7 @@ func TestPush(t *testing.T) { { name: "2 urls on env file and openshift cluster are in sync", componentName: "wildfly", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example-0", @@ -1070,7 +1068,7 @@ func TestPush(t *testing.T) { { name: "2 (1 ingress,1 route) urls on env file and 2 on openshift cluster (1 ingress,1 route), but they are different", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example-local-0", @@ -1137,7 +1135,7 @@ func TestPush(t *testing.T) { { name: "create a ingress on a kubernetes cluster", componentName: "nodejs", - args: args{isRouteSupported: false, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: false}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1175,7 +1173,9 @@ func TestPush(t *testing.T) { { name: "url with same name exists on env and cluster but with different specs", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{ + isRouteSupported: true, + }, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example-local-0", @@ -1221,7 +1221,7 @@ func TestPush(t *testing.T) { name: "url with same name exists on config and cluster but with different specs", componentName: "nodejs", applicationName: "app", - args: args{isRouteSupported: true, isExperimentalModeEnabled: false}, + args: args{isRouteSupported: true, isS2I: true}, existingConfigURLs: []config.ConfigURL{ { Name: "example-local-0", @@ -1260,7 +1260,7 @@ func TestPush(t *testing.T) { { name: "create a secure route url", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1293,7 +1293,7 @@ func TestPush(t *testing.T) { { name: "create a secure ingress url with empty user given tls secret", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1328,7 +1328,7 @@ func TestPush(t *testing.T) { { name: "create a secure ingress url with user given tls secret", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1365,7 +1365,7 @@ func TestPush(t *testing.T) { { name: "env ingress port does not match endpoint defined in devfile", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1386,7 +1386,7 @@ func TestPush(t *testing.T) { { name: "env route port does not match endpoint defined in devfile", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1406,7 +1406,7 @@ func TestPush(t *testing.T) { { name: "no endpoint defined in devfile", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1421,7 +1421,7 @@ func TestPush(t *testing.T) { { name: "env has ingress defined with same port, but endpoint port defined in devfile is internally exposed", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1443,7 +1443,7 @@ func TestPush(t *testing.T) { { name: "env has ingress defined with same port, endpoint port defined in devfile is not exposed", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1465,7 +1465,7 @@ func TestPush(t *testing.T) { { name: "env has route defined with same port, but endpoint port defined in devfile is internally exposed", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1486,7 +1486,7 @@ func TestPush(t *testing.T) { { name: "env has route defined with same port, but endpoint port defined in devfile is internally exposed", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1507,7 +1507,7 @@ func TestPush(t *testing.T) { { name: "env has route defined with same port, but endpoint port defined in devfile is not exposed", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1528,7 +1528,7 @@ func TestPush(t *testing.T) { { name: "no host defined for ingress should not create any URL", componentName: "nodejs", - args: args{isRouteSupported: false, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: false}, existingEnvInfoURLs: []envinfo.EnvInfoURL{}, endpintMap: map[int32]versionsCommon.Endpoint{ 8080: versionsCommon.Endpoint{ @@ -1545,7 +1545,7 @@ func TestPush(t *testing.T) { { name: "should create route in openshift cluster if endpoint is defined in devfile", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{}, endpintMap: map[int32]versionsCommon.Endpoint{ 8080: versionsCommon.Endpoint{ @@ -1574,7 +1574,7 @@ func TestPush(t *testing.T) { { name: "should create ingress if endpoint is defined in devfile", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1611,7 +1611,7 @@ func TestPush(t *testing.T) { { name: "should create route in openshift cluster with path defined in devfile", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{}, endpintMap: map[int32]versionsCommon.Endpoint{ 8080: versionsCommon.Endpoint{ @@ -1641,7 +1641,7 @@ func TestPush(t *testing.T) { { name: "should create ingress with path defined in devfile", componentName: "nodejs", - args: args{isRouteSupported: true, isExperimentalModeEnabled: true}, + args: args{isRouteSupported: true}, existingEnvInfoURLs: []envinfo.EnvInfoURL{ { Name: "example", @@ -1715,13 +1715,13 @@ func TestPush(t *testing.T) { }) if err := Push(fakeClient, fakeKClient, PushParameters{ - ComponentName: tt.componentName, - ApplicationName: tt.applicationName, - ConfigURLs: tt.existingConfigURLs, - EnvURLS: tt.existingEnvInfoURLs, - IsRouteSupported: tt.args.isRouteSupported, - IsExperimentalModeEnabled: tt.args.isExperimentalModeEnabled, - EndpointMap: tt.endpintMap, + ComponentName: tt.componentName, + ApplicationName: tt.applicationName, + ConfigURLs: tt.existingConfigURLs, + EnvURLS: tt.existingEnvInfoURLs, + IsRouteSupported: tt.args.isRouteSupported, + EndpointMap: tt.endpintMap, + IsS2I: tt.args.isS2I, }); (err != nil) != tt.wantErr { t.Errorf("Push() error = %v, wantErr %v", err, tt.wantErr) } else { diff --git a/pkg/version/version.go b/pkg/version/version.go index 1b8ad14a9c4..ea0ffc177f2 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -12,7 +12,7 @@ Changing these values will change the versioning information when releasing odo. var ( // VERSION is version number that will be displayed when running ./odo version - VERSION = "v1.2.6" + VERSION = "v2.0.0" // GITCOMMIT is hash of the commit that will be displayed when running ./odo version // this will be overwritten when running build like this: go build -ldflags="-X github.com/openshift/odo/cmd.GITCOMMIT=$(GITCOMMIT)" diff --git a/tests/e2escenarios/e2e_beta_test.go b/tests/e2escenarios/e2e_beta_test.go index 403a2150098..e411d0a638e 100644 --- a/tests/e2escenarios/e2e_beta_test.go +++ b/tests/e2escenarios/e2e_beta_test.go @@ -46,7 +46,7 @@ var _ = Describe("odo core beta flow", func() { // abstract main test to the function, to allow running the same test in a different context (slightly different arguments) TestBasicCreateConfigPush := func(extraArgs ...string) { - createSession := helper.CmdShouldPass(odo, append([]string{"component", "create", "java:8", "mycomponent", "--app", "myapp", "--project", project}, extraArgs...)...) + createSession := helper.CmdShouldPass(odo, append([]string{"component", "create", "--s2i", "java:8", "mycomponent", "--app", "myapp", "--project", project}, extraArgs...)...) // output of the commands should point user to running "odo push" Expect(createSession).Should(ContainSubstring("odo push")) configFile := filepath.Join(context, ".odo", "config.yaml") @@ -106,8 +106,8 @@ var _ = Describe("odo core beta flow", func() { }) It("'odo component' should fail if there already is .odo dir", func() { - helper.CmdShouldPass("odo", "component", "create", "nodejs", "--project", project) - helper.CmdShouldFail("odo", "component", "create", "nodejs", "--project", project) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", "--project", project) + helper.CmdShouldFail("odo", "component", "create", "--s2i", "nodejs", "--project", project) }) It("'odo config' should fail if there is no .odo dir", func() { @@ -123,8 +123,8 @@ var _ = Describe("odo core beta flow", func() { Context("when --context flag is used", func() { It("odo component should fail if there already is .odo dir", func() { - helper.CmdShouldPass("odo", "component", "create", "nodejs", "--context", context, "--project", project) - helper.CmdShouldFail("odo", "component", "create", "nodejs", "--context", context, "--project", project) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", "--context", context, "--project", project) + helper.CmdShouldFail("odo", "component", "create", "--s2i", "nodejs", "--context", context, "--project", project) }) It("odo config should fail if there is no .odo dir", func() { diff --git a/tests/e2escenarios/e2e_java_test.go b/tests/e2escenarios/e2e_java_test.go index f5c450151ab..ab2ad544a7a 100644 --- a/tests/e2escenarios/e2e_java_test.go +++ b/tests/e2escenarios/e2e_java_test.go @@ -47,7 +47,7 @@ var _ = Describe("odo java e2e tests", func() { }) It("Should be able to deploy a git repo that contains a wildfly application without wait flag", func() { - helper.CmdShouldPass("odo", "create", "wildfly", "wo-wait-javaee-git-test", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "wildfly", "wo-wait-javaee-git-test", "--project", project, "--ref", "master", "--git", warGitRepo, "--context", context) // Create a URL @@ -66,7 +66,7 @@ var _ = Describe("odo java e2e tests", func() { Context("odo component creation", func() { It("Should be able to deploy a .war file using wildfly", func() { helper.CopyExample(filepath.Join("binary", "java", "wildfly"), context) - helper.CmdShouldPass("odo", "create", "wildfly", "javaee-war-test", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "wildfly", "javaee-war-test", "--project", project, "--binary", filepath.Join(context, "ROOT.war"), "--context", context) // Create a URL @@ -85,7 +85,7 @@ var _ = Describe("odo java e2e tests", func() { oc.ImportJavaIS(project) // Deploy the git repo / wildfly example - helper.CmdShouldPass("odo", "create", "java:8", "uberjar-git-test", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "java:8", "uberjar-git-test", "--project", project, "--ref", "master", "--git", jarGitRepo, "--context", context) // Create a URL @@ -104,7 +104,7 @@ var _ = Describe("odo java e2e tests", func() { oc.ImportJavaIS(project) helper.CopyExample(filepath.Join("binary", "java", "openjdk"), context) - helper.CmdShouldPass("odo", "create", "java:8", "sb-jar-test", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "java:8", "sb-jar-test", "--project", project, "--binary", filepath.Join(context, "sb.jar"), "--context", context) // Create a URL diff --git a/tests/e2escenarios/e2e_source_test.go b/tests/e2escenarios/e2e_source_test.go index e2a89f03996..a89bb7c71b4 100644 --- a/tests/e2escenarios/e2e_source_test.go +++ b/tests/e2escenarios/e2e_source_test.go @@ -39,7 +39,7 @@ var _ = Describe("odo source e2e tests", func() { It("Should be able to deploy a wildfly source application", func() { helper.CopyExample(filepath.Join("source", "wildfly"), context) - helper.CmdShouldPass("odo", "create", "wildfly", "wildfly-app", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "wildfly", "wildfly-app", "--project", project, "--context", context) // Push changes @@ -62,7 +62,7 @@ var _ = Describe("odo source e2e tests", func() { It("Should be able to deploy a dotnet source application", func() { oc.ImportDotnet20IS(project) helper.CopyExample(filepath.Join("source", "dotnet"), context) - helper.CmdShouldPass("odo", "create", "dotnet:2.0", "dotnet-app", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "dotnet:2.0", "dotnet-app", "--project", project, "--context", context) // Push changes @@ -87,7 +87,7 @@ var _ = Describe("odo source e2e tests", func() { It("Should be able to deploy a python source application", func() { helper.CopyExample(filepath.Join("source", "python"), context) - helper.CmdShouldPass("odo", "create", "python", "python-app", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "python", "python-app", "--project", project, "--context", context) // Push changes @@ -110,7 +110,7 @@ var _ = Describe("odo source e2e tests", func() { It("Should be able to deploy an openjdk source application", func() { oc.ImportJavaIS(project) helper.CopyExample(filepath.Join("source", "openjdk"), context) - helper.CmdShouldPass("odo", "create", "java:8", "openjdk-app", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "java:8", "openjdk-app", "--project", project, "--context", context) // Push changes @@ -132,7 +132,7 @@ var _ = Describe("odo source e2e tests", func() { It("Should be able to deploy a nodejs source application", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs-app", "--project", + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs-app", "--project", project, "--context", context) // Push changes diff --git a/tests/integration/cmd_app_test.go b/tests/integration/cmd_app_test.go index 9e39a81734f..8bc5083f94b 100644 --- a/tests/integration/cmd_app_test.go +++ b/tests/integration/cmd_app_test.go @@ -69,7 +69,7 @@ var _ = Describe("odo app command tests", func() { It("should successfully execute list, describe and delete along with machine readable output", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) // changing directory to the context directory @@ -93,7 +93,7 @@ var _ = Describe("odo app command tests", func() { Context("when running app command without app parameter in directory that doesn't contain .odo config directory", func() { It("should fail without app parameter (except the list command)", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) // list should pass as the project exists @@ -107,7 +107,7 @@ var _ = Describe("odo app command tests", func() { Context("when running app command app parameter in directory that doesn't contain .odo config directory", func() { It("should successfully execute list, describe and delete along with machine readable output", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) appListOutput := helper.CmdShouldPass("odo", "app", "list", "--project", project) @@ -130,7 +130,7 @@ var _ = Describe("odo app command tests", func() { Context("When running app describe with storage added in component in directory that doesn't contain .odo config directory", func() { It("should successfully execute describe", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) helper.CmdShouldPass("odo", "storage", "create", "storage-one", "--context", context, "--path", mountPath, "--size", size) helper.CmdShouldPass("odo", "push", "--context", context) helper.CmdShouldPass("odo", "app", "describe", appName, "--project", project) diff --git a/tests/integration/cmd_debug_test.go b/tests/integration/cmd_debug_test.go index 26fa53742b9..5d123c80227 100644 --- a/tests/integration/cmd_debug_test.go +++ b/tests/integration/cmd_debug_test.go @@ -42,7 +42,7 @@ var _ = Describe("odo debug command tests", func() { Context("odo debug on a nodejs:latest component", func() { It("check that machine output debug information works", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs:latest", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs:latest", "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) httpPort, err := util.HTTPGetFreePort() @@ -69,7 +69,7 @@ var _ = Describe("odo debug command tests", func() { It("should expect a ws connection when tried to connect on different debug port locally and remotely", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs:latest", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs:latest", "--project", project, "--context", context) helper.CmdShouldPass("odo", "config", "set", "--force", "DebugPort", "9292", "--context", context) dbgPort := helper.GetConfigValueWithContext("DebugPort", context) Expect(dbgPort).To(Equal("9292")) @@ -88,7 +88,7 @@ var _ = Describe("odo debug command tests", func() { It("should expect a ws connection when tried to connect on default debug port locally", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs:latest", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs:latest", "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) stopChannel := make(chan bool) @@ -107,7 +107,7 @@ var _ = Describe("odo debug command tests", func() { Context("odo debug info should work on a odo component", func() { It("should start a debug session and run debug info on a running debug session", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs:latest", "nodejs-cmp-"+project, "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs:latest", "nodejs-cmp-"+project, "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) httpPort, err := util.HTTPGetFreePort() @@ -130,7 +130,7 @@ var _ = Describe("odo debug command tests", func() { It("should start a debug session and run debug info on a closed debug session", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs:latest", "nodejs-cmp-"+project, "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs:latest", "nodejs-cmp-"+project, "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) httpPort, err := util.HTTPGetFreePort() diff --git a/tests/integration/cmd_link_unlink_test.go b/tests/integration/cmd_link_unlink_test.go index f6982dfc74f..f30378242ed 100644 --- a/tests/integration/cmd_link_unlink_test.go +++ b/tests/integration/cmd_link_unlink_test.go @@ -41,14 +41,16 @@ var _ = Describe("odo link and unlink command tests", func() { Context("when running help for link command", func() { It("should display the help", func() { appHelp := helper.CmdShouldPass("odo", "link", "-h") - Expect(appHelp).To(ContainSubstring("Link component to a service or component")) + // Check for -vmodule moduleSpec output which is in additional flags + Expect(appHelp).To(ContainSubstring("--vmodule moduleSpec")) }) }) Context("when running help for unlink command", func() { It("should display the help", func() { appHelp := helper.CmdShouldPass("odo", "unlink", "-h") - Expect(appHelp).To(ContainSubstring("Unlink component or service from a component")) + // Check for -vmodule moduleSpec output which is in additional flags + Expect(appHelp).To(ContainSubstring("--vmodule moduleSpec")) }) }) @@ -63,10 +65,10 @@ var _ = Describe("odo link and unlink command tests", func() { }) It("should fail", func() { helper.CopyExample(filepath.Join("source", "nodejs"), frontendContext) - helper.CmdShouldPass("odo", "create", "nodejs", "frontend", "--context", frontendContext, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "frontend", "--context", frontendContext, "--project", project) helper.CmdShouldPass("odo", "push", "--context", frontendContext) helper.CopyExample(filepath.Join("source", "python"), backendContext) - helper.CmdShouldPass("odo", "create", "python", "backend", "--context", backendContext, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "python", "backend", "--context", backendContext, "--project", project) helper.CmdShouldPass("odo", "push", "--context", backendContext) stdErr := helper.CmdShouldFail("odo", "link", "backend", "--context", frontendContext, "--port", "1234") Expect(stdErr).To(ContainSubstring("Unable to properly link to component backend using port 1234")) @@ -84,13 +86,13 @@ var _ = Describe("odo link and unlink command tests", func() { }) It("should link the frontend application to the backend and then unlink successfully", func() { helper.CopyExample(filepath.Join("source", "nodejs"), frontendContext) - helper.CmdShouldPass("odo", "create", "nodejs", "frontend", "--context", frontendContext, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "frontend", "--context", frontendContext, "--project", project) helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", frontendContext) helper.CmdShouldPass("odo", "push", "--context", frontendContext) frontendURL := helper.DetermineRouteURL(frontendContext) oc.ImportJavaIS(project) helper.CopyExample(filepath.Join("source", "openjdk"), backendContext) - helper.CmdShouldPass("odo", "create", "java:8", "backend", "--project", project, "--context", backendContext) + helper.CmdShouldPass("odo", "create", "--s2i", "java:8", "backend", "--project", project, "--context", backendContext) helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", backendContext) helper.CmdShouldPass("odo", "push", "--context", backendContext) @@ -113,14 +115,14 @@ var _ = Describe("odo link and unlink command tests", func() { It("Wait till frontend dc rollout properly after linking the frontend application to the backend", func() { appName := helper.RandString(7) helper.CopyExample(filepath.Join("source", "nodejs"), frontendContext) - helper.CmdShouldPass("odo", "create", "nodejs", "frontend", "--app", appName, "--context", frontendContext, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "frontend", "--app", appName, "--context", frontendContext, "--project", project) helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", frontendContext) helper.CmdShouldPass("odo", "push", "--context", frontendContext) frontendURL := helper.DetermineRouteURL(frontendContext) oc.ImportJavaIS(project) helper.CopyExample(filepath.Join("source", "openjdk"), backendContext) - helper.CmdShouldPass("odo", "create", "java:8", "backend", "--app", appName, "--project", project, "--context", backendContext) + helper.CmdShouldPass("odo", "create", "--s2i", "java:8", "backend", "--app", appName, "--project", project, "--context", backendContext) helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", backendContext) helper.CmdShouldPass("odo", "push", "--context", backendContext) @@ -138,10 +140,10 @@ var _ = Describe("odo link and unlink command tests", func() { It("should successfully delete component after linked component is deleted", func() { // first create the two components helper.CopyExample(filepath.Join("source", "nodejs"), frontendContext) - helper.CmdShouldPass("odo", "create", "nodejs", "frontend", "--context", frontendContext, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "frontend", "--context", frontendContext, "--project", project) helper.CmdShouldPass("odo", "push", "--context", frontendContext) helper.CopyExample(filepath.Join("source", "nodejs"), backendContext) - helper.CmdShouldPass("odo", "create", "nodejs", "backend", "--context", backendContext, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "backend", "--context", backendContext, "--project", project) helper.CmdShouldPass("odo", "push", "--context", backendContext) // now link frontend to the backend component diff --git a/tests/integration/cmd_pref_config_test.go b/tests/integration/cmd_pref_config_test.go index db3b0bdec37..07db6ad65cb 100644 --- a/tests/integration/cmd_pref_config_test.go +++ b/tests/integration/cmd_pref_config_test.go @@ -190,7 +190,7 @@ var _ = Describe("odo preference and config command tests", func() { paramValue: "https://github.com/sclorg/nodejs-ex", }, } - helper.CmdShouldPass("odo", "create", "nodejs", "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--project", project) for _, testCase := range cases { helper.CmdShouldPass("odo", "config", "set", testCase.paramName, testCase.paramValue, "-f") setValue := helper.GetConfigValue(testCase.paramName) @@ -269,7 +269,7 @@ var _ = Describe("odo preference and config command tests", func() { paramValue: "https://github.com/sclorg/nodejs-ex", }, } - helper.CmdShouldPass("odo", "create", "nodejs", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--project", project, "--context", context) for _, testCase := range cases { helper.CmdShouldPass("odo", "config", "set", "-f", "--context", context, testCase.paramName, testCase.paramValue) @@ -293,7 +293,7 @@ var _ = Describe("odo preference and config command tests", func() { helper.DeleteDir(context) }) It("should set and unset env variables", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--project", project, "--context", context) helper.CmdShouldPass("odo", "config", "set", "--env", "PORT=4000", "--env", "PORT=1234", "--context", context) configPort := helper.GetConfigValueWithContext("PORT", context) Expect(configPort).To(ContainSubstring("1234")) @@ -306,7 +306,7 @@ var _ = Describe("odo preference and config command tests", func() { helper.DontMatchAllInOutput(configValue, []string{"PORT", "SECRET_KEY"}) }) It("should check for existence of environment variable in config before unsetting it", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--project", project, "--context", context) helper.CmdShouldPass("odo", "config", "set", "--env", "PORT=4000", "--env", "PORT=1234", "--context", context) // unset a valid env var @@ -330,7 +330,7 @@ var _ = Describe("odo preference and config command tests", func() { helper.DeleteDir(context) }) It("should list config successfully", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--project", project, "--context", context) helper.CmdShouldPass("odo", "config", "set", "--env", "hello=world", "--context", context) kubeconfigOld := os.Getenv("KUBECONFIG") os.Setenv("KUBECONFIG", "/no/such/path") @@ -340,7 +340,7 @@ var _ = Describe("odo preference and config command tests", func() { }) It("should set config variable without logging in", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--project", project, "--context", context) kubeconfigOld := os.Getenv("KUBECONFIG") os.Setenv("KUBECONFIG", "/no/such/path") helper.CmdShouldPass("odo", "config", "set", "--force", "--context", context, "Name", "foobar") @@ -366,7 +366,7 @@ var _ = Describe("odo preference and config command tests", func() { It("should successfully set and unset variables", func() { //set env var helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--project", project, "--context", context) helper.CmdShouldPass("odo", "config", "set", "--now", "--env", "hello=world", "--context", context) //*Check config configValue1 := helper.CmdShouldPass("odo", "config", "view", "--context", context) diff --git a/tests/integration/cmd_push_test.go b/tests/integration/cmd_push_test.go index 0976f19513a..7e94f4ffa07 100644 --- a/tests/integration/cmd_push_test.go +++ b/tests/integration/cmd_push_test.go @@ -45,7 +45,7 @@ var _ = Describe("odo push command tests", func() { It("Check that pod timeout works and we time out immediately..", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) helper.CmdShouldPass("odo", "preference", "set", "PushTimeout", "1") output := helper.CmdShouldFail("odo", "push", "--context", context+"/nodejs-ex") Expect(output).To(ContainSubstring("waited 1s but couldn't find running pod matching selector")) @@ -58,7 +58,7 @@ var _ = Describe("odo push command tests", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "config", "set", "Memory", "300Mi", "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) @@ -68,7 +68,7 @@ var _ = Describe("odo push command tests", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "config", "set", "minmemory", "100Mi", "--context", context) output := helper.CmdShouldFail("odo", "push", "--context", context) @@ -79,7 +79,7 @@ var _ = Describe("odo push command tests", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "config", "set", "maxmemory", "400Mi", "--context", context) output := helper.CmdShouldFail("odo", "push", "--context", context) @@ -90,7 +90,7 @@ var _ = Describe("odo push command tests", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "config", "set", "cpu", "0.4", "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) @@ -100,7 +100,7 @@ var _ = Describe("odo push command tests", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "config", "set", "mincpu", "0.4", "--context", context) output := helper.CmdShouldFail("odo", "push", "--context", context) @@ -111,7 +111,7 @@ var _ = Describe("odo push command tests", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "config", "set", "maxcpu", "0.5", "--context", context) output := helper.CmdShouldFail("odo", "push", "--context", context) @@ -123,7 +123,7 @@ var _ = Describe("odo push command tests", func() { It("Check for labels", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "push", "--context", context) // Check for all the labels @@ -154,7 +154,7 @@ var _ = Describe("odo push command tests", func() { It("Push, modify a file and then push outside of the working directory", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "push", "--context", context) // Create a new file to test propagating changes @@ -178,7 +178,7 @@ var _ = Describe("odo push command tests", func() { Context("when push command is executed", func() { It("should not build when no changes are detected in the directory and build when a file change is detected", func() { helper.CmdShouldPass("git", "clone", "https://github.com/openshift/nodejs-ex", context+"/nodejs-ex") - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", context+"/nodejs-ex") output := helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") @@ -194,7 +194,7 @@ var _ = Describe("odo push command tests", func() { It("should be able to create a file, push, delete, then push again propagating the deletions and build", func() { helper.CmdShouldPass("git", "clone", "https://github.com/openshift/nodejs-ex", context+"/nodejs-ex") - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") output := helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") Expect(output).To(ContainSubstring("No file changes detected, skipping build")) @@ -233,7 +233,7 @@ var _ = Describe("odo push command tests", func() { It("should build when a file and a folder is renamed in the directory", func() { helper.CmdShouldPass("git", "clone", "https://github.com/openshift/nodejs-ex", context+"/nodejs-ex") - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") output := helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") @@ -272,7 +272,7 @@ var _ = Describe("odo push command tests", func() { It("should build when no changes are detected in the directory and force flag is enabled", func() { helper.CmdShouldPass("git", "clone", "https://github.com/openshift/nodejs-ex", context+"/nodejs-ex") - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", context+"/nodejs-ex") @@ -283,7 +283,7 @@ var _ = Describe("odo push command tests", func() { It("should push only the modified files", func() { helper.CmdShouldPass("git", "clone", "https://github.com/openshift/nodejs-ex", context+"/nodejs-ex") - helper.CmdShouldPass("odo", "component", "create", "nodejs:latest", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs:latest", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", context+"/nodejs-ex") helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") @@ -355,7 +355,7 @@ var _ = Describe("odo push command tests", func() { oc.ImportJavaIS(project) cmpName := "backend" helper.CopyExample(filepath.Join("source", "openjdk"), context) - helper.CmdShouldPass("odo", "create", "java:8", "backend", "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "create", "--s2i", "java:8", "backend", "--project", project, "--context", context, "--app", appName) helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) @@ -404,7 +404,7 @@ var _ = Describe("odo push command tests", func() { fmt.Printf("the .odoignore file was not created, reason %v", err.Error()) } - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--project", project, "--context", context+"/nodejs-ex") + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--project", project, "--context", context+"/nodejs-ex") helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") // get the name of running pod @@ -435,7 +435,7 @@ var _ = Describe("odo push command tests", func() { Context("when .gitignore file exists", func() { It("should create and push the contents of a named component and include odo-file-index.json path to .gitignore file to exclude the contents", func() { helper.CmdShouldPass("git", "clone", "https://github.com/openshift/nodejs-ex", context+"/nodejs-ex") - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context+"/nodejs-ex", "--app", appName) // push and include the odo-file-index.json path to .gitignore file helper.CmdShouldPass("odo", "push", "--context", filepath.Join(context, "nodejs-ex")) @@ -447,7 +447,7 @@ var _ = Describe("odo push command tests", func() { Context("when .gitignore file does not exist", func() { It("should create and push the contents of a named component and also create .gitignore then include odo-file-index.json path to .gitignore file to exclude the contents", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--app", appName) // push and include the odo-file-index.json path to .gitignore file helper.CmdShouldPass("odo", "push", "--context", context) @@ -459,9 +459,7 @@ var _ = Describe("odo push command tests", func() { Context("when running odo push with flag --show-log", func() { It("should be able to execute odo push consecutively without breaking anything", func() { helper.CmdShouldPass("git", "clone", "https://github.com/openshift/nodejs-ex", context+"/nodejs-ex") - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--project", project, "--context", context+"/nodejs-ex") - - // Run odo push in consecutive iteration + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--project", project, "--context", context+"/nodejs-ex") output := helper.CmdShouldPass("odo", "push", "--show-log", "--context", context+"/nodejs-ex") Expect(output).To(Not(ContainSubstring("No file changes detected, skipping build"))) diff --git a/tests/integration/cmd_storage_test.go b/tests/integration/cmd_storage_test.go index e5ede79b7bd..36f917aff6b 100644 --- a/tests/integration/cmd_storage_test.go +++ b/tests/integration/cmd_storage_test.go @@ -43,7 +43,7 @@ var _ = Describe("odo storage command tests", func() { Context("when running storage command without required flag(s)", func() { It("should fail", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", "nodejs", "--app", "nodeapp", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", "nodejs", "--app", "nodeapp", "--project", project, "--context", context) stdErr := helper.CmdShouldFail("odo", "storage", "create", "pv1", "--context", context) Expect(stdErr).To(ContainSubstring("required flag")) stdErr = helper.CmdShouldFail("odo", "storage", "create", "pv1", "--path", "/data", "--context", context) @@ -56,7 +56,7 @@ var _ = Describe("odo storage command tests", func() { It("should add a storage, list and delete it", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", "nodejs", "--app", "nodeapp", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", "nodejs", "--app", "nodeapp", "--project", project, "--context", context) // Default flag value // --app string Application, defaults to active application // --component string Component, defaults to active component. @@ -94,7 +94,7 @@ var _ = Describe("odo storage command tests", func() { Context("when using storage command with specified flag values", func() { It("should add a storage, list and delete it", func() { helper.CopyExample(filepath.Join("source", "python"), context) - helper.CmdShouldPass("odo", "component", "create", "python", "python", "--app", "pyapp", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "python", "python", "--app", "pyapp", "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) storAdd := helper.CmdShouldPass("odo", "storage", "create", "pv1", "--path", "/mnt/pv1", "--size", "1Gi", "--context", context) Expect(storAdd).To(ContainSubstring("python")) @@ -130,7 +130,7 @@ var _ = Describe("odo storage command tests", func() { Context("when using storage command with -o json", func() { It("should create and list output in json format", func() { helper.CopyExample(filepath.Join("source", "wildfly"), context) - helper.CmdShouldPass("odo", "component", "create", "wildfly", "wildfly", "--app", "wildflyapp", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "wildfly", "wildfly", "--app", "wildflyapp", "--project", project, "--context", context) actualJSONStorage := helper.CmdShouldPass("odo", "storage", "create", "mystorage", "--path=/opt/app-root/src/storage/", "--size=1Gi", "--context", context, "-o", "json") desiredJSONStorage := `{"kind":"storage","apiVersion":"odo.dev/v1alpha1","metadata":{"name":"mystorage","creationTimestamp":null},"spec":{"size":"1Gi","path":"/opt/app-root/src/storage/"}}` Expect(desiredJSONStorage).Should(MatchJSON(actualJSONStorage)) @@ -147,7 +147,7 @@ var _ = Describe("odo storage command tests", func() { It("should list storage with correct state", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", "nodejs", "--app", "nodeapp", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", "nodejs", "--app", "nodeapp", "--project", project, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) // create storage, list storage should have state "Not Pushed" diff --git a/tests/integration/cmd_url_test.go b/tests/integration/cmd_url_test.go index df5faec8a20..3c7bbf4bcdb 100644 --- a/tests/integration/cmd_url_test.go +++ b/tests/integration/cmd_url_test.go @@ -44,7 +44,7 @@ var _ = Describe("odo url command tests", func() { url1 := helper.RandString(5) url2 := helper.RandString(5) componentName := helper.RandString(6) - helper.CmdShouldPass("odo", "create", "nodejs", "--context", context, "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex", "--port", "8080,8000") + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--context", context, "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex", "--port", "8080,8000") helper.CmdShouldPass("odo", "push", "--context", context) stdout = helper.CmdShouldFail("odo", "url", "list", "--context", context) Expect(stdout).To(ContainSubstring("no URLs found")) @@ -75,7 +75,7 @@ var _ = Describe("odo url command tests", func() { url1 := helper.RandString(5) componentName := helper.RandString(6) helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "create", "nodejs", "--context", context, "--project", project, componentName) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--context", context, "--project", project, componentName) helper.CmdShouldPass("odo", "url", "create", url1, "--port", "8080", "--context", context, "--secure") @@ -100,7 +100,7 @@ var _ = Describe("odo url command tests", func() { var stdout string url1 := helper.RandString(5) componentName := helper.RandString(6) - helper.CmdShouldPass("odo", "create", "nodejs", "--context", context, "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex", "--port", "8080,8000") + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--context", context, "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex", "--port", "8080,8000") helper.CmdShouldPass("odo", "url", "create", url1, "--port", "8080", "--context", context) stdout = helper.CmdShouldPass("odo", "url", "describe", url1, "--context", context) @@ -117,7 +117,7 @@ var _ = Describe("odo url command tests", func() { }) It("should be able to describe a url in CLI format and machine readable json format for a secure url", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--app", "myapp", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--app", "myapp", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context) helper.CmdShouldPass("odo", "url", "create", "myurl", "--secure", "--context", context) actualURLDescribeJSON := helper.CmdShouldPass("odo", "url", "describe", "myurl", "-o", "json", "--context", context) @@ -146,7 +146,7 @@ var _ = Describe("odo url command tests", func() { helper.Chdir(originalDir) }) It("should be able to list url in machine readable json format", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--app", "myapp", "--project", project, "--git", "https://github.com/openshift/nodejs-ex") + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--app", "myapp", "--project", project, "--git", "https://github.com/openshift/nodejs-ex") helper.CmdShouldPass("odo", "url", "create", "myurl") helper.CmdShouldPass("odo", "push") @@ -159,7 +159,7 @@ var _ = Describe("odo url command tests", func() { }) It("should be able to list url in machine readable json format for a secure url", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--app", "myapp", "--project", project, "--git", "https://github.com/openshift/nodejs-ex") + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--app", "myapp", "--project", project, "--git", "https://github.com/openshift/nodejs-ex") helper.CmdShouldPass("odo", "url", "create", "myurl", "--secure") actualURLListJSON := helper.CmdShouldPass("odo", "url", "list", "-o", "json") desiredURLListJSON := `{"kind":"List","apiVersion":"odo.dev/v1alpha1","metadata":{},"items":[{"kind":"url","apiVersion":"odo.dev/v1alpha1","metadata":{"name":"myurl","creationTimestamp":null},"spec":{"port":8080,"secure":true,"path": "/","kind": "route"},"status":{"state": "Not Pushed"}}]}` @@ -181,7 +181,7 @@ var _ = Describe("odo url command tests", func() { url1 := helper.RandString(5) componentName := helper.RandString(6) helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "create", "nodejs", "--context", context, "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex", "--port", "8080,8000") + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--context", context, "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex", "--port", "8080,8000") helper.CmdShouldPass("odo", "url", "create", url1, "--context", context, "--port", "8080", "--now") out1 := helper.CmdShouldPass("odo", "url", "list", "--context", context) helper.MatchAllInOutput(out1, []string{url1, "Pushed", url1}) diff --git a/tests/integration/cmd_watch_test.go b/tests/integration/cmd_watch_test.go index 4d49baf273c..20ca449ea3b 100644 --- a/tests/integration/cmd_watch_test.go +++ b/tests/integration/cmd_watch_test.go @@ -45,7 +45,7 @@ var _ = Describe("odo watch command tests", func() { Context("when executing watch without pushing the component", func() { It("should fail", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", "--project", project, "--context", context) output := helper.CmdShouldFail("odo", "watch", "--context", context) Expect(output).To(ContainSubstring("component does not exist. Please use `odo push` to create your component")) }) @@ -61,7 +61,7 @@ var _ = Describe("odo watch command tests", func() { }) It("should fail with proper error", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs", "--project", project) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs", "--project", project) output := helper.CmdShouldFail("odo", "watch", "--app", "dummy") Expect(output).To(ContainSubstring("component does not exist")) }) @@ -69,7 +69,7 @@ var _ = Describe("odo watch command tests", func() { Context("when executing watch on a git source type component", func() { It("should fail", func() { - helper.CmdShouldPass("odo", "create", "--context", context, "nodejs", "--git", "https://github.com/openshift/nodejs-ex.git") + helper.CmdShouldPass("odo", "create", "--s2i", "--context", context, "nodejs", "--git", "https://github.com/openshift/nodejs-ex.git") output := helper.CmdShouldFail("odo", "watch", "--context", context) Expect(output).To(ContainSubstring("Watch is supported by binary and local components only")) }) diff --git a/tests/integration/component.go b/tests/integration/component.go index 3fc72e2572b..4533a29038d 100644 --- a/tests/integration/component.go +++ b/tests/integration/component.go @@ -61,7 +61,7 @@ func componentTests(args ...string) { }) It("should create component even in new project", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,cmp-git", "Application,testing") helper.CmdShouldPass("odo", append(args, "push", "--context", context, "-v4")...) oc.SwitchProject(project) @@ -70,7 +70,7 @@ func componentTests(args ...string) { }) It("shouldn't error when creating a component with --project and --context at the same time", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...) helper.CmdShouldPass("odo", append(args, "push", "--context", context, "-v4")...) oc.SwitchProject(project) projectList := helper.CmdShouldPass("odo", "project", "list") @@ -78,13 +78,13 @@ func componentTests(args ...string) { }) It("should error when listing components (basically anything other then creating) with --project and --context ", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...) helper.CmdShouldFail("odo", "list", "--project", project, "--context", context) }) It("Without an application should create one", func() { componentName := helper.RandString(6) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+componentName, "Application,app") helper.CmdShouldPass("odo", append(args, "push")...) appName := helper.CmdShouldPass("odo", "app", "list") @@ -104,30 +104,30 @@ func componentTests(args ...string) { It("should create default named component when passed same context differently", func() { dir := filepath.Base(context) helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project, "--context", ".", "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "--project", project, "--context", ".", "--app", "testing")...) componentName := helper.GetConfigValueWithContext("Name", context) Expect(componentName).To(ContainSubstring("nodejs-" + dir)) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+componentName, "Application,testing") helper.DeleteDir(filepath.Join(context, ".odo")) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project, "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "--project", project, "--context", context, "--app", "testing")...) newComponentName := helper.GetConfigValueWithContext("Name", context) Expect(newComponentName).To(ContainSubstring("nodejs-" + dir)) }) It("should show an error when ref flag is provided with sources except git", func() { - outputErr := helper.CmdShouldFail("odo", append(args, "create", "nodejs", "--project", project, "cmp-git", "--ref", "test")...) + outputErr := helper.CmdShouldFail("odo", append(args, "create", "--s2i", "nodejs", "--project", project, "cmp-git", "--ref", "test")...) Expect(outputErr).To(ContainSubstring("the --ref flag is only valid for --git flag")) }) It("create component twice fails from same directory", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "nodejs", "--project", project)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "nodejs", "--project", project)...) output := helper.CmdShouldFail("odo", append(args, "create", "nodejs", "nodejs", "--project", project)...) Expect(output).To(ContainSubstring("this directory already contains a component")) }) It("should list out component in json format along with path flag", func() { var contextPath string - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "nodejs", "--project", project)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "nodejs", "--project", project)...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,nodejs", "Application,app") if runtime.GOOS == "windows" { contextPath = strings.Replace(strings.TrimSpace(context), "\\", "\\\\", -1) @@ -149,7 +149,7 @@ func componentTests(args ...string) { var contextPath string var contextPath2 string helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "nodejs", "--project", project)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "nodejs", "--project", project)...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,nodejs", "Application,app") helper.CmdShouldPass("odo", append(args, "push")...) @@ -157,7 +157,7 @@ func componentTests(args ...string) { context2 := helper.CreateNewContext() helper.Chdir(context2) helper.CopyExample(filepath.Join("source", "python"), context2) - helper.CmdShouldPass("odo", append(args, "create", "python", "python", "--project", project2)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "python", "python", "--project", project2)...) helper.ValidateLocalCmpExist(context2, "Type,python", "Name,python", "Application,app") helper.CmdShouldPass("odo", append(args, "push")...) @@ -186,7 +186,7 @@ func componentTests(args ...string) { }) It("should list the component", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,cmp-git", "Application,testing") helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) @@ -201,14 +201,14 @@ func componentTests(args ...string) { }) It("should list the component when it is not pushed", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,cmp-git", "Application,testing") cmpList := helper.CmdShouldPass("odo", append(args, "list", "--context", context)...) helper.MatchAllInOutput(cmpList, []string{"cmp-git", "Not Pushed"}) helper.CmdShouldPass("odo", append(args, "delete", "-f", "--all", "--context", context)...) }) It("should list the state as unknown for disconnected cluster", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,cmp-git", "Application,testing") kubeconfigOrig := os.Getenv("KUBECONFIG") os.Setenv("KUBECONFIG", "/no/such/path") @@ -225,7 +225,7 @@ func componentTests(args ...string) { }) It("should describe the component when it is not pushed", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) helper.CmdShouldPass("odo", "url", "create", "url-1", "--context", context) helper.CmdShouldPass("odo", "url", "create", "url-2", "--context", context) helper.CmdShouldPass("odo", "storage", "create", "storage-1", "--size", "1Gi", "--path", "/data1", "--context", context) @@ -255,7 +255,7 @@ func componentTests(args ...string) { It("should describe not pushed component when it is created with json output", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - cmpDescribeJSON, err := helper.Unindented(helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--context", context, "--app", "testing", "-o", "json")...)) + cmpDescribeJSON, err := helper.Unindented(helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--context", context, "--app", "testing", "-o", "json")...)) Expect(err).Should(BeNil()) expected, err := helper.Unindented(`{"kind": "Component","apiVersion": "odo.dev/v1alpha1","metadata": {"name": "cmp-git","namespace": "` + project + `","creationTimestamp": null},"spec":{"app": "testing","type":"nodejs","source": "file://./","sourceType": "local","ports": ["8080/TCP"]}, "status": {"state": "Not Pushed"}}`) Expect(err).Should(BeNil()) @@ -265,7 +265,7 @@ func componentTests(args ...string) { It("should describe pushed component when it is created with json output", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - cmpDescribeJSON, err := helper.Unindented(helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--context", context, "--app", "testing", "-o", "json", "--now")...)) + cmpDescribeJSON, err := helper.Unindented(helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--context", context, "--app", "testing", "-o", "json", "--now")...)) Expect(err).Should(BeNil()) expected, err := helper.Unindented(`{"kind": "Component","apiVersion": "odo.dev/v1alpha1","metadata": {"name": "cmp-git","namespace": "` + project + `","creationTimestamp": null},"spec":{"app": "testing","type":"nodejs","sourceType": "local","env": [{"name": "DEBUG_PORT","value": "5858"}],"ports": ["8080/TCP"]}, "status": {"state": "Pushed"}}`) Expect(err).Should(BeNil()) @@ -275,12 +275,12 @@ func componentTests(args ...string) { It("should list the component in the same app when one is pushed and the other one is not pushed", func() { helper.Chdir(originalDir) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,cmp-git", "Application,testing") helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) context2 := helper.CreateNewContext() - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git-2", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context2, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git-2", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context2, "--app", "testing")...) helper.ValidateLocalCmpExist(context2, "Type,nodejs", "Name,cmp-git-2", "Application,testing") cmpList := helper.CmdShouldPass("odo", append(args, "list", "--context", context2)...) helper.MatchAllInOutput(cmpList, []string{"cmp-git", "cmp-git-2", "Not Pushed", "Pushed"}) @@ -291,18 +291,15 @@ func componentTests(args ...string) { }) It("should succeed listing catalog components", func() { - // Since components catalog is constantly changing, we simply check to see if this command passes.. rather than checking the JSON each time. - output := helper.CmdShouldPass("odo", "catalog", "list", "components", "-o", "json") - helper.MatchAllInOutput(output, []string{"List", "supportedTags"}) - Expect(output).ToNot(ContainSubstring("devfileItems")) + helper.CmdShouldPass("odo", "catalog", "list", "components", "-o", "json") }) It("binary component should not fail when --context is not set", func() { oc.ImportJavaIS(project) helper.CopyExample(filepath.Join("binary", "java", "openjdk"), context) // Was failing due to https://github.com/openshift/odo/issues/1969 - helper.CmdShouldPass("odo", append(args, "create", "java:8", "sb-jar-test", "--project", + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "java:8", "sb-jar-test", "--project", project, "--binary", filepath.Join(context, "sb.jar"))...) helper.ValidateLocalCmpExist(context, "Type,java:8", "Name,sb-jar-test") }) @@ -314,7 +311,7 @@ func componentTests(args ...string) { newContext := helper.CreateNewContext() defer helper.DeleteDir(newContext) - output := helper.CmdShouldFail("odo", append(args, "create", "java:8", "sb-jar-test", "--project", + output := helper.CmdShouldFail("odo", append(args, "create", "--s2i", "java:8", "sb-jar-test", "--project", project, "--binary", filepath.Join(context, "sb.jar"), "--context", newContext)...) Expect(output).To(ContainSubstring("inside of the context directory")) }) @@ -326,7 +323,7 @@ func componentTests(args ...string) { relativeContext := fmt.Sprintf("..%c%s", filepath.Separator, filepath.Base(context)) fmt.Printf("relativeContext = %#v\n", relativeContext) - helper.CmdShouldPass("odo", append(args, "create", "java:8", "sb-jar-test", "--project", + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "java:8", "sb-jar-test", "--project", project, "--binary", filepath.Join(context, "sb.jar"), "--context", relativeContext)...) helper.ValidateLocalCmpExist(relativeContext, "Type,java:8", "Name,sb-jar-test") }) @@ -349,7 +346,7 @@ func componentTests(args ...string) { cmpName := "nodejs" helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project)...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+cmpName, "Application,"+appName) // component doesn't exist yet so attempt to only push source should fail @@ -379,7 +376,7 @@ func componentTests(args ...string) { cmpName := "nodejs-push-atonce" helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project)...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+cmpName, "Application,"+appName) // Push only config and see that the component is created but wothout any source copied helper.CmdShouldPass("odo", append(args, "push")...) @@ -405,7 +402,7 @@ func componentTests(args ...string) { cmpName := "nodejs" helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--context", context, "--app", appName, "--project", project)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--context", context, "--app", appName, "--project", project)...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+cmpName, "Application,"+appName) // component doesn't exist yet so attempt to only push source should fail @@ -435,7 +432,7 @@ func componentTests(args ...string) { cmpName := "nodejs-push-atonce" helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--context", context, "--project", project)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--context", context, "--project", project)...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+cmpName, "Application,"+appName) // Push both config and source @@ -465,7 +462,7 @@ func componentTests(args ...string) { helper.DeleteProject(project) }) It("should create component", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,cmp-git", "Application,testing") helper.CmdShouldPass("odo", append(args, "push", "--context", context, "-v4")...) oc.SwitchProject(project) @@ -488,7 +485,7 @@ func componentTests(args ...string) { appName := "nodejs-create-now-test" cmpName := "nodejs-push-atonce" helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project, "--now")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--now")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+cmpName, "Application,"+appName) oc.VerifyCmpExists(cmpName, appName, project) @@ -523,14 +520,14 @@ func componentTests(args ...string) { It("create local nodejs component twice and fail", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project, "--env", "key=value,key1=value1")...) - output := helper.CmdShouldFail("odo", append(args, "create", "nodejs", "--project", project, "--env", "key=value,key1=value1")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "--project", project, "--env", "key=value,key1=value1")...) + output := helper.CmdShouldFail("odo", append(args, "create", "--s2i", "nodejs", "--project", project, "--env", "key=value,key1=value1")...) Expect(output).To(ContainSubstring("this directory already contains a component")) }) It("creates and pushes local nodejs component and then deletes --all", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", componentName, "--app", appName, "--project", project, "--env", "key=value,key1=value1")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", componentName, "--app", appName, "--project", project, "--env", "key=value,key1=value1")...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+componentName, "Application,"+appName) helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) helper.CmdShouldPass("odo", append(args, "delete", "--context", context, "-f", "--all")...) @@ -542,7 +539,7 @@ func componentTests(args ...string) { It("creates a local python component, pushes it and then deletes it using --all flag", func() { helper.CopyExample(filepath.Join("source", "python"), context) - helper.CmdShouldPass("odo", append(args, "create", "python", componentName, "--app", appName, "--project", project, "--context", context)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "python", componentName, "--app", appName, "--project", project, "--context", context)...) helper.ValidateLocalCmpExist(context, "Type,python", "Name,"+componentName, "Application,"+appName) helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) helper.CmdShouldPass("odo", append(args, "delete", "--context", context, "-f")...) @@ -555,7 +552,7 @@ func componentTests(args ...string) { It("creates a local python component, pushes it and then deletes it using --all flag in local directory", func() { helper.CopyExample(filepath.Join("source", "python"), context) - helper.CmdShouldPass("odo", append(args, "create", "python", componentName, "--app", appName, "--project", project)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "python", componentName, "--app", appName, "--project", project)...) helper.ValidateLocalCmpExist(context, "Type,python", "Name,"+componentName, "Application,"+appName) helper.CmdShouldPass("odo", append(args, "push")...) helper.CmdShouldPass("odo", append(args, "delete", "--all", "-f")...) @@ -568,19 +565,19 @@ func componentTests(args ...string) { It("creates a local python component and check for unsupported warning", func() { helper.CopyExample(filepath.Join("source", "python"), context) - output := helper.CmdShouldPass("odo", append(args, "create", "python", componentName, "--app", appName, "--project", project, "--context", context)...) + output := helper.CmdShouldPass("odo", append(args, "create", "--s2i", "python", componentName, "--app", appName, "--project", project, "--context", context)...) Expect(output).To(ContainSubstring("Warning: python is not fully supported by odo, and it is not guaranteed to work")) }) It("creates a local nodejs component and check unsupported warning hasn't occured", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - output := helper.CmdShouldPass("odo", append(args, "create", "nodejs:latest", componentName, "--app", appName, "--project", project, "--context", context)...) + output := helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs:latest", componentName, "--app", appName, "--project", project, "--context", context)...) Expect(output).NotTo(ContainSubstring("Warning")) }) It("creates a local java component and check unsupported warning hasn't occured", func() { helper.CopyExample(filepath.Join("binary", "java", "openjdk"), context) - output := helper.CmdShouldPass("odo", append(args, "create", "java:latest", componentName, "--project", project, "--context", context)...) + output := helper.CmdShouldPass("odo", append(args, "create", "--s2i", "java:latest", componentName, "--project", project, "--context", context)...) Expect(output).NotTo(ContainSubstring("Warning")) }) }) @@ -596,7 +593,7 @@ func componentTests(args ...string) { It("should be able to create a git component and update it from local to git", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--context", context, "--app", "testing")...) helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) helper.CmdShouldPass("odo", "update", "--git", "https://github.com/openshift/nodejs-ex.git", "--context", context) @@ -608,7 +605,7 @@ func componentTests(args ...string) { }) It("should be able to update a component from git to local", func() { - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing")...) helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) // update the component config according to the git component @@ -640,7 +637,7 @@ func componentTests(args ...string) { It("should pass inside a odo directory without component name as parameter", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) helper.CmdShouldPass("odo", "url", "create", "example", "--context", context) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+cmpName, "Application,"+appName, "URL,0,Name,example") helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) @@ -660,7 +657,7 @@ func componentTests(args ...string) { It("should fail outside a odo directory without component name as parameter", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+cmpName, "Application,"+appName) helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) @@ -673,7 +670,7 @@ func componentTests(args ...string) { It("should pass outside a odo directory with component name as parameter", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) helper.ValidateLocalCmpExist(context, "Type,nodejs", "Name,"+cmpName, "Application,"+appName) helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) @@ -704,7 +701,7 @@ func componentTests(args ...string) { componentName := helper.RandString(6) appName := helper.RandString(6) helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", componentName, "--app", appName, "--project", project, "--context", context)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", componentName, "--app", appName, "--project", project, "--context", context)...) helper.CmdShouldPass("odo", append(args, "push", "--context", context)...) helper.Chdir(context) @@ -739,7 +736,7 @@ func componentTests(args ...string) { It("should create default named component in a directory with numeric name", func() { helper.CopyExample(filepath.Join("source", "nodejs"), contextNumeric) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project, "--context", contextNumeric, "--app", "testing")...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", "--project", project, "--context", contextNumeric, "--app", "testing")...) helper.ValidateLocalCmpExist(contextNumeric, "Type,nodejs", "Application,testing") helper.CmdShouldPass("odo", append(args, "push", "--context", contextNumeric, "-v4")...) }) @@ -775,7 +772,7 @@ func componentTests(args ...string) { helper.CopyExample(filepath.Join("binary", "java", "openjdk"), context) // create the component using symlink - helper.CmdShouldPass("odo", append(args, "create", "java:8", "sb-jar-test", "--project", + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "java:8", "sb-jar-test", "--project", project, "--binary", filepath.Join(symLinkPath, "sb.jar"), "--context", symLinkPath)...) // Create a URL and push without using the symlink @@ -793,7 +790,7 @@ func componentTests(args ...string) { It("Should be able to deploy a wildfly war file using symlinks in some odo commands", func() { helper.CopyExample(filepath.Join("binary", "java", "wildfly"), context) - helper.CmdShouldPass("odo", append(args, "create", "wildfly", "javaee-war-test", "--project", + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "wildfly", "javaee-war-test", "--project", project, "--binary", filepath.Join(symLinkPath, "ROOT.war"), "--context", symLinkPath)...) // Create a URL @@ -824,7 +821,7 @@ func componentTests(args ...string) { It("should delete the component and the owned resources", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) helper.CmdShouldPass("odo", "url", "create", "example-1", "--context", context) helper.CmdShouldPass("odo", "storage", "create", "storage-1", "--size", "1Gi", "--path", "/data1", "--context", context) @@ -847,7 +844,7 @@ func componentTests(args ...string) { It("should delete the component and the owned resources with wait flag", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) + helper.CmdShouldPass("odo", append(args, "create", "--s2i", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)...) helper.CmdShouldPass("odo", "url", "create", "example-1", "--context", context) helper.CmdShouldPass("odo", "storage", "create", "storage-1", "--size", "1Gi", "--path", "/data1", "--context", context) diff --git a/tests/integration/debug/cmd_debug_test.go b/tests/integration/debug/cmd_debug_test.go index 3d350e0414f..315d1990402 100644 --- a/tests/integration/debug/cmd_debug_test.go +++ b/tests/integration/debug/cmd_debug_test.go @@ -48,7 +48,7 @@ var _ = Describe("odo debug command serial tests", func() { It("should auto-select a local debug port when the given local port is occupied", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "component", "create", "nodejs:latest", "nodejs-cmp-"+namespace, "--project", namespace, "--context", context) + helper.CmdShouldPass("odo", "component", "create", "--s2i", "nodejs:latest", "nodejs-cmp-"+namespace, "--project", namespace, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) stopChannel := make(chan bool) diff --git a/tests/integration/devfile/cmd_devfile_catalog_test.go b/tests/integration/devfile/cmd_devfile_catalog_test.go index 5eb8df20808..04850ace9ff 100644 --- a/tests/integration/devfile/cmd_devfile_catalog_test.go +++ b/tests/integration/devfile/cmd_devfile_catalog_test.go @@ -24,13 +24,17 @@ var _ = Describe("odo devfile catalog command tests", func() { SetDefaultEventuallyTimeout(10 * time.Minute) context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) project = cliRunner.CreateRandNamespaceProject() currentWorkingDirectory = helper.Getwd() helper.Chdir(context) + + // For some reason on TravisCI, there are flakes with regards to registrycachetime and doing + // odo catalog list components. + // TODO: Investigate this more. + helper.CmdShouldPass("odo", "preference", "set", "registrycachetime", "0") }) // This is run after every Spec (It) diff --git a/tests/integration/devfile/cmd_devfile_create_test.go b/tests/integration/devfile/cmd_devfile_create_test.go index 8923c7a8fc0..00273368162 100644 --- a/tests/integration/devfile/cmd_devfile_create_test.go +++ b/tests/integration/devfile/cmd_devfile_create_test.go @@ -25,7 +25,6 @@ var _ = Describe("odo devfile create command tests", func() { SetDefaultEventuallyTimeout(10 * time.Minute) context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() @@ -44,49 +43,6 @@ var _ = Describe("odo devfile create command tests", func() { os.Unsetenv("GLOBALODOCONFIG") }) - Context("Enabling experimental preference should show a disclaimer", func() { - It("checks that the experimental warning appears for create", func() { - helper.CopyExample(filepath.Join("source", "nodejs"), context) - - // Check that it will contain the experimental mode output - experimentalOutputMsg := "Experimental mode is enabled, use at your own risk" - Expect(helper.CmdShouldPass("odo", "create", "nodejs")).To(ContainSubstring(experimentalOutputMsg)) - - }) - }) - - Context("Disabling experimental preference should show a disclaimer", func() { - JustBeforeEach(func() { - if os.Getenv("KUBERNETES") == "true" { - Skip("Skipping test because s2i image is not supported on Kubernetes cluster") - } - }) - It("checks that the experimental warning does *not* appear when Experimental is set to false for create", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "false", "-f") - helper.CopyExample(filepath.Join("source", "nodejs"), context) - - // Check that it will contain the experimental mode output - experimentalOutputMsg := "Experimental mode is enabled, use at your own risk" - Expect(helper.CmdShouldPass("odo", "create", "nodejs")).To(Not(ContainSubstring(experimentalOutputMsg))) - }) - }) - - Context("Disabling experimental preference should error out on providing --s2i flag", func() { - JustBeforeEach(func() { - if os.Getenv("KUBERNETES") == "true" { - Skip("Skipping test because s2i image is not supported on Kubernetes cluster") - } - }) - It("checks that the --s2i flag is unrecognised when Experimental is set to false for create", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "false", "-f") - helper.CopyExample(filepath.Join("source", "nodejs"), context) - - // Check that it will contain the experimental mode output - s2iFlagUnknownMsg := "Error: unknown flag: --s2i" - Expect(helper.CmdShouldFail("odo", "create", "nodejs", "--s2i")).To(ContainSubstring(s2iFlagUnknownMsg)) - }) - }) - Context("When executing odo create with devfile component type argument", func() { It("should successfully create the devfile component", func() { helper.CmdShouldPass("odo", "create", "java-openliberty") @@ -170,20 +126,20 @@ var _ = Describe("odo devfile create command tests", func() { It("should fail the create command as --git flag, which is specific to s2i component creation, is used without --s2i flag", func() { output := helper.CmdShouldFail("odo", "create", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--context", context, "--app", "testing") - Expect(output).Should(ContainSubstring("flag --git, requires --s2i flag to be set, when in experimental mode.")) + Expect(output).Should(ContainSubstring("flag --git, requires --s2i flag to be set, when deploying S2I (Source-to-Image).")) }) It("should fail the create command as --binary flag, which is specific to s2i component creation, is used without --s2i flag", func() { helper.CopyExample(filepath.Join("binary", "java", "openjdk"), context) output := helper.CmdShouldFail("odo", "create", "java:8", "sb-jar-test", "--binary", filepath.Join(context, "sb.jar"), "--context", context) - Expect(output).Should(ContainSubstring("flag --binary, requires --s2i flag to be set, when in experimental mode.")) + Expect(output).Should(ContainSubstring("flag --binary, requires --s2i flag to be set, when deploying S2I (Source-to-Image).")) }) It("should fail the create command as --now flag, which is specific to s2i component creation, is used without --s2i flag", func() { componentName := helper.RandString(6) output := helper.CmdShouldFail("odo", "create", "nodejs", componentName, "--now") - Expect(output).Should(ContainSubstring("flag --now, requires --s2i flag to be set, when in experimental mode.")) + Expect(output).Should(ContainSubstring("flag --now, requires --s2i flag to be set, when deploying S2I (Source-to-Image).")) }) }) diff --git a/tests/integration/devfile/cmd_devfile_debug_test.go b/tests/integration/devfile/cmd_devfile_debug_test.go index 0a880ccac5c..69713ff3876 100644 --- a/tests/integration/devfile/cmd_devfile_debug_test.go +++ b/tests/integration/devfile/cmd_devfile_debug_test.go @@ -29,9 +29,6 @@ var _ = Describe("odo devfile debug command tests", func() { context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - // Devfile push requires experimental mode to be set - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() diff --git a/tests/integration/devfile/cmd_devfile_delete_test.go b/tests/integration/devfile/cmd_devfile_delete_test.go index 6ae6641a74c..cfca19594fe 100644 --- a/tests/integration/devfile/cmd_devfile_delete_test.go +++ b/tests/integration/devfile/cmd_devfile_delete_test.go @@ -25,9 +25,6 @@ var _ = Describe("odo devfile delete command tests", func() { context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - // Devfile commands require experimental mode to be set - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() diff --git a/tests/integration/devfile/cmd_devfile_env_test.go b/tests/integration/devfile/cmd_devfile_env_test.go index 86a6f4a0a15..690062590fd 100644 --- a/tests/integration/devfile/cmd_devfile_env_test.go +++ b/tests/integration/devfile/cmd_devfile_env_test.go @@ -28,7 +28,6 @@ var _ = Describe("odo devfile env command tests", func() { SetDefaultEventuallyTimeout(10 * time.Minute) context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) diff --git a/tests/integration/devfile/cmd_devfile_exec_test.go b/tests/integration/devfile/cmd_devfile_exec_test.go index 79438667613..66baa5e59b8 100644 --- a/tests/integration/devfile/cmd_devfile_exec_test.go +++ b/tests/integration/devfile/cmd_devfile_exec_test.go @@ -29,9 +29,6 @@ var _ = Describe("odo devfile exec command tests", func() { os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - // Devfile push requires experimental mode to be set - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() diff --git a/tests/integration/devfile/cmd_devfile_log_test.go b/tests/integration/devfile/cmd_devfile_log_test.go index 88233f6571a..cce3923110c 100644 --- a/tests/integration/devfile/cmd_devfile_log_test.go +++ b/tests/integration/devfile/cmd_devfile_log_test.go @@ -23,9 +23,6 @@ var _ = Describe("odo devfile log command tests", func() { context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - // Devfile push requires experimental mode to be set - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() diff --git a/tests/integration/devfile/cmd_devfile_push_test.go b/tests/integration/devfile/cmd_devfile_push_test.go index 13012d4162b..218b6913543 100644 --- a/tests/integration/devfile/cmd_devfile_push_test.go +++ b/tests/integration/devfile/cmd_devfile_push_test.go @@ -31,9 +31,6 @@ var _ = Describe("odo devfile push command tests", func() { context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - // Devfile push requires experimental mode to be set - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() @@ -897,7 +894,6 @@ var _ = Describe("odo devfile push command tests", func() { Expect(output).To(ContainSubstring(cmpName)) Expect(output).To(ContainSubstring(cmpName2)) - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "false") helper.DeleteDir(context2) }) @@ -923,15 +919,12 @@ var _ = Describe("odo devfile push command tests", func() { context2 := helper.CreateNewContext() cmpName2 := helper.RandString(6) appName := helper.RandString(6) - helper.CmdShouldPass("odo", "preference", "set", "--force", "Experimental", "false") helper.CopyExample(filepath.Join("source", "nodejs"), context2) helper.CmdShouldPass("odo", "create", "nodejs", "--project", namespace, "--app", appName, "--context", context2, cmpName2) output2 := helper.CmdShouldPass("odo", "push", "--context", context2) Expect(output2).To(ContainSubstring("Changes successfully pushed to component")) - helper.CmdShouldPass("odo", "preference", "set", "--force", "Experimental", "true") - output = helper.CmdShouldPass("odo", "list", "--all-apps", "--project", namespace) Expect(output).To(ContainSubstring(cmpName)) diff --git a/tests/integration/devfile/cmd_devfile_registry_test.go b/tests/integration/devfile/cmd_devfile_registry_test.go index 05c9b7c39fa..e69f4b5806d 100644 --- a/tests/integration/devfile/cmd_devfile_registry_test.go +++ b/tests/integration/devfile/cmd_devfile_registry_test.go @@ -24,8 +24,6 @@ var _ = Describe("odo devfile registry command tests", func() { SetDefaultEventuallyTimeout(10 * time.Minute) context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) project = cliRunner.CreateRandNamespaceProject() diff --git a/tests/integration/devfile/cmd_devfile_storage_test.go b/tests/integration/devfile/cmd_devfile_storage_test.go index dcb6633c349..2c7b68cd936 100644 --- a/tests/integration/devfile/cmd_devfile_storage_test.go +++ b/tests/integration/devfile/cmd_devfile_storage_test.go @@ -27,9 +27,6 @@ var _ = Describe("odo devfile storage command tests", func() { os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - // Devfile push requires experimental mode to be set - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() diff --git a/tests/integration/devfile/cmd_devfile_test_test.go b/tests/integration/devfile/cmd_devfile_test_test.go index c418fef44ff..d1ef8022107 100644 --- a/tests/integration/devfile/cmd_devfile_test_test.go +++ b/tests/integration/devfile/cmd_devfile_test_test.go @@ -22,8 +22,6 @@ var _ = Describe("odo devfile test command tests", func() { SetDefaultEventuallyTimeout(10 * time.Minute) context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() diff --git a/tests/integration/devfile/cmd_devfile_url_test.go b/tests/integration/devfile/cmd_devfile_url_test.go index 4cdd53b65e9..5de8a1eb619 100644 --- a/tests/integration/devfile/cmd_devfile_url_test.go +++ b/tests/integration/devfile/cmd_devfile_url_test.go @@ -31,9 +31,6 @@ var _ = Describe("odo devfile url command tests", func() { currentWorkingDirectory = helper.Getwd() componentName = helper.RandString(6) helper.Chdir(context) - - // Devfile push requires experimental mode to be set - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") }) // Clean up after the test diff --git a/tests/integration/devfile/cmd_devfile_watch_test.go b/tests/integration/devfile/cmd_devfile_watch_test.go index daa124d8624..5f6a1815786 100644 --- a/tests/integration/devfile/cmd_devfile_watch_test.go +++ b/tests/integration/devfile/cmd_devfile_watch_test.go @@ -36,9 +36,6 @@ var _ = Describe("odo devfile watch command tests", func() { currentWorkingDirectory = helper.Getwd() cmpName = helper.RandString(6) helper.Chdir(context) - - // Set experimental mode to true - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") }) // Clean up after the test diff --git a/tests/integration/devfile/debug/cmd_devfile_debug_test.go b/tests/integration/devfile/debug/cmd_devfile_debug_test.go index ae35ab105d5..5effc36c672 100644 --- a/tests/integration/devfile/debug/cmd_devfile_debug_test.go +++ b/tests/integration/devfile/debug/cmd_devfile_debug_test.go @@ -38,9 +38,6 @@ var _ = Describe("odo devfile debug command serial tests", func() { context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) - // Devfile push requires experimental mode to be set - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") - originalKubeconfig = os.Getenv("KUBECONFIG") helper.LocalKubeconfigSet(context) namespace = cliRunner.CreateRandNamespaceProject() diff --git a/tests/integration/generic_test.go b/tests/integration/generic_test.go index e39db92ffa7..e31b793b1c0 100644 --- a/tests/integration/generic_test.go +++ b/tests/integration/generic_test.go @@ -137,7 +137,7 @@ var _ = Describe("odo generic", func() { os.Unsetenv("GLOBALODOCONFIG") }) It("should create the component in default application", func() { - helper.CmdShouldPass("odo", "create", "php", "testcmp", "--app", "e2e-xyzk", "--project", project, "--git", testPHPGitURL) + helper.CmdShouldPass("odo", "create", "--s2i", "php", "testcmp", "--app", "e2e-xyzk", "--project", project, "--git", testPHPGitURL) helper.CmdShouldPass("odo", "config", "set", "Ports", "8080/TCP", "-f") helper.CmdShouldPass("odo", "push") oc.VerifyCmpName("testcmp", project) @@ -162,7 +162,7 @@ var _ = Describe("odo generic", func() { os.Unsetenv("GLOBALODOCONFIG") }) It("should pass to build component if the given build timeout is more than the default(300s) value", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--project", project, "--git", testNodejsGitURL) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--project", project, "--git", testNodejsGitURL) helper.CmdShouldPass("odo", "preference", "set", "BuildTimeout", "600") buildTimeout := helper.GetPreferenceValue("BuildTimeout") helper.MatchAllInOutput(buildTimeout, []string{"600"}) @@ -170,7 +170,7 @@ var _ = Describe("odo generic", func() { }) It("should fail to build component if the given build timeout is pretty less(2s)", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--project", project, "--git", testNodejsGitURL) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--project", project, "--git", testNodejsGitURL) helper.CmdShouldPass("odo", "preference", "set", "BuildTimeout", "2") buildTimeout := helper.GetPreferenceValue("BuildTimeout") helper.MatchAllInOutput(buildTimeout, []string{"2"}) @@ -192,7 +192,7 @@ var _ = Describe("odo generic", func() { os.Unsetenv("GLOBALODOCONFIG") }) It("should be able to create a php component with application created", func() { - helper.CmdShouldPass("odo", "create", "php", "testcmp", "--app", "testing", "--project", project, "--ref", "master", "--git", testPHPGitURL, "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "php", "testcmp", "--app", "testing", "--project", project, "--ref", "master", "--git", testPHPGitURL, "--context", context) helper.CmdShouldPass("odo", "push", "--context", context) currentProject := helper.CreateRandProject() currentAppNames := helper.CmdShouldPass("odo", "app", "list", "--project", currentProject) @@ -217,7 +217,7 @@ var _ = Describe("odo generic", func() { }) It("should be able to push changes", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "create", "nodejs", "nodejs", "--project", project, "--context", context) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "nodejs", "--project", project, "--context", context) // Push the changes with --show-log getLogging := helper.CmdShouldPass("odo", "push", "--show-log", "--context", context) @@ -239,7 +239,7 @@ var _ = Describe("odo generic", func() { }) It("should deploy the component", func() { helper.CmdShouldPass("git", "clone", "https://github.com/openshift/nodejs-ex", context+"/nodejs-ex") - helper.CmdShouldPass("odo", "create", "nodejs:latest", "testversioncmp", "--project", project, "--context", context+"/nodejs-ex") + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs:latest", "testversioncmp", "--project", project, "--context", context+"/nodejs-ex") helper.CmdShouldPass("odo", "push", "--context", context+"/nodejs-ex") helper.CmdShouldPass("odo", "delete", "-f", "--context", context+"/nodejs-ex") }) @@ -316,7 +316,7 @@ var _ = Describe("odo generic", func() { os.Unsetenv("GLOBALODOCONFIG") }) It("should not allow creating a URL with long name", func() { - helper.CmdShouldPass("odo", "create", "nodejs", "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--project", project) stdOut := helper.CmdShouldFail("odo", "url", "create", testLongURLName, "--port", "8080") Expect(stdOut).To(ContainSubstring("must be shorter than 63 characters")) }) @@ -342,7 +342,7 @@ var _ = Describe("odo generic", func() { }) It("should delete all OpenShift objects except the component's imagestream", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "create", "nodejs", componentRandomName, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", componentRandomName, "--project", project) helper.CmdShouldPass("odo", "push") // Delete the deployment config using oc delete @@ -416,7 +416,7 @@ var _ = Describe("odo generic", func() { } for _, testCase := range cases { helper.CopyExample(filepath.Join("source", "nodejs"), context) - output := helper.CmdShouldFail("odo", "component", "create", "nodejs", cmpName, "--project", project, "--context", context, "--"+testCase.paramName, testCase.paramValue) + output := helper.CmdShouldFail("odo", "component", "create", "--s2i", "nodejs", cmpName, "--project", project, "--context", context, "--"+testCase.paramName, testCase.paramValue) Expect(output).To(ContainSubstring("unknown flag: --" + testCase.paramName)) } }) diff --git a/tests/integration/servicecatalog/cmd_service_test.go b/tests/integration/servicecatalog/cmd_service_test.go index 47a323b4ef3..42468f247db 100644 --- a/tests/integration/servicecatalog/cmd_service_test.go +++ b/tests/integration/servicecatalog/cmd_service_test.go @@ -148,7 +148,7 @@ var _ = Describe("odo service command tests", func() { helper.CopyExample(filepath.Join("source", "openjdk-sb-postgresql"), context) // Local config needs to be present in order to create service https://github.com/openshift/odo/issues/1602 - helper.CmdShouldPass("odo", "create", "java:8", "sb-app", "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "java:8", "sb-app", "--project", project) // Create a URL helper.CmdShouldPass("odo", "url", "create", "--port", "8080") @@ -213,7 +213,7 @@ var _ = Describe("odo service command tests", func() { It("should be able to create, list and delete a service using a given value for --context", func() { // create a component by copying the example helper.CopyExample(filepath.Join("source", "python"), context) - helper.CmdShouldPass("odo", "create", "python", "--app", app, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "python", "--app", app, "--project", project) // cd to the originalDir to create service using --context helper.Chdir(originalDir) @@ -239,7 +239,7 @@ var _ = Describe("odo service command tests", func() { It("should be able to list services, as well as json list in a given app and project combination", func() { // create a component by copying the example helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", "create", "nodejs", "--app", app, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "--app", app, "--project", project) // create a service from within a component directory helper.CmdShouldPass("odo", "service", "create", "dh-prometheus-apb", "--plan", "ephemeral", @@ -304,10 +304,10 @@ var _ = Describe("odo service command tests", func() { }) It("should link backend to service successfully", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context1) - helper.CmdShouldPass("odo", "create", "nodejs", "frontend", "--context", context1, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "frontend", "--context", context1, "--project", project) helper.CmdShouldPass("odo", "push", "--context", context1) helper.CopyExample(filepath.Join("source", "python"), context2) - helper.CmdShouldPass("odo", "create", "python", "backend", "--context", context2, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "python", "backend", "--context", context2, "--project", project) helper.CmdShouldPass("odo", "push", "--context", context2) helper.CmdShouldPass("odo", "link", "backend", "--context", context1) // Switching to context2 dir because --context flag is not supported with service command @@ -336,10 +336,10 @@ var _ = Describe("odo service command tests", func() { }) It("should pass", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context1) - helper.CmdShouldPass("odo", "create", "nodejs", "frontend", "--context", context1, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "frontend", "--context", context1, "--project", project) helper.CmdShouldPass("odo", "push", "--context", context1) helper.CopyExample(filepath.Join("source", "python"), context2) - helper.CmdShouldPass("odo", "create", "python", "backend", "--context", context2, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "python", "backend", "--context", context2, "--project", project) helper.CmdShouldPass("odo", "push", "--context", context2) helper.CmdShouldPass("odo", "link", "backend", "--context", context1) helper.Chdir(context2) @@ -373,10 +373,10 @@ var _ = Describe("odo service command tests", func() { It("should print the environment variables being linked/unlinked", func() { helper.CopyExample(filepath.Join("source", "python"), context1) - helper.CmdShouldPass("odo", "create", "python", "component1", "--context", context1, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "python", "component1", "--context", context1, "--project", project) helper.CmdShouldPass("odo", "push", "--context", context1) helper.CopyExample(filepath.Join("source", "nodejs"), context2) - helper.CmdShouldPass("odo", "create", "nodejs", "component2", "--context", context2, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "nodejs", "component2", "--context", context2, "--project", project) helper.CmdShouldPass("odo", "push", "--context", context2) // tests for linking a component to a component @@ -417,7 +417,7 @@ var _ = Describe("odo service command tests", func() { It("should succeed when we're describing service that could have integer value for default field", func() { // https://github.com/openshift/odo/issues/2488 helper.CopyExample(filepath.Join("source", "python"), context) - helper.CmdShouldPass("odo", "create", "python", "component1", "--context", context, "--project", project) + helper.CmdShouldPass("odo", "create", "--s2i", "python", "component1", "--context", context, "--project", project) helper.Chdir(context) helper.CmdShouldPass("odo", "catalog", "describe", "service", "dh-es-apb")