mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 14:26:23 -04:00
cli: move cloudcmd/validators
to cmd
(#2679)
* cli: refactor `cloudcmd/validators` Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * make struct fields private Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * use errors.New Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * make struct fields private in usage * fix casing --------- Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com>
This commit is contained in:
parent
a3de1d95d9
commit
781ac85711
7 changed files with 316 additions and 364 deletions
|
@ -260,7 +260,7 @@ func runApply(cmd *cobra.Command, _ []string) error {
|
|||
fileHandler: fileHandler,
|
||||
flags: flags,
|
||||
log: log,
|
||||
wLog: &cloudcmd.WarnLogger{Cmd: cmd, Log: log},
|
||||
wLog: &warnLogger{cmd: cmd, log: log},
|
||||
spinner: spinner,
|
||||
merger: &kubeconfigMerger{log: log},
|
||||
newHelmClient: newHelmClient,
|
||||
|
@ -786,3 +786,20 @@ func skipPhasesCompletion(_ *cobra.Command, _ []string, toComplete string) ([]st
|
|||
|
||||
return suggestions, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
// warnLogger implements logging of warnings for validators.
|
||||
type warnLogger struct {
|
||||
cmd *cobra.Command
|
||||
log debugLog
|
||||
}
|
||||
|
||||
// Infof messages are reduced to debug messages, since we don't want
|
||||
// the extra info when using the CLI without setting the debug flag.
|
||||
func (wl warnLogger) Infof(fmtStr string, args ...any) {
|
||||
wl.log.Debugf(fmtStr, args...)
|
||||
}
|
||||
|
||||
// Warnf prints a formatted warning from the validator.
|
||||
func (wl warnLogger) Warnf(fmtStr string, args ...any) {
|
||||
wl.cmd.PrintErrf("Warning: %s\n", fmt.Sprintf(fmtStr, args...))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue