Diff shows the difference bettwen the cluster and the index.
()
| 8 | |
| 9 | // Diff shows the difference bettwen the cluster and the index. |
| 10 | func (s SpreadCli) Diff() *cli.Command { |
| 11 | return &cli.Command{ |
| 12 | Name: "diff", |
| 13 | Usage: "spread diff", |
| 14 | Description: "Diffs index against state of cluster", |
| 15 | Flags: []cli.Flag{ |
| 16 | cli.StringFlag{ |
| 17 | Name: "context", |
| 18 | Value: "", |
| 19 | Usage: "kubectl context to use for requests", |
| 20 | }, |
| 21 | }, |
| 22 | Action: func(c *cli.Context) { |
| 23 | proj := s.projectOrDie() |
| 24 | docs, err := proj.Index() |
| 25 | if err != nil { |
| 26 | s.fatalf("Could not load Index: %v", err) |
| 27 | } |
| 28 | |
| 29 | index, err := deploy.DeploymentFromDocMap(docs) |
| 30 | if err != nil { |
| 31 | s.fatalf("Failed to create Deployment from Documents: %v", err) |
| 32 | } |
| 33 | |
| 34 | context := c.String("context") |
| 35 | client, err := deploy.NewKubeClusterFromContext(context) |
| 36 | if err != nil { |
| 37 | s.fatalf("Failed to connect to Kubernetes cluster: %v", err) |
| 38 | } |
| 39 | |
| 40 | cluster, err := client.Deployment() |
| 41 | if err != nil { |
| 42 | s.fatalf("Could not load deployment from cluster: %v", err) |
| 43 | } |
| 44 | |
| 45 | s.printf(index.Diff(cluster)) |
| 46 | }, |
| 47 | } |
| 48 | } |
nothing calls this directly
no test coverage detected