@@ -16,7 +16,13 @@ limitations under the License.
16
16
17
17
package action
18
18
19
- import "time"
19
+ import (
20
+ "sort"
21
+ "strings"
22
+ "time"
23
+
24
+ "helm.sh/helm/v3/pkg/chart"
25
+ )
20
26
21
27
// GetMetadata is the action for checking a given release's metadata.
22
28
//
@@ -28,14 +34,16 @@ type GetMetadata struct {
28
34
}
29
35
30
36
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"`
37
+ Name string `json:"name" yaml:"name"`
38
+ Chart string `json:"chart" yaml:"chart"`
39
+ Version string `json:"version" yaml:"version"`
40
+ AppVersion string `json:"appVersion" yaml:"appVersion"`
41
+ Annotations map [string ]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
42
+ Dependencies []* chart.Dependency `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
43
+ Namespace string `json:"namespace" yaml:"namespace"`
44
+ Revision int `json:"revision" yaml:"revision"`
45
+ Status string `json:"status" yaml:"status"`
46
+ DeployedAt string `json:"deployedAt" yaml:"deployedAt"`
39
47
}
40
48
41
49
// NewGetMetadata creates a new GetMetadata object with the given configuration.
@@ -57,13 +65,26 @@ func (g *GetMetadata) Run(name string) (*Metadata, error) {
57
65
}
58
66
59
67
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
+ Name : rel .Name ,
69
+ Chart : rel .Chart .Metadata .Name ,
70
+ Version : rel .Chart .Metadata .Version ,
71
+ AppVersion : rel .Chart .Metadata .AppVersion ,
72
+ Dependencies : rel .Chart .Metadata .Dependencies ,
73
+ Annotations : rel .Chart .Metadata .Annotations ,
74
+ Namespace : rel .Namespace ,
75
+ Revision : rel .Version ,
76
+ Status : rel .Info .Status .String (),
77
+ DeployedAt : rel .Info .LastDeployed .Format (time .RFC3339 ),
68
78
}, nil
69
79
}
80
+
81
+ // FormattedDepNames formats metadata.dependencies names into a comma-separated list.
82
+ func (m * Metadata ) FormattedDepNames () string {
83
+ depsNames := make ([]string , 0 , len (m .Dependencies ))
84
+ for _ , dep := range m .Dependencies {
85
+ depsNames = append (depsNames , dep .Name )
86
+ }
87
+ sort .StringSlice (depsNames ).Sort ()
88
+
89
+ return strings .Join (depsNames , "," )
90
+ }
0 commit comments