Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Devfile dependency for commands
Browse files Browse the repository at this point in the history
feloy committed Sep 1, 2023
1 parent e9dbded commit a018240
Showing 16 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/odo/cli/add/binding/binding.go
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ func NewCmdBinding(name, fullName string, testClientset clientset.Clientset) *co
"Naming strategy to use for binding names. "+
"It can be set to pre-defined strategies: 'none', 'lowercase', or 'uppercase'. "+
"Otherwise, it is treated as a custom Go template, and it is handled accordingly.")
clientset.Add(bindingCmd, clientset.BINDING, clientset.FILESYSTEM)
clientset.Add(bindingCmd, clientset.BINDING, clientset.FILESYSTEM, clientset.USE_DEVFILE)

return bindingCmd
}
1 change: 1 addition & 0 deletions pkg/odo/cli/apiserver/apiserver.go
Original file line number Diff line number Diff line change
@@ -123,6 +123,7 @@ func NewCmdApiServer(ctx context.Context, name, fullName string, testClientset c
clientset.INFORMER,
clientset.STATE,
clientset.PREFERENCE,
clientset.USE_DEVFILE,
)
apiserverCmd.Flags().BoolVar(&o.randomPortsFlag, "random-ports", false, "Assign a random API Server port.")
apiserverCmd.Flags().IntVar(&o.portFlag, "port", 0, "Define custom port for API Server.")
2 changes: 1 addition & 1 deletion pkg/odo/cli/build_images/build_images.go
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ func NewCmdBuildImages(name, fullName string, testClientset clientset.Clientset)
buildImagesCmd.SetUsageTemplate(odoutil.CmdUsageTemplate)
commonflags.UseVariablesFlags(buildImagesCmd)
buildImagesCmd.Flags().BoolVar(&o.pushFlag, "push", false, "If true, build and push the images")
clientset.Add(buildImagesCmd, clientset.FILESYSTEM)
clientset.Add(buildImagesCmd, clientset.FILESYSTEM, clientset.USE_DEVFILE)

return buildImagesCmd
}
2 changes: 1 addition & 1 deletion pkg/odo/cli/delete/component/component.go
Original file line number Diff line number Diff line change
@@ -540,7 +540,7 @@ func NewCmdComponent(ctx context.Context, name, fullName string, testClientset c
componentCmd.Flags().BoolVarP(&o.withFilesFlag, "files", "", false, "Delete all files and directories generated by odo. Use with caution.")
componentCmd.Flags().BoolVarP(&o.forceFlag, "force", "f", false, "Delete component without prompting")
componentCmd.Flags().BoolVarP(&o.waitFlag, "wait", "w", false, "Wait for deletion of all dependent resources")
clientset.Add(componentCmd, clientset.DELETE_COMPONENT, clientset.KUBERNETES, clientset.FILESYSTEM)
clientset.Add(componentCmd, clientset.DELETE_COMPONENT, clientset.KUBERNETES, clientset.FILESYSTEM, clientset.USE_DEVFILE)
if feature.IsEnabled(ctx, feature.GenericPlatformFlag) {
clientset.Add(componentCmd, clientset.PODMAN_NULLABLE)
}
2 changes: 1 addition & 1 deletion pkg/odo/cli/deploy/deploy.go
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ func NewCmdDeploy(name, fullName string, testClientset clientset.Clientset) *cob
return genericclioptions.GenericRun(o, testClientset, cmd, args)
},
}
clientset.Add(deployCmd, clientset.INIT, clientset.DEPLOY, clientset.FILESYSTEM, clientset.KUBERNETES)
clientset.Add(deployCmd, clientset.INIT, clientset.DEPLOY, clientset.FILESYSTEM, clientset.KUBERNETES, clientset.USE_DEVFILE)

// Add a defined annotation in order to appear in the help menu
util.SetCommandGroup(deployCmd, util.MainGroup)
2 changes: 1 addition & 1 deletion pkg/odo/cli/describe/binding.go
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ func NewCmdBinding(name, fullName string, testClientset clientset.Clientset) *co
},
}
bindingCmd.Flags().StringVar(&o.nameFlag, "name", "", "Name of the binding to describe, optional. By default, the bindings in the local devfile are described")
clientset.Add(bindingCmd, clientset.KUBERNETES, clientset.BINDING, clientset.FILESYSTEM)
clientset.Add(bindingCmd, clientset.KUBERNETES, clientset.BINDING, clientset.FILESYSTEM, clientset.USE_DEVFILE)
commonflags.UseOutputFlag(bindingCmd)

