Skip to content

Commit

Permalink
change default options not pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Falzetti <andrea@okteto.com>
  • Loading branch information
andreafalzetti committed Feb 21, 2024
1 parent 04d2425 commit e0b7d6b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions cmd/context/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func LoadStackWithContext(ctx context.Context, name, namespace string, stackPath
}

// LoadContextFromPath initializes the okteto context taking into account command flags and manifest namespace/context fields
func LoadContextFromPath(ctx context.Context, namespace, k8sContext, path string, defaultCtxOpts *Options) error {
func LoadContextFromPath(ctx context.Context, namespace, k8sContext, path string, defaultCtxOpts Options) error {
ctxResource, err := getCtxResource(path)
if err != nil {
return err
Expand All @@ -238,14 +238,9 @@ func LoadContextFromPath(ctx context.Context, namespace, k8sContext, path string
return err
}

var ctxOptions *Options

if defaultCtxOpts != nil {
ctxOptions = defaultCtxOpts
}

ctxOptions := defaultCtxOpts
ctxOptions.Context = ctxResource.Context
ctxOptions.Namespace = ctxResource.Namespace

return NewContextCommand().Run(ctx, ctxOptions)
return NewContextCommand().Run(ctx, &ctxOptions)
}
2 changes: 1 addition & 1 deletion cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func Deploy(ctx context.Context, at analyticsTrackerInterface, ioCtrl *io.Contro
}

// Loads, updates and uses the context from path. If not found, it creates and uses a new context
if err := contextCMD.LoadContextFromPath(ctx, options.Namespace, options.K8sContext, options.ManifestPath, &contextCMD.Options{Show: true}); err != nil {
if err := contextCMD.LoadContextFromPath(ctx, options.Namespace, options.K8sContext, options.ManifestPath, contextCMD.Options{Show: true}); err != nil {
if err.Error() == fmt.Errorf(oktetoErrors.ErrNotLogged, okteto.CloudURL).Error() {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/deploy/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func Endpoints(ctx context.Context, k8sLogger *io.K8sLogger) *cobra.Command {
}

// Loads, updates and uses the context from path. If not found, it creates and uses a new context
if err := contextCMD.LoadContextFromPath(ctx, options.Namespace, options.K8sContext, options.ManifestPath, &contextCMD.Options{Show: options.Output == ""}); err != nil {
if err := contextCMD.LoadContextFromPath(ctx, options.Namespace, options.K8sContext, options.ManifestPath, contextCMD.Options{Show: options.Output == ""}); err != nil {
if err := contextCMD.NewContextCommand().Run(ctx, &contextCMD.Options{Namespace: options.Namespace, Show: false}); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/destroy/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func Destroy(ctx context.Context, at analyticsTrackerInterface, ioCtrl *io.Contr
}
options.ManifestPath = uptManifestPath
}
if err := contextCMD.LoadContextFromPath(ctx, options.Namespace, options.K8sContext, options.ManifestPath, &contextCMD.Options{Show: true}); err != nil {
if err := contextCMD.LoadContextFromPath(ctx, options.Namespace, options.K8sContext, options.ManifestPath, contextCMD.Options{Show: true}); err != nil {
if err.Error() == fmt.Errorf(oktetoErrors.ErrNotLogged, okteto.CloudURL).Error() {
return err
}
Expand Down

0 comments on commit e0b7d6b

Please sign in to comment.