MCPcopy Create free account
hub / github.com/cozystack/talm / debugPhase

Function debugPhase

pkg/engine/engine.go:83–125  ·  view source on GitHub ↗

debugPhase is a unified debug function that prints debug information based on the given stage and context, then exits the program. nolint:gocritic // hugeParam: Options carries flag-aggregated config and is consumed read-only along the debug path; converting to a pointer here would require changing

(opts Options, patches []string, clusterName string, clusterEndpoint string, mType machine.Type)

Source from the content-addressed store, hash-verified

81//
82//nolint:gocritic // hugeParam: Options carries flag-aggregated config and is consumed read-only along the debug path; converting to a pointer here would require changing every public signature in this file (Render, InitializeConfigBundle, FullConfigProcess) without runtime benefit, since debugPhase exits the process.
83func debugPhase(opts Options, patches []string, clusterName string, clusterEndpoint string, mType machine.Type) {
84 phase := 2
85
86 if clusterName == "" {
87 clusterName = "dummy"
88 phase = 1
89 }
90
91 if clusterEndpoint == "" {
92 clusterEndpoint = "clusterEndpoint"
93 phase = 1
94 }
95
96 fmt.Fprintf(os.Stdout,
97 "# DEBUG(phase %d): talosctl gen config %s %s -t %s --with-secrets=%s --talos-version=%s --kubernetes-version=%s -o -",
98 phase, clusterName, clusterEndpoint, mType,
99 opts.WithSecrets, opts.TalosVersion, opts.KubernetesVersion,
100 )
101
102 patchOption := "--config-patch-control-plane"
103 if mType == machine.TypeWorker {
104 patchOption = "--config-patch-worker"
105 }
106
107 // Print patches. Skip empty entries — a template that conditionally
108 // emits nothing legitimately produces "" in the slice, and indexing
109 // patch[0] on an empty string would panic right at the moment the
110 // operator is using --debug to investigate something.
111 for _, patch := range patches {
112 if patch == "" {
113 continue
114 }
115
116 if patch[0] == '@' {
117 // Apply patch is always one
118 fmt.Fprintf(os.Stdout, " %s=%s\n", patchOption, patch)
119 } else {
120 fmt.Fprintf(os.Stdout, "\n---\n# DEBUG(phase %d): %s=\n%s", phase, patchOption, patch)
121 }
122 }
123
124 os.Exit(0)
125}
126
127// FullConfigProcess handles the full process of creating and updating the Bundle.
128//

Calls

no outgoing calls