Add readonly flag to cli

mine
Joscha Alisch 2020-02-04 22:09:21 +01:00
parent 224c7bdb90
commit bc434dcfc8
No known key found for this signature in database
GPG Key ID: 5CD84D89434B6CB5
2 changed files with 12 additions and 0 deletions

View File

@ -113,6 +113,10 @@ func loadConfiguration() *config.Config {
k9sCfg.K9s.OverrideHeadless(*k9sFlags.Headless)
}
if k9sFlags.ReadOnly != nil {
k9sCfg.K9s.OverrideReadOnly(*k9sFlags.ReadOnly)
}
if k9sFlags.Command != nil {
k9sCfg.K9s.OverrideCommand(*k9sFlags.Command)
}
@ -189,6 +193,12 @@ func initK9sFlags() {
config.DefaultCommand,
"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() {

View File

@ -18,6 +18,7 @@ type Flags struct {
Headless *bool
Command *string
AllNamespaces *bool
ReadOnly *bool
}
// NewFlags returns new configuration flags.
@ -28,6 +29,7 @@ func NewFlags() *Flags {
Headless: boolPtr(false),
Command: strPtr(DefaultCommand),
AllNamespaces: boolPtr(false),
ReadOnly: boolPtr(false),
}
}