mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Add a Devfile dependency for commands (#7063)
* Define Devfile dependency for commands * Remove MarkDevfileNotNeeded * More commands not using Devfile * Tests with invalid devfiles
This commit is contained in:
@@ -35,6 +35,10 @@ func (o *AlizerOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *AlizerOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (o *AlizerOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *AlizerOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -80,7 +84,6 @@ func NewCmdAlizer(name, fullName string, testClientset clientset.Clientset) *cob
|
|||||||
}
|
}
|
||||||
clientset.Add(alizerCmd, clientset.ALIZER, clientset.FILESYSTEM)
|
clientset.Add(alizerCmd, clientset.ALIZER, clientset.FILESYSTEM)
|
||||||
util.SetCommandGroup(alizerCmd, util.UtilityGroup)
|
util.SetCommandGroup(alizerCmd, util.UtilityGroup)
|
||||||
genericclioptions.MarkDevfileNotNeeded(alizerCmd)
|
|
||||||
commonflags.UseOutputFlag(alizerCmd)
|
commonflags.UseOutputFlag(alizerCmd)
|
||||||
alizerCmd.SetUsageTemplate(odoutil.CmdUsageTemplate)
|
alizerCmd.SetUsageTemplate(odoutil.CmdUsageTemplate)
|
||||||
return alizerCmd
|
return alizerCmd
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ func (o *ComponentOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ComponentOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return o.name == ""
|
||||||
|
}
|
||||||
|
|
||||||
func (o *ComponentOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *ComponentOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
switch api.RunningMode(o.runningInFlag) {
|
switch api.RunningMode(o.runningInFlag) {
|
||||||
case api.RunningModeDev:
|
case api.RunningModeDev:
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ func (o *BindingOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *BindingOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return o.nameFlag == ""
|
||||||
|
}
|
||||||
|
|
||||||
func (o *BindingOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *BindingOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
if o.nameFlag == "" {
|
if o.nameFlag == "" {
|
||||||
devfileObj := odocontext.GetEffectiveDevfileObj(ctx)
|
devfileObj := odocontext.GetEffectiveDevfileObj(ctx)
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ func (o *ComponentOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ComponentOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return o.nameFlag == ""
|
||||||
|
}
|
||||||
|
|
||||||
func (o *ComponentOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *ComponentOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
platform := fcontext.GetPlatform(ctx, commonflags.PlatformCluster)
|
platform := fcontext.GetPlatform(ctx, commonflags.PlatformCluster)
|
||||||
|
|
||||||
@@ -329,7 +333,7 @@ func NewCmdComponent(ctx context.Context, name, fullName string, testClientset c
|
|||||||
}
|
}
|
||||||
componentCmd.Flags().StringVar(&o.nameFlag, "name", "", "Name of the component to describe, optional. By default, the component in the local devfile is described")
|
componentCmd.Flags().StringVar(&o.nameFlag, "name", "", "Name of the component to describe, optional. By default, the component in the local devfile is described")
|
||||||
componentCmd.Flags().StringVar(&o.namespaceFlag, "namespace", "", "Namespace in which to find the component to describe, optional. By default, the current namespace defined in kubeconfig is used")
|
componentCmd.Flags().StringVar(&o.namespaceFlag, "namespace", "", "Namespace in which to find the component to describe, optional. By default, the current namespace defined in kubeconfig is used")
|
||||||
clientset.Add(componentCmd, clientset.KUBERNETES_NULLABLE, clientset.STATE)
|
clientset.Add(componentCmd, clientset.KUBERNETES_NULLABLE, clientset.STATE, clientset.FILESYSTEM)
|
||||||
if feature.IsEnabled(ctx, feature.GenericPlatformFlag) {
|
if feature.IsEnabled(ctx, feature.GenericPlatformFlag) {
|
||||||
clientset.Add(componentCmd, clientset.PODMAN_NULLABLE)
|
clientset.Add(componentCmd, clientset.PODMAN_NULLABLE)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ func (o *InitOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *InitOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Complete will build the parameters for init, using different backends based on the flags set,
|
// Complete will build the parameters for init, using different backends based on the flags set,
|
||||||
// either by using flags or interactively if no flag is passed
|
// either by using flags or interactively if no flag is passed
|
||||||
// Complete will return an error immediately if the current working directory is not empty
|
// Complete will return an error immediately if the current working directory is not empty
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ func (o *ServiceListOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ServiceListOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (o *ServiceListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, _ []string) error {
|
func (o *ServiceListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, _ []string) error {
|
||||||
if o.namespaceFlag == "" && !o.allNamespacesFlag {
|
if o.namespaceFlag == "" && !o.allNamespacesFlag {
|
||||||
o.namespaceFlag = odocontext.GetNamespace(ctx)
|
o.namespaceFlag = odocontext.GetNamespace(ctx)
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ func (o *RegistryOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *RegistryOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Complete completes RegistryOptions after they've been created
|
// Complete completes RegistryOptions after they've been created
|
||||||
func (o *RegistryOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *RegistryOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
o.operation = "add"
|
o.operation = "add"
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ func (o *RegistryOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *RegistryOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Complete completes RegistryOptions after they've been created
|
// Complete completes RegistryOptions after they've been created
|
||||||
func (o *RegistryOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *RegistryOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
o.operation = "remove"
|
o.operation = "remove"
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ func (o *SetOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *SetOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Complete completes SetOptions after they've been created
|
// Complete completes SetOptions after they've been created
|
||||||
func (o *SetOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *SetOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
o.paramName = strings.ToLower(args[0])
|
o.paramName = strings.ToLower(args[0])
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ func (o *UnsetOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *UnsetOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Complete completes UnsetOptions after they've been created
|
// Complete completes UnsetOptions after they've been created
|
||||||
func (o *UnsetOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *UnsetOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
o.paramName = strings.ToLower(args[0])
|
o.paramName = strings.ToLower(args[0])
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ func (o *ViewOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ViewOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Complete completes ViewOptions after they've been created
|
// Complete completes ViewOptions after they've been created
|
||||||
func (o *ViewOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *ViewOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ func (o *ListOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
o.clientset = clientset
|
o.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ListOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Complete completes ListOptions after they've been created
|
// Complete completes ListOptions after they've been created
|
||||||
func (o *ListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (o *ListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ func (so *SetOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
so.clientset = clientset
|
so.clientset = clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *SetOptions) UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Complete completes SetOptions after they've been created
|
// Complete completes SetOptions after they've been created
|
||||||
func (so *SetOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (so *SetOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
so.namespaceName = args[0]
|
so.namespaceName = args[0]
|
||||||
|
|||||||
@@ -15,17 +15,6 @@ import (
|
|||||||
odoutil "github.com/redhat-developer/odo/pkg/util"
|
odoutil "github.com/redhat-developer/odo/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MarkDevfileNotNeeded annotates the provided command such that it does not require a valid Devfile
|
|
||||||
// to be present in the current directory.
|
|
||||||
// A corollary to this is that commands annotated as such will not have any Devfile parsed in their root context,
|
|
||||||
// even if there is a local "devfile.yaml" in the current directory.
|
|
||||||
func MarkDevfileNotNeeded(cmd *cobra.Command) {
|
|
||||||
if cmd.Annotations == nil {
|
|
||||||
cmd.Annotations = map[string]string{}
|
|
||||||
}
|
|
||||||
cmd.Annotations["devfile-not-needed"] = "true"
|
|
||||||
}
|
|
||||||
|
|
||||||
func getDevfileInfo(cmd *cobra.Command, fsys filesystem.Filesystem, workingDir string, variables map[string]string, imageRegistry string) (
|
func getDevfileInfo(cmd *cobra.Command, fsys filesystem.Filesystem, workingDir string, variables map[string]string, imageRegistry string) (
|
||||||
devfilePath string,
|
devfilePath string,
|
||||||
devfileObj *parser.DevfileObj,
|
devfileObj *parser.DevfileObj,
|
||||||
@@ -34,8 +23,7 @@ func getDevfileInfo(cmd *cobra.Command, fsys filesystem.Filesystem, workingDir s
|
|||||||
) {
|
) {
|
||||||
devfilePath = location.DevfileLocation(fsys, workingDir)
|
devfilePath = location.DevfileLocation(fsys, workingDir)
|
||||||
isDevfile := odoutil.CheckPathExists(fsys, devfilePath)
|
isDevfile := odoutil.CheckPathExists(fsys, devfilePath)
|
||||||
requiresValidDevfile := cmd.Annotations["devfile-not-needed"] != "true"
|
if isDevfile {
|
||||||
if requiresValidDevfile && isDevfile {
|
|
||||||
devfilePath, err = dfutil.GetAbsPath(devfilePath)
|
devfilePath, err = dfutil.GetAbsPath(devfilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, "", err
|
return "", nil, "", err
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ type JsonOutputter interface {
|
|||||||
RunForJsonOutput(ctx context.Context) (result interface{}, err error)
|
RunForJsonOutput(ctx context.Context) (result interface{}, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DevfileUser must be implemented by commands that use Devfile depending on arguments, or
|
||||||
|
// commands that depend on FS but do not use Devfile.
|
||||||
|
// If the interface is not implemented and the command depends on FS, the command is expected to use Devfile
|
||||||
|
type DevfileUser interface {
|
||||||
|
// UseDevfile returns true if the command with the specified cmdline and args needs to have access to the Devfile
|
||||||
|
UseDevfile(ctx context.Context, cmdline cmdline.Cmdline, args []string) bool
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// defaultAppName is the default name of the application when an application name is not provided
|
// defaultAppName is the default name of the application when an application name is not provided
|
||||||
defaultAppName = "app"
|
defaultAppName = "app"
|
||||||
@@ -248,16 +256,23 @@ func GenericRun(o Runnable, testClientset clientset.Clientset, cmd *cobra.Comman
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var devfilePath, componentName string
|
useDevfile := true
|
||||||
var devfileObj *parser.DevfileObj
|
if devfileUser, ok := o.(DevfileUser); ok {
|
||||||
devfilePath, devfileObj, componentName, err = getDevfileInfo(cmd, deps.FS, cwd, variables, userConfig.GetImageRegistry())
|
useDevfile = devfileUser.UseDevfile(ctx, cmdLineObj, args)
|
||||||
if err != nil {
|
}
|
||||||
startTelemetry(cmd, err, startTime)
|
|
||||||
return err
|
if useDevfile {
|
||||||
|
var devfilePath, componentName string
|
||||||
|
var devfileObj *parser.DevfileObj
|
||||||
|
devfilePath, devfileObj, componentName, err = getDevfileInfo(cmd, deps.FS, cwd, variables, userConfig.GetImageRegistry())
|
||||||
|
if err != nil {
|
||||||
|
startTelemetry(cmd, err, startTime)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ctx = odocontext.WithDevfilePath(ctx, devfilePath)
|
||||||
|
ctx = odocontext.WithEffectiveDevfileObj(ctx, devfileObj)
|
||||||
|
ctx = odocontext.WithComponentName(ctx, componentName)
|
||||||
}
|
}
|
||||||
ctx = odocontext.WithDevfilePath(ctx, devfilePath)
|
|
||||||
ctx = odocontext.WithEffectiveDevfileObj(ctx, devfileObj)
|
|
||||||
ctx = odocontext.WithComponentName(ctx, componentName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run completion, validation and run.
|
// Run completion, validation and run.
|
||||||
|
|||||||
@@ -319,3 +319,15 @@ func AppendToFile(filepath string, s string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateInvalidDevfile(dir string) {
|
||||||
|
devfilePath := filepath.Join(dir, "devfile.yaml")
|
||||||
|
err := CreateFileWithContent(devfilePath, "invalid")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteInvalidDevfile(dir string) {
|
||||||
|
devfilePath := filepath.Join(dir, "devfile.yaml")
|
||||||
|
err := os.Remove(devfilePath)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
}
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ var _ = Describe("odo delete command tests", func() {
|
|||||||
Eventually(string(commonVar.CliRunner.Run(getSVCArgs...).Out.Contents()), 60, 3).ShouldNot(ContainSubstring(serviceName))
|
Eventually(string(commonVar.CliRunner.Run(getSVCArgs...).Out.Contents()), 60, 3).ShouldNot(ContainSubstring(serviceName))
|
||||||
})
|
})
|
||||||
It("should output that there are no resources to be deleted", func() {
|
It("should output that there are no resources to be deleted", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
|
helper.Chdir(commonVar.Context)
|
||||||
args := []string{"delete", "component", "--name", cmpName, "--namespace", commonVar.Project}
|
args := []string{"delete", "component", "--name", cmpName, "--namespace", commonVar.Project}
|
||||||
if runningIn != "" {
|
if runningIn != "" {
|
||||||
args = append(args, "--running-in", runningIn)
|
args = append(args, "--running-in", runningIn)
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
|
|
||||||
It("should fail, with default cluster mode", func() {
|
It("should fail, with default cluster mode", func() {
|
||||||
By("running odo describe component -o json with an unknown name", func() {
|
By("running odo describe component -o json with an unknown name", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "-o", "json").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "-o", "json").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
||||||
@@ -77,6 +78,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("running odo describe component with an unknown name", func() {
|
By("running odo describe component with an unknown name", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
Expect(stdout).To(BeEmpty())
|
Expect(stdout).To(BeEmpty())
|
||||||
@@ -86,6 +88,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
|
|
||||||
It("should fail, with cluster", func() {
|
It("should fail, with cluster", func() {
|
||||||
By("running odo describe component -o json with an unknown name", func() {
|
By("running odo describe component -o json with an unknown name", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "cluster", "-o", "json").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "cluster", "-o", "json").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
||||||
@@ -94,6 +97,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("running odo describe component with an unknown name", func() {
|
By("running odo describe component with an unknown name", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "cluster").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "cluster").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
Expect(stdout).To(BeEmpty())
|
Expect(stdout).To(BeEmpty())
|
||||||
@@ -103,6 +107,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
|
|
||||||
It("should fail, with podman", Label(helper.LabelPodman), func() {
|
It("should fail, with podman", Label(helper.LabelPodman), func() {
|
||||||
By("running odo describe component -o json with an unknown name", func() {
|
By("running odo describe component -o json with an unknown name", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "podman", "-o", "json").
|
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "podman", "-o", "json").
|
||||||
ShouldFail()
|
ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
@@ -112,6 +117,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("running odo describe component with an unknown name", func() {
|
By("running odo describe component with an unknown name", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
stderr := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "podman").
|
stderr := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "--platform", "podman").
|
||||||
ShouldFail().Err()
|
ShouldFail().Err()
|
||||||
Expect(stderr).To(ContainSubstring("no component found with name \"unknown-name\""))
|
Expect(stderr).To(ContainSubstring("no component found with name \"unknown-name\""))
|
||||||
@@ -257,8 +263,10 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
|
|
||||||
It("should not describe the component from another directory, with default cluster mode", func() {
|
It("should not describe the component from another directory, with default cluster mode", func() {
|
||||||
By("running with json output", func() {
|
By("running with json output", func() {
|
||||||
err := os.Chdir("/")
|
otherDir := filepath.Join(commonVar.Context, "tmp")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
helper.MakeDir(otherDir)
|
||||||
|
helper.Chdir(otherDir)
|
||||||
|
helper.CreateInvalidDevfile(otherDir)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", cmpName, "-o", "json").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", cmpName, "-o", "json").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
||||||
@@ -267,8 +275,10 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("running with default output", func() {
|
By("running with default output", func() {
|
||||||
err := os.Chdir("/")
|
otherDir := filepath.Join(commonVar.Context, "tmp")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
helper.MakeDir(otherDir)
|
||||||
|
helper.Chdir(otherDir)
|
||||||
|
helper.CreateInvalidDevfile(otherDir)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", cmpName).ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", cmpName).ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
Expect(stdout).To(BeEmpty())
|
Expect(stdout).To(BeEmpty())
|
||||||
@@ -278,8 +288,10 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
|
|
||||||
It("should not describe the component from another directory, with cluster", func() {
|
It("should not describe the component from another directory, with cluster", func() {
|
||||||
By("running with json output", func() {
|
By("running with json output", func() {
|
||||||
err := os.Chdir("/")
|
otherDir := filepath.Join(commonVar.Context, "tmp")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
helper.MakeDir(otherDir)
|
||||||
|
helper.Chdir(otherDir)
|
||||||
|
helper.CreateInvalidDevfile(otherDir)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", cmpName, "-o", "json", "--platform", "cluster").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", cmpName, "-o", "json", "--platform", "cluster").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
||||||
@@ -288,8 +300,10 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("running with default output", func() {
|
By("running with default output", func() {
|
||||||
err := os.Chdir("/")
|
otherDir := filepath.Join(commonVar.Context, "tmp")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
helper.MakeDir(otherDir)
|
||||||
|
helper.Chdir(otherDir)
|
||||||
|
helper.CreateInvalidDevfile(otherDir)
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", cmpName, "--platform", "cluster").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", cmpName, "--platform", "cluster").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
Expect(stdout).To(BeEmpty())
|
Expect(stdout).To(BeEmpty())
|
||||||
@@ -547,10 +561,12 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
By("checking the human readable output with component name", func() {
|
By("checking the human readable output with component name", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
out := helper.Cmd("odo", "describe", "component", "--name", componentName).ShouldPass().Out()
|
out := helper.Cmd("odo", "describe", "component", "--name", componentName).ShouldPass().Out()
|
||||||
helper.MatchAllInOutput(out, ctx.matchOutput)
|
helper.MatchAllInOutput(out, ctx.matchOutput)
|
||||||
})
|
})
|
||||||
By("checking the machine readable output with component name", func() {
|
By("checking the machine readable output with component name", func() {
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
out := helper.Cmd("odo", "describe", "component", "--name", componentName, "-o", "json").ShouldPass().Out()
|
out := helper.Cmd("odo", "describe", "component", "--name", componentName, "-o", "json").ShouldPass().Out()
|
||||||
for key, value := range ctx.matchJSONOutput {
|
for key, value := range ctx.matchJSONOutput {
|
||||||
helper.JsonPathContentContain(out, key, value)
|
helper.JsonPathContentContain(out, key, value)
|
||||||
|
|||||||
@@ -737,9 +737,11 @@ var _ = Describe("odo describe/list binding command tests", func() {
|
|||||||
ctx.assertDescribeAllHumanReadableOutput(stdout, stderr)
|
ctx.assertDescribeAllHumanReadableOutput(stdout, stderr)
|
||||||
})
|
})
|
||||||
|
|
||||||
By("JSON output from another directory with name flag", func() {
|
By("JSON output from another directory with name flag and invalid devfile", func() {
|
||||||
err := os.Chdir("/")
|
otherDir := filepath.Join(commonVar.Context, "tmp")
|
||||||
Expect(err).ToNot(HaveOccurred())
|
helper.MakeDir(otherDir)
|
||||||
|
helper.Chdir(otherDir)
|
||||||
|
helper.CreateInvalidDevfile(otherDir)
|
||||||
res := helper.Cmd("odo", "describe", "binding", "--name", "my-nodejs-app-cluster-sample-k8s", "-o", "json").ShouldPass()
|
res := helper.Cmd("odo", "describe", "binding", "--name", "my-nodejs-app-cluster-sample-k8s", "-o", "json").ShouldPass()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
ctx.assertDescribeNamedJsonOutput(stdout, stderr, "my-nodejs-app-cluster-sample-k8s")
|
ctx.assertDescribeNamedJsonOutput(stdout, stderr, "my-nodejs-app-cluster-sample-k8s")
|
||||||
@@ -748,9 +750,11 @@ var _ = Describe("odo describe/list binding command tests", func() {
|
|||||||
stdout, stderr = res.Out(), res.Err()
|
stdout, stderr = res.Out(), res.Err()
|
||||||
ctx.assertDescribeNamedJsonOutput(stdout, stderr, "my-nodejs-app-cluster-sample-ocp")
|
ctx.assertDescribeNamedJsonOutput(stdout, stderr, "my-nodejs-app-cluster-sample-ocp")
|
||||||
})
|
})
|
||||||
By("human readable output from another directory with name flag", func() {
|
By("human readable output from another directory with name flag and invalid devfile", func() {
|
||||||
err := os.Chdir("/")
|
otherDir := filepath.Join(commonVar.Context, "tmp")
|
||||||
Expect(err).ToNot(HaveOccurred())
|
helper.MakeDir(otherDir)
|
||||||
|
helper.Chdir(otherDir)
|
||||||
|
helper.CreateInvalidDevfile(otherDir)
|
||||||
res := helper.Cmd("odo", "describe", "binding", "--name", "my-nodejs-app-cluster-sample-k8s").ShouldPass()
|
res := helper.Cmd("odo", "describe", "binding", "--name", "my-nodejs-app-cluster-sample-k8s").ShouldPass()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
ctx.assertDescribeNamedHumanReadableOutput(stdout, stderr, "my-nodejs-app-cluster-sample-k8s")
|
ctx.assertDescribeNamedHumanReadableOutput(stdout, stderr, "my-nodejs-app-cluster-sample-k8s")
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ var _ = Describe("odo devfile registry command tests", func() {
|
|||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach()
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
// This is run after every Spec (It)
|
// This is run after every Spec (It)
|
||||||
@@ -182,6 +183,7 @@ var _ = Describe("odo devfile registry command tests", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("should pass, when doing odo init with --devfile-registry flag", func() {
|
It("should pass, when doing odo init with --devfile-registry flag", func() {
|
||||||
|
helper.DeleteInvalidDevfile(commonVar.Context)
|
||||||
helper.Cmd("odo", "init", "--name", "aname", "--devfile", "nodejs", "--devfile-registry", registryName).ShouldPass()
|
helper.Cmd("odo", "init", "--name", "aname", "--devfile", "nodejs", "--devfile-registry", registryName).ShouldPass()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -194,6 +196,7 @@ var _ = Describe("odo devfile registry command tests", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("deleting registry and creating component with registry flag ", func() {
|
It("deleting registry and creating component with registry flag ", func() {
|
||||||
|
helper.DeleteInvalidDevfile(commonVar.Context)
|
||||||
helper.Cmd("odo", "preference", "remove", "registry", registryName, "-f").ShouldPass()
|
helper.Cmd("odo", "preference", "remove", "registry", registryName, "-f").ShouldPass()
|
||||||
helper.Cmd("odo", "init", "--name", "aname", "--devfile", "java-maven", "--devfile-registry", registryName).ShouldFail()
|
helper.Cmd("odo", "init", "--name", "aname", "--devfile", "java-maven", "--devfile-registry", registryName).ShouldFail()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ var _ = Describe("odo list services tests", func() {
|
|||||||
commonVar.CliRunner.EnsurePodIsUp(randomProject, "cluster-sample-1")
|
commonVar.CliRunner.EnsurePodIsUp(randomProject, "cluster-sample-1")
|
||||||
Expect(addBindableKind.ExitCode()).To(BeEquivalentTo(0))
|
Expect(addBindableKind.ExitCode()).To(BeEquivalentTo(0))
|
||||||
helper.Cmd("odo", "set", "project", commonVar.Project).ShouldPass()
|
helper.Cmd("odo", "set", "project", commonVar.Project).ShouldPass()
|
||||||
|
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ var _ = Describe("odo preference and config command tests", func() {
|
|||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach()
|
commonVar = helper.CommonBeforeEach()
|
||||||
|
helper.CreateInvalidDevfile(commonVar.Context)
|
||||||
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Clean up after the test
|
// Clean up after the test
|
||||||
@@ -199,6 +201,7 @@ OdoSettings:
|
|||||||
helper.Chdir(workingDir)
|
helper.Chdir(workingDir)
|
||||||
})
|
})
|
||||||
It("should not prompt the user", func() {
|
It("should not prompt the user", func() {
|
||||||
|
helper.DeleteInvalidDevfile(commonVar.Context)
|
||||||
helper.Cmd("odo", "preference", "set", "ConsentTelemetry", "false", "-f").ShouldPass()
|
helper.Cmd("odo", "preference", "set", "ConsentTelemetry", "false", "-f").ShouldPass()
|
||||||
output := helper.Cmd("odo", "init", "--name", "aname", "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-registry.yaml")).ShouldPass().Out()
|
output := helper.Cmd("odo", "init", "--name", "aname", "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-registry.yaml")).ShouldPass().Out()
|
||||||
Expect(output).ToNot(ContainSubstring(promptMessageSubString))
|
Expect(output).ToNot(ContainSubstring(promptMessageSubString))
|
||||||
|
|||||||
Reference in New Issue
Block a user