mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Fixes odo url list for s2i components (#3728)
* Fixes odo url list for s2i components * Renames odoUtil to odoutil
This commit is contained in:
@@ -3,6 +3,7 @@ package url
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"text/tabwriter"
|
||||
|
||||
@@ -18,10 +19,12 @@ import (
|
||||
"github.com/openshift/odo/pkg/lclient"
|
||||
"github.com/openshift/odo/pkg/log"
|
||||
"github.com/openshift/odo/pkg/machineoutput"
|
||||
"github.com/openshift/odo/pkg/odo/cli/component"
|
||||
"github.com/openshift/odo/pkg/odo/genericclioptions"
|
||||
"github.com/openshift/odo/pkg/odo/util"
|
||||
odoutil "github.com/openshift/odo/pkg/odo/util"
|
||||
"github.com/openshift/odo/pkg/odo/util/completion"
|
||||
"github.com/openshift/odo/pkg/url"
|
||||
"github.com/openshift/odo/pkg/util"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
ktemplates "k8s.io/kubectl/pkg/util/templates"
|
||||
@@ -41,6 +44,8 @@ var (
|
||||
type URLListOptions struct {
|
||||
componentContext string
|
||||
*genericclioptions.Context
|
||||
|
||||
isDevfile bool
|
||||
}
|
||||
|
||||
// NewURLListOptions creates a new URLCreateOptions instance
|
||||
@@ -50,7 +55,8 @@ func NewURLListOptions() *URLListOptions {
|
||||
|
||||
// Complete completes URLListOptions after they've been Listed
|
||||
func (o *URLListOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) {
|
||||
if experimental.IsExperimentalModeEnabled() {
|
||||
o.isDevfile = util.CheckPathExists(filepath.Join(o.componentContext, component.DevfilePath))
|
||||
if o.isDevfile {
|
||||
o.Context = genericclioptions.NewDevfileContext(cmd)
|
||||
o.EnvSpecificInfo, err = envinfo.NewEnvSpecificInfo(o.componentContext)
|
||||
} else {
|
||||
@@ -65,12 +71,12 @@ func (o *URLListOptions) Complete(name string, cmd *cobra.Command, args []string
|
||||
|
||||
// Validate validates the URLListOptions based on completed values
|
||||
func (o *URLListOptions) Validate() (err error) {
|
||||
return util.CheckOutputFlag(o.OutputFlag)
|
||||
return odoutil.CheckOutputFlag(o.OutputFlag)
|
||||
}
|
||||
|
||||
// Run contains the logic for the odo url list command
|
||||
func (o *URLListOptions) Run() (err error) {
|
||||
if experimental.IsExperimentalModeEnabled() {
|
||||
if o.isDevfile {
|
||||
if pushtarget.IsPushTargetDocker() {
|
||||
componentName := o.EnvSpecificInfo.GetName()
|
||||
client, err := lclient.New()
|
||||
|
||||
@@ -394,5 +394,21 @@ var _ = Describe("odo devfile url command tests", func() {
|
||||
output := helper.CmdShouldPass("oc", "get", "routes", "--namespace", namespace)
|
||||
Expect(output).Should(ContainSubstring(url1))
|
||||
})
|
||||
|
||||
// remove once https://github.com/openshift/odo/issues/3550 is resolved
|
||||
It("should list URLs for s2i components", func() {
|
||||
url1 := helper.RandString(5)
|
||||
url2 := helper.RandString(5)
|
||||
|
||||
componentName := helper.RandString(6)
|
||||
helper.CopyExample(filepath.Join("source", "nodejs"), context)
|
||||
helper.CmdShouldPass("odo", "create", "nodejs", "--context", context, "--project", namespace, componentName, "--s2i")
|
||||
|
||||
helper.CmdShouldPass("odo", "url", "create", url1, "--port", "8080", "--context", context)
|
||||
helper.CmdShouldPass("odo", "url", "create", url2, "--port", "8080", "--context", context, "--ingress", "--host", "com")
|
||||
|
||||
stdout := helper.CmdShouldPass("odo", "url", "list", "--context", context)
|
||||
helper.MatchAllInOutput(stdout, []string{url1, url2})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user