Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip run app via clusterfile Or run CLI #2117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/sealer/cmd/cluster/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func NewRunCmd() *cobra.Command {
runCmd.Flags().StringVar(&runFlags.Pk, "pk", filepath.Join(common.GetHomeDir(), ".ssh", "id_rsa"), "set baremetal server private key")
runCmd.Flags().StringVar(&runFlags.PkPassword, "pk-passwd", "", "set baremetal server private key password")
runCmd.Flags().StringSliceVar(&runFlags.Cmds, "cmds", []string{}, "override default LaunchCmds of sealer image")
runCmd.Flags().StringSliceVar(&runFlags.AppNames, "apps", []string{}, "override default AppNames of sealer image")
runCmd.Flags().StringSliceVar(&runFlags.AppNames, "apps", nil, "override default AppNames of sealer image")
runCmd.Flags().StringSliceVarP(&runFlags.CustomEnv, "env", "e", []string{}, "set custom environment variables")
runCmd.Flags().StringVarP(&runFlags.ClusterFile, "Clusterfile", "f", "", "Clusterfile path to run a Kubernetes cluster")
runCmd.Flags().StringVar(&runFlags.Mode, "mode", common.ApplyModeApply, "load images to the specified registry in advance")
Expand Down
2 changes: 1 addition & 1 deletion cmd/sealer/cmd/utils/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func ConstructApplication(app *v2.Application, cmds, appNames []string) *v2.Appl
newApp.Spec.Cmds = cmds
}

if len(appNames) > 0 {
if appNames != nil {
newApp.Spec.LaunchApps = appNames
}

Expand Down
16 changes: 15 additions & 1 deletion pkg/application/v2app.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ type v2Application struct {
app *v2.Application

// launchApps indicate that which applications will be launched
//if launchApps==nil, use default launch apps got from image extension to launch.
//if launchApps==[""], skip launch apps.
//if launchApps==["app1","app2"], launch app1,app2.
launchApps []string

// globalCmds is raw cmds without any application info
Expand Down Expand Up @@ -173,7 +176,18 @@ func NewV2Application(app *v2.Application, extension imagev1.ImageExtension) (In
}

// initialize appNames field, overwrite default app names from image extension.
if len(app.Spec.LaunchApps) > 0 {
if app.Spec.LaunchApps != nil {
// validate app.Spec.LaunchApps, if not in image extension,will return error
// NOTE: app name =="" is valid
for _, wanted := range app.Spec.LaunchApps {
if len(wanted) == 0 {
continue
}
if !strUtils.IsInSlice(wanted, v2App.launchApps) {
return nil, fmt.Errorf("app name `%s` is not found in %s", wanted, v2App.launchApps)
}
}

v2App.launchApps = app.Spec.LaunchApps
}

Expand Down