Skip to content

Commit f971576

Browse files
Bump app proxy (#152)
* wip * wip * wip * wip * wip * wip * bump * wip * codegen
1 parent be4256c commit f971576

27 files changed

+921
-33
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.142
1+
VERSION=v0.0.143
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/common.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ func getKubeContextNameFromUserSelect(cmd *cobra.Command, kubeContextName *strin
278278

279279
contextsList := conf.Contexts
280280
currentContext := conf.CurrentContext
281-
var contextsNamesToShowUser []string
282-
var contextsIndex []string
281+
contextsNamesToShowUser := []string{currentContext + " (current)"}
282+
contextsIndex := []string{currentContext}
283283

284284
for key := range contextsList {
285-
contextsIndex = append(contextsIndex, key)
286285
if key == currentContext {
287-
key = key + " (current)"
286+
continue
288287
}
288+
contextsIndex = append(contextsIndex, key)
289289
contextsNamesToShowUser = append(contextsNamesToShowUser, key)
290290
}
291291

@@ -319,6 +319,10 @@ func getIngressHostFromUserInput(cmd *cobra.Command, ingressHost *string) error
319319
return nil
320320
}
321321

322+
if ingressHost != nil && *ingressHost != "" {
323+
return nil
324+
}
325+
322326
ingressHostPrompt := promptui.Prompt{
323327
Label: "Ingress host (leave blank to skip)",
324328
}

cmd/commands/config.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ commands, respectively:
5252
cmd.AddCommand(NewConfigUseContextCommand())
5353
cmd.AddCommand(NewConfigCreateContextCommand())
5454
cmd.AddCommand(NewConfigDeleteContextCommand())
55+
cmd.AddCommand(NewConfigSetRuntimeCommand())
56+
cmd.AddCommand(NewConfigGetRuntimeCommand())
5557

5658
return cmd
5759
}
@@ -139,6 +141,76 @@ func RunConfigCurrentContext(ctx context.Context) error {
139141
return nil
140142
}
141143

144+
func NewConfigSetRuntimeCommand() *cobra.Command {
145+
cmd := &cobra.Command{
146+
Use: "set-runtime RUNTIME",
147+
Short: "Sets the default runtime name to use for the current authentication context",
148+
Example: util.Doc(`
149+
# Sets the default runtime to 'runtime-2':
150+
151+
<BIN> config set-runtime runtime-2`),
152+
RunE: func(cmd *cobra.Command, args []string) error {
153+
if len(args) < 1 {
154+
return fmt.Errorf("must provide runtime name to use")
155+
156+
}
157+
158+
return RunConfigSetRuntime(cmd.Context(), args[0])
159+
},
160+
}
161+
162+
return cmd
163+
}
164+
165+
func RunConfigSetRuntime(ctx context.Context, runtime string) error {
166+
_, err := cfConfig.NewClient().V2().Runtime().Get(ctx, runtime)
167+
if err != nil {
168+
return err
169+
}
170+
171+
cur := cfConfig.GetCurrentContext()
172+
if cur.Name == "" {
173+
log.G(ctx).Fatal(util.Doc("no currently selected context, use '<BIN> config use-context' to select a context"))
174+
}
175+
176+
cur.DefaultRuntime = runtime
177+
178+
if err := cfConfig.Save(); err != nil {
179+
return fmt.Errorf("failed to save config: %w", err)
180+
}
181+
182+
log.G(ctx).Infof("default runtime set to: %s", runtime)
183+
184+
return nil
185+
}
186+
187+
func NewConfigGetRuntimeCommand() *cobra.Command {
188+
cmd := &cobra.Command{
189+
Use: "get-runtime",
190+
Short: "Gets the default runtime for the current authentication context",
191+
Example: util.Doc(`
192+
# Prints the default runtime:
193+
194+
<BIN> config get-runtime`),
195+
RunE: func(cmd *cobra.Command, args []string) error {
196+
return RunConfigGetRuntime(cmd.Context())
197+
},
198+
}
199+
200+
return cmd
201+
}
202+
203+
func RunConfigGetRuntime(ctx context.Context) error {
204+
cur := cfConfig.GetCurrentContext()
205+
if cur.DefaultRuntime == "" {
206+
return fmt.Errorf(util.Doc("no default runtime is set for current context, use '<BIN> config set-runtime' to set one"))
207+
}
208+
209+
log.G(ctx).Infof("default runtime set to: %s", cur.DefaultRuntime)
210+
211+
return nil
212+
}
213+
142214
func NewConfigUseContextCommand() *cobra.Command {
143215
cmd := &cobra.Command{
144216
Use: "use-context CONTEXT",

0 commit comments

Comments
 (0)