File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package deploy
2+
3+ import (
4+ "fmt"
5+ "os/exec"
6+ "strings"
7+ )
8+
9+ func Status (envName string ) error {
10+
11+ environment , err := LoadEnvironment (envName )
12+ if err != nil {
13+ return err
14+ }
15+
16+ ns := environment .K8s .Namespace
17+ ctx := environment .K8s .Context
18+ release := environment .Helm .Release
19+
20+ fmt .Println ("Deployment Status" )
21+ fmt .Println ("-----------------" )
22+ fmt .Println ("Environment:" , envName )
23+ fmt .Println ("Namespace:" , ns )
24+ fmt .Println ("Release:" , release )
25+ fmt .Println ()
26+
27+ // Helm Status
28+ args := []string {
29+ "status" ,
30+ release ,
31+ "-n" ,
32+ ns ,
33+ }
34+
35+ if ctx != "" {
36+ args = append (args , "--kube-context" , ctx )
37+ }
38+
39+ cmd := exec .Command ("helm" , args ... )
40+ out , err := cmd .CombinedOutput ()
41+ if err != nil {
42+ fmt .Println ("Helm status not available" )
43+ } else {
44+ fmt .Println (string (out ))
45+ }
46+
47+ // Pods
48+ fmt .Println ("Pods:" )
49+ podArgs := []string {
50+ "get" ,
51+ "pods" ,
52+ "-n" ,
53+ ns ,
54+ "-o" ,
55+ "wide" ,
56+ }
57+
58+ if ctx != "" {
59+ podArgs = append (podArgs , "--context" , ctx )
60+ }
61+
62+ podCmd := exec .Command ("kubectl" , podArgs ... )
63+ podsOut , err := podCmd .CombinedOutput ()
64+ if err != nil {
65+ fmt .Println ("Unable to fetch pods" )
66+ } else {
67+ fmt .Println (strings .TrimSpace (string (podsOut )))
68+ }
69+
70+ return nil
71+ }
You can’t perform that action at this time.
0 commit comments