forked from noobaa/noobaa-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a CLI sub-command in noobaa diagnostics to print proxy details
Signed-off-by: Aayush Chouhan <[email protected]>
- Loading branch information
1 parent
089b5af
commit 6047c1f
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package diagnostics | ||
|
||
import ( | ||
"github.com/noobaa/noobaa-operator/v5/pkg/bundle" | ||
"github.com/noobaa/noobaa-operator/v5/pkg/options" | ||
"github.com/noobaa/noobaa-operator/v5/pkg/util" | ||
"github.com/spf13/cobra" | ||
appsv1 "k8s.io/api/apps/v1" | ||
) | ||
|
||
// RunReport runs a CLI command | ||
func RunReport(cmd *cobra.Command, args []string) { | ||
log := util.Logger() | ||
|
||
log.Printf("⏳ Retrieving proxy environment variable details...\n\n") | ||
|
||
coreApp := util.KubeObject(bundle.File_deploy_internal_statefulset_core_yaml).(*appsv1.StatefulSet) | ||
coreApp.Namespace = options.Namespace | ||
if !util.KubeCheck(coreApp) { | ||
log.Fatalf(`❌ Could not get core StatefulSet %q in Namespace %q`, | ||
coreApp.Name, coreApp.Namespace) | ||
} | ||
|
||
for _, proxyName := range []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"} { | ||
envVar := util.GetEnvVariable(&coreApp.Spec.Template.Spec.Containers[0].Env, proxyName) | ||
if envVar != nil && envVar.Value != "" { | ||
log.Printf("✅ %s is set to: %s\n", envVar.Name, envVar.Value) | ||
} else { | ||
log.Errorf("❌ %s is not set or is empty.\n", proxyName) | ||
} | ||
} | ||
} |