MCPcopy
hub / github.com/kubesphere/kubekey / ModuleDebug

Function ModuleDebug

pkg/modules/debug/debug.go:87–106  ·  view source on GitHub ↗

* The Debug module provides debugging capabilities by printing variable values and messages. This module allows users to inspect variable values and debug playbook execution. Configuration: Users can specify either a message or a variable path to debug. debug: msg: "message" #

(_ context.Context, opts internal.ExecOptions)

Source from the content-addressed store, hash-verified

85
86// ModuleDebug handles the "debug" module, printing debug information
87func ModuleDebug(_ context.Context, opts internal.ExecOptions) (string, string, error) {
88 // get host variable
89 ha, err := opts.GetAllVariables()
90 if err != nil {
91 return internal.StdoutFailed, internal.StderrGetHostVariable, err
92 }
93 args := variable.Extension2Variables(opts.Args)
94
95 // Handle "var" field - for getting variable values
96 if v, ok := args["var"]; ok {
97 return handleVarField(v, ha, opts.LogOutput)
98 }
99
100 // Handle "msg" field - for printing messages with template support
101 if v, ok := args["msg"]; ok {
102 return handleMsgField(v, ha, opts.LogOutput)
103 }
104
105 return internal.StdoutFailed, internal.StderrUnsupportArgs, errors.New("either \"msg\" or \"var\" must be specified")
106}
107
108// handleVarField handles the "var" field for variable debugging
109// Supports both template syntax "{{ .var }}" and simple path ".var"

Callers 2

TestDebugArgsModuleFunction · 0.85
TestDebugModuleFunction · 0.85

Calls 5

Extension2VariablesFunction · 0.92
handleVarFieldFunction · 0.85
handleMsgFieldFunction · 0.85
GetAllVariablesMethod · 0.80
NewMethod · 0.45

Tested by 2

TestDebugArgsModuleFunction · 0.68
TestDebugModuleFunction · 0.68