Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
core/cli: Update profile set to use defaults on init only
Browse files Browse the repository at this point in the history
This commit modifies `runner profile set` to use profile defaults only
when setting up an initial profile instead of resetting the profile to
defaults when updating an existing profile.
  • Loading branch information
demophoon committed Sep 9, 2022
1 parent fdd353f commit 4f3ce70
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions internal/cli/runner_profile_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *RunnerProfileSetCommand) Run(args []string) int {
},
},
}
} else {
} else if od.TargetRunner == nil || c.flagTargetRunnerId == "*" {
od.TargetRunner = &pb.Ref_Runner{Target: &pb.Ref_Runner_Any{}}
}

Expand Down Expand Up @@ -188,8 +188,9 @@ func (c *RunnerProfileSetCommand) Run(args []string) int {
}
}

od.OciUrl = c.flagOCIUrl
od.EnvironmentVariables = map[string]string{}
if od.OciUrl == "" || c.flagOCIUrl != installutil.DefaultRunnerImage {
od.OciUrl = c.flagOCIUrl
}
if c.flagDefault != nil {
od.Default = *c.flagDefault
}
Expand All @@ -206,20 +207,31 @@ func (c *RunnerProfileSetCommand) Run(args []string) int {
od.EnvironmentVariables[kv[:idx]] = kv[idx+1:]
}
}
} else {
od.EnvironmentVariables = c.flagEnvVar
}
if c.flagEnvVar != nil {
fmt.Printf("envvar: %#v", c.flagEnvVar)
for k, v := range c.flagEnvVar {
if v == "" {
delete(od.EnvironmentVariables, k)
} else {
od.EnvironmentVariables[k] = v
}
}
//od.EnvironmentVariables = c.flagEnvVar
}

if c.flagPluginType == "" {
if od.PluginType == "" && c.flagPluginType == "" {
c.ui.Output(
"Flag '-plugin-type' must be set to a valid plugin type like 'docker' or 'kubernetes'.\n\n%s",
c.Help(),
terminal.WithErrorStyle(),
)
return 1
}
if c.flagPluginType != "" {
od.PluginType = c.flagPluginType
}

od.PluginType = c.flagPluginType

// Upsert
_, err := c.project.Client().UpsertOnDemandRunnerConfig(ctx, &pb.UpsertOnDemandRunnerConfigRequest{
Expand Down

0 comments on commit 4f3ce70

Please sign in to comment.