...
1
16
17 package action
18
19 import "time"
20
21
22
23
24 type GetMetadata struct {
25 cfg *Configuration
26
27 Version int
28 }
29
30 type Metadata struct {
31 Name string `json:"name" yaml:"name"`
32 Chart string `json:"chart" yaml:"chart"`
33 Version string `json:"version" yaml:"version"`
34 AppVersion string `json:"appVersion" yaml:"appVersion"`
35 Namespace string `json:"namespace" yaml:"namespace"`
36 Revision int `json:"revision" yaml:"revision"`
37 Status string `json:"status" yaml:"status"`
38 DeployedAt string `json:"deployedAt" yaml:"deployedAt"`
39 }
40
41
42 func NewGetMetadata(cfg *Configuration) *GetMetadata {
43 return &GetMetadata{
44 cfg: cfg,
45 }
46 }
47
48
49 func (g *GetMetadata) Run(name string) (*Metadata, error) {
50 if err := g.cfg.KubeClient.IsReachable(); err != nil {
51 return nil, err
52 }
53
54 rel, err := g.cfg.releaseContent(name, g.Version)
55 if err != nil {
56 return nil, err
57 }
58
59 return &Metadata{
60 Name: rel.Name,
61 Chart: rel.Chart.Metadata.Name,
62 Version: rel.Chart.Metadata.Version,
63 AppVersion: rel.Chart.Metadata.AppVersion,
64 Namespace: rel.Namespace,
65 Revision: rel.Version,
66 Status: rel.Info.Status.String(),
67 DeployedAt: rel.Info.LastDeployed.Format(time.RFC3339),
68 }, nil
69 }
70
View as plain text