return bindingCmd
2 changes: 1 addition & 1 deletion pkg/odo/cli/describe/component.go
Original file line number Diff line number Diff line change
@@ -329,7 +329,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.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, clientset.USE_DEVFILE)
if feature.IsEnabled(ctx, feature.GenericPlatformFlag) {
clientset.Add(componentCmd, clientset.PODMAN_NULLABLE)
}
1 change: 1 addition & 0 deletions pkg/odo/cli/dev/dev.go
Original file line number Diff line number Diff line change
@@ -440,6 +440,7 @@ It forwards endpoints with any exposure values ('public', 'internal' or 'none')
clientset.PREFERENCE,
clientset.STATE,
clientset.SYNC,
clientset.USE_DEVFILE,
clientset.WATCH,
)
// Add a defined annotation in order to appear in the help menu
2 changes: 1 addition & 1 deletion pkg/odo/cli/list/binding/binding.go
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ func NewCmdBindingList(name, fullName string, testClientset clientset.Clientset)
},
Aliases: []string{"bindings"},
}
clientset.Add(bindingListCmd, clientset.KUBERNETES, clientset.BINDING, clientset.FILESYSTEM)
clientset.Add(bindingListCmd, clientset.KUBERNETES, clientset.BINDING, clientset.FILESYSTEM, clientset.USE_DEVFILE)
bindingListCmd.Flags().StringVar(&o.namespaceFlag, "namespace", "", "Namespace for odo to scan for bindings")
commonflags.UseOutputFlag(bindingListCmd)
return bindingListCmd
2 changes: 1 addition & 1 deletion pkg/odo/cli/list/component/list.go
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ func NewCmdComponentList(ctx context.Context, name, fullName string, testClients
},
Aliases: []string{"components"},
}
clientset.Add(listCmd, clientset.KUBERNETES_NULLABLE, clientset.FILESYSTEM)
clientset.Add(listCmd, clientset.KUBERNETES_NULLABLE, clientset.FILESYSTEM, clientset.USE_DEVFILE)
if feature.IsEnabled(ctx, feature.GenericPlatformFlag) {
clientset.Add(listCmd, clientset.PODMAN_NULLABLE)
}
2 changes: 1 addition & 1 deletion pkg/odo/cli/list/list.go
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ func NewCmdList(ctx context.Context, name, fullName string, testClientset client
return genericclioptions.GenericRun(o, testClientset, cmd, args)
},
}
clientset.Add(listCmd, clientset.KUBERNETES_NULLABLE, clientset.BINDING, clientset.FILESYSTEM)
clientset.Add(listCmd, clientset.KUBERNETES_NULLABLE, clientset.BINDING, clientset.FILESYSTEM, clientset.USE_DEVFILE)
if feature.IsEnabled(ctx, feature.GenericPlatformFlag) {
clientset.Add(listCmd, clientset.PODMAN_NULLABLE)
}
2 changes: 1 addition & 1 deletion pkg/odo/cli/logs/logs.go
Original file line number Diff line number Diff line change
@@ -162,7 +162,7 @@ By default it shows logs of all containers running in both Dev and Deploy mode.
logsCmd.Flags().BoolVar(&o.deployMode, string(DeployMode), false, "Show logs for containers running only in Deploy mode")
logsCmd.Flags().BoolVar(&o.follow, "follow", false, "Follow/tail the logs of the pods")

clientset.Add(logsCmd, clientset.LOGS, clientset.FILESYSTEM)
clientset.Add(logsCmd, clientset.LOGS, clientset.FILESYSTEM, clientset.USE_DEVFILE)
util.SetCommandGroup(logsCmd, util.MainGroup)
logsCmd.SetUsageTemplate(odoutil.CmdUsageTemplate)
commonflags.UsePlatformFlag(logsCmd)
2 changes: 1 addition & 1 deletion pkg/odo/cli/remove/binding/binding.go
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ func NewCmdBinding(name, fullName string, testClientset clientset.Clientset) *co
},
}
bindingCmd.Flags().String(backend.FLAG_NAME, "", "Name of the Binding to remove")
clientset.Add(bindingCmd, clientset.BINDING, clientset.FILESYSTEM)
clientset.Add(bindingCmd, clientset.BINDING, clientset.FILESYSTEM, clientset.USE_DEVFILE)

return bindingCmd
}
1 change: 1 addition & 0 deletions pkg/odo/cli/run/run.go
Original file line number Diff line number Diff line change
@@ -113,6 +113,7 @@ func NewCmdRun(name, fullName string, testClientset clientset.Clientset) *cobra.
clientset.KUBERNETES_NULLABLE,
clientset.PODMAN_NULLABLE,
clientset.DEV,
clientset.USE_DEVFILE,
)

odoutil.SetCommandGroup(runCmd, odoutil.MainGroup)
6 changes: 6 additions & 0 deletions pkg/odo/genericclioptions/clientset/clientset.go
Original file line number Diff line number Diff line change
@@ -90,6 +90,8 @@ const (
STATE = "DEP_STATE"
// SYNC instantiates client for pkg/sync
SYNC = "DEP_SYNC"
// USE_DEVFILE indicates that a command is using a Devfile
USE_DEVFILE = "DEP_DEVFILE"
// WATCH instantiates client for pkg/watch
WATCH = "DEP_WATCH"
/* Add key for new package here */
@@ -139,6 +141,7 @@ type Clientset struct {
DeleteClient _delete.Client
DeployClient deploy.Client
DevClient dev.Client
UseDevfile *struct{}
ExecClient exec.Client
FS filesystem.Filesystem
InformerClient *informer.InformerClient
@@ -194,6 +197,9 @@ func Fetch(command *cobra.Command, platform string, testClientset Clientset) (*C
}

/* Without sub-dependencies */
if isDefined(command, USE_DEVFILE) {
dep.UseDevfile = &struct{}{}
}
if isDefined(command, FILESYSTEM) {
if testClientset.FS != nil {
dep.FS = testClientset.FS
20 changes: 11 additions & 9 deletions pkg/odo/genericclioptions/runnable.go
Original file line number Diff line number Diff line change
@@ -248,16 +248,18 @@ func GenericRun(o Runnable, testClientset clientset.Clientset, cmd *cobra.Comman
}
}

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
if deps.UseDevfile != nil {
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.

0 comments on commit a018240

Please sign in to comment.