MCPcopy
hub / github.com/redspread/spread / Diff

Method Diff

cli/diff.go:10–48  ·  view source on GitHub ↗

Diff shows the difference bettwen the cluster and the index.

()

Source from the content-addressed store, hash-verified

8
9// Diff shows the difference bettwen the cluster and the index.
10func (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}

Callers

nothing calls this directly

Calls 6

projectOrDieMethod · 0.95
fatalfMethod · 0.95
printfMethod · 0.95
IndexMethod · 0.80
DeploymentMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected