Add readonly flag to cli
parent
224c7bdb90
commit
bc434dcfc8
10
cmd/root.go
10
cmd/root.go
|
|
@ -113,6 +113,10 @@ func loadConfiguration() *config.Config {
|
||||||
k9sCfg.K9s.OverrideHeadless(*k9sFlags.Headless)
|
k9sCfg.K9s.OverrideHeadless(*k9sFlags.Headless)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if k9sFlags.ReadOnly != nil {
|
||||||
|
k9sCfg.K9s.OverrideReadOnly(*k9sFlags.ReadOnly)
|
||||||
|
}
|
||||||
|
|
||||||
if k9sFlags.Command != nil {
|
if k9sFlags.Command != nil {
|
||||||
k9sCfg.K9s.OverrideCommand(*k9sFlags.Command)
|
k9sCfg.K9s.OverrideCommand(*k9sFlags.Command)
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +193,12 @@ func initK9sFlags() {
|
||||||
config.DefaultCommand,
|
config.DefaultCommand,
|
||||||
"Specify the default command to view when the application launches",
|
"Specify the default command to view when the application launches",
|
||||||
)
|
)
|
||||||
|
rootCmd.Flags().BoolVar(
|
||||||
|
k9sFlags.ReadOnly,
|
||||||
|
"readonly",
|
||||||
|
false,
|
||||||
|
"Disable all commands that modify the cluster",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initK8sFlags() {
|
func initK8sFlags() {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ type Flags struct {
|
||||||
Headless *bool
|
Headless *bool
|
||||||
Command *string
|
Command *string
|
||||||
AllNamespaces *bool
|
AllNamespaces *bool
|
||||||
|
ReadOnly *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFlags returns new configuration flags.
|
// NewFlags returns new configuration flags.
|
||||||
|
|
@ -28,6 +29,7 @@ func NewFlags() *Flags {
|
||||||
Headless: boolPtr(false),
|
Headless: boolPtr(false),
|
||||||
Command: strPtr(DefaultCommand),
|
Command: strPtr(DefaultCommand),
|
||||||
AllNamespaces: boolPtr(false),
|
AllNamespaces: boolPtr(false),
|
||||||
|
ReadOnly: boolPtr(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue