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

fix(cli): skip deprecated suboptions when upgrading a provider tied to a pro instance #1385

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/pro/import_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (cmd *ImportCmd) writeWorkspaceDefinition(devPodConfig *config.Config, prov
},
}

devPodConfig, err := options.ResolveOptions(context.Background(), devPodConfig, provider, instanceOpts, false, nil, cmd.log)
devPodConfig, err := options.ResolveOptions(context.Background(), devPodConfig, provider, instanceOpts, false, false, nil, cmd.log)
if err != nil {
return fmt.Errorf("resolve options: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pro/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (cmd *LoginCmd) Run(ctx context.Context, fullURL string, log log.Logger) er

// 3. Configure provider
if cmd.Use {
err := providercmd.ConfigureProvider(ctx, providerConfig, devPodConfig.DefaultContext, cmd.Options, false, false, nil, log)
err := providercmd.ConfigureProvider(ctx, providerConfig, devPodConfig.DefaultContext, cmd.Options, false, false, false, nil, log)
if err != nil {
return errors.Wrap(err, "configure provider")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pro/update_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (cmd *UpdateProviderCmd) Run(ctx context.Context, args []string) error {
return fmt.Errorf("update provider %s: %w", provider.Name, err)
}

err = providercmd.ConfigureProvider(ctx, provider, devPodConfig.DefaultContext, []string{}, false, false, nil, log.Discard)
err = providercmd.ConfigureProvider(ctx, provider, devPodConfig.DefaultContext, []string{}, true, true, true, nil, log.Discard)
if err != nil {
return fmt.Errorf("configure provider, please retry with 'devpod provider use %s --reconfigure': %w", provider.Name, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/provider/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (cmd *AddCmd) Run(ctx context.Context, devPodConfig *config.Config, args []

log.Default.Donef("Successfully installed provider %s", providerConfig.Name)
if cmd.Use {
configureErr := ConfigureProvider(ctx, providerConfig, devPodConfig.DefaultContext, options, true, false, &cmd.SingleMachine, log.Default)
configureErr := ConfigureProvider(ctx, providerConfig, devPodConfig.DefaultContext, options, true, false, false, &cmd.SingleMachine, log.Default)
if configureErr != nil {
devPodConfig, err := config.LoadConfig(cmd.Context, "")
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/provider/set_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (cmd *SetOptionsCmd) Run(ctx context.Context, args []string, log log.Logger
cmd.Reconfigure,
cmd.Dry,
cmd.Dry,
false,
&cmd.SingleMachine,
log,
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/provider/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (cmd *UpdateCmd) Run(ctx context.Context, devPodConfig *config.Config, args

log.Default.Donef("Successfully updated provider %s", providerConfig.Name)
if cmd.Use {
err = ConfigureProvider(ctx, providerConfig, devPodConfig.DefaultContext, cmd.Options, false, false, nil, log.Default)
err = ConfigureProvider(ctx, providerConfig, devPodConfig.DefaultContext, cmd.Options, false, false, false, nil, log.Default)
if err != nil {
log.Default.Errorf("Error configuring provider, please retry with 'devpod provider use %s --reconfigure'", providerConfig.Name)
return errors.Wrap(err, "configure provider")
Expand Down
11 changes: 6 additions & 5 deletions cmd/provider/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (cmd *UseCmd) Run(ctx context.Context, providerName string) error {
// should reconfigure?
shouldReconfigure := cmd.Reconfigure || len(cmd.Options) > 0 || providerWithOptions.State == nil || cmd.SingleMachine
if shouldReconfigure {
return ConfigureProvider(ctx, providerWithOptions.Config, devPodConfig.DefaultContext, cmd.Options, cmd.Reconfigure, cmd.SkipInit, &cmd.SingleMachine, log.Default)
return ConfigureProvider(ctx, providerWithOptions.Config, devPodConfig.DefaultContext, cmd.Options, cmd.Reconfigure, cmd.SkipInit, false, &cmd.SingleMachine, log.Default)
} else {
log.Default.Infof("To reconfigure provider %s, run with '--reconfigure' to reconfigure the provider", providerWithOptions.Config.Name)
}
Expand All @@ -94,9 +94,9 @@ func (cmd *UseCmd) Run(ctx context.Context, providerName string) error {
return nil
}

func ConfigureProvider(ctx context.Context, provider *provider2.ProviderConfig, context string, userOptions []string, reconfigure, skipInit bool, singleMachine *bool, log log.Logger) error {
func ConfigureProvider(ctx context.Context, provider *provider2.ProviderConfig, context string, userOptions []string, reconfigure, skipInit, skipSubOptions bool, singleMachine *bool, log log.Logger) error {
// set options
devPodConfig, err := setOptions(ctx, provider, context, userOptions, reconfigure, false, skipInit, singleMachine, log)
devPodConfig, err := setOptions(ctx, provider, context, userOptions, reconfigure, false, skipInit, skipSubOptions, singleMachine, log)
if err != nil {
return err
}
Expand All @@ -122,7 +122,8 @@ func setOptions(
userOptions []string,
reconfigure,
skipRequired,
skipInit bool,
skipInit,
skipSubOptions bool,
singleMachine *bool,
log log.Logger,
) (*config.Config, error) {
Expand All @@ -148,7 +149,7 @@ func setOptions(
}

// fill defaults
devPodConfig, err = options2.ResolveOptions(ctx, devPodConfig, provider, options, skipRequired, singleMachine, log)
devPodConfig, err = options2.ResolveOptions(ctx, devPodConfig, provider, options, skipRequired, skipSubOptions, singleMachine, log)
if err != nil {
return nil, errors.Wrap(err, "resolve options")
}
Expand Down
7 changes: 4 additions & 3 deletions desktop/src/App/useAppReady.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export function useAppReady() {
proInstances
.filter((instance) => instance.provider && instance.host)
.map(async (instance) => {
client.log("info", `[${instance.host ?? ""}] Checking for update`)

const proClient = client.getProClient(instance.host!)
const checkUpdateRes = await proClient.checkUpdate()
if (checkUpdateRes.err) {
Expand All @@ -81,7 +79,10 @@ export function useAppReady() {

const updateRes = await proClient.update(newVersion)
if (updateRes.err) {
client.log("error", `[${instance.host ?? ""}] Failed to upgrade: ${updateRes.val}`)
client.log(
"error",
`[${instance.host ?? ""}] Failed to upgrade: ${updateRes.val.message}`
)

return null
}
Expand Down
13 changes: 10 additions & 3 deletions pkg/options/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func ResolveOptions(
provider *provider2.ProviderConfig,
userOptions map[string]string,
skipRequired bool,
skipSubOptions bool,
singleMachine *bool,
log log.Logger,
) (*config.Config, error) {
Expand All @@ -164,14 +165,20 @@ func ResolveOptions(
return nil, err
}

resolverOpts := []resolver.Option{
resolver.WithResolveGlobal(),
resolver.WithSkipRequired(skipRequired),
}
if !skipSubOptions {
resolverOpts = append(resolverOpts, resolver.WithResolveSubOptions())
}

// create new resolver
resolve := resolver.New(
userOptions,
provider2.Merge(provider2.GetBaseEnvironment(devConfig.DefaultContext, provider.Name), binaryPaths),
log,
resolver.WithResolveGlobal(),
resolver.WithResolveSubOptions(),
resolver.WithSkipRequired(skipRequired),
resolverOpts...,
)

// loop and resolve options, as soon as we encounter a new dynamic option it will get filled
Expand Down
Loading