Status returns information about the current state of the project.
()
| 8 | |
| 9 | // Status returns information about the current state of the project. |
| 10 | func (s SpreadCli) Status() *cli.Command { |
| 11 | return &cli.Command{ |
| 12 | Name: "status", |
| 13 | Usage: "spread status", |
| 14 | Description: "Information about what's commited, changed, and staged.", |
| 15 | Action: func(c *cli.Context) { |
| 16 | proj := s.projectOrDie() |
| 17 | indexDocs, err := proj.Index() |
| 18 | if err != nil { |
| 19 | s.fatalf("Could not load Index: %v", err) |
| 20 | } |
| 21 | |
| 22 | index, err := deploy.DeploymentFromDocMap(indexDocs) |
| 23 | if err != nil { |
| 24 | s.fatalf("Failed to create KubeObject from index doc: %v", err) |
| 25 | } |
| 26 | |
| 27 | var head *deploy.Deployment |
| 28 | headDocs, err := proj.Head() |
| 29 | if err == nil { |
| 30 | head, err = deploy.DeploymentFromDocMap(headDocs) |
| 31 | if err != nil { |
| 32 | s.fatalf("Failed to create KubeObject from HEAD doc: %v", err) |
| 33 | } |
| 34 | } else { |
| 35 | head = new(deploy.Deployment) |
| 36 | } |
| 37 | |
| 38 | client, err := deploy.NewKubeClusterFromContext("") |
| 39 | if err != nil { |
| 40 | s.fatalf("Failed to connect to Kubernetes cluster: %v", err) |
| 41 | } |
| 42 | |
| 43 | cluster, err := client.Deployment() |
| 44 | if err != nil { |
| 45 | s.fatalf("Could not load deployment from cluster: %v", err) |
| 46 | } |
| 47 | |
| 48 | stat := deploy.Stat(index, head, cluster) |
| 49 | s.printStatus(stat) |
| 50 | }, |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | func (s SpreadCli) printStatus(status deploy.DiffStat) { |
| 55 | s.printf("From Index:") |
nothing calls this directly
no test coverage detected