Skip to content

Commit

Permalink
Updated the function call and description
Browse files Browse the repository at this point in the history
Signed-off-by: Aayush Chouhan <[email protected]>
  • Loading branch information
achouhan09 committed Sep 17, 2024
1 parent e3d8c7b commit a25496b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func CmdAnalyze() *cobra.Command {
func CmdReport() *cobra.Command {
cmd := &cobra.Command{
Use: "report",
Short: "Reports the proxy status",
Short: "Run reports of the status and setup",
Run: RunReport,
Args: cobra.NoArgs,
}
Expand Down
20 changes: 15 additions & 5 deletions pkg/diagnostics/report.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package diagnostics

import (
"fmt"

"github.com/noobaa/noobaa-operator/v5/pkg/bundle"
"github.com/noobaa/noobaa-operator/v5/pkg/options"
"github.com/noobaa/noobaa-operator/v5/pkg/util"
Expand All @@ -10,24 +12,32 @@ import (

// RunReport runs a CLI command
func RunReport(cmd *cobra.Command, args []string) {
log := util.Logger()

log.Printf("⏳ Retrieving proxy environment variable details...\n")
// retrieving the status of proxy environment variables
proxyStatus()

// TODO: Add support for additional features
}

// proxyStatus returns the status of the environment variables: HTTP_PROXY, HTTPS_PROXY, and NO_PROXY
func proxyStatus() {
log := util.Logger()

log.Print("⏳ Retrieving proxy environment variable details...\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)
}

log.Printf("\nProxy Environment Variables Check:\n----------------------------------")
fmt.Print("\nProxy Environment Variables Check:\n----------------------------------\n")
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(" ✅ %-12s : %s\n", envVar.Name, envVar.Value)
fmt.Printf(" ✅ %-12s : %s\n", envVar.Name, envVar.Value)
} else {
log.Printf(" ❌ %-12s : not set or empty.\n", proxyName)
fmt.Printf(" ❌ %-12s : not set or empty.\n", proxyName)
}
}
}

0 comments on commit a25496b

Please sign in to comment.