|
|
|
@ -16,7 +16,13 @@ limitations under the License.
|
|
|
|
|
|
|
|
|
|
package action
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
import (
|
|
|
|
|
"sort"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/chart"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// GetMetadata is the action for checking a given release's metadata.
|
|
|
|
|
//
|
|
|
|
@ -28,14 +34,16 @@ type GetMetadata struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Metadata struct {
|
|
|
|
|
Name string `json:"name" yaml:"name"`
|
|
|
|
|
Chart string `json:"chart" yaml:"chart"`
|
|
|
|
|
Version string `json:"version" yaml:"version"`
|
|
|
|
|
AppVersion string `json:"appVersion" yaml:"appVersion"`
|
|
|
|
|
Namespace string `json:"namespace" yaml:"namespace"`
|
|
|
|
|
Revision int `json:"revision" yaml:"revision"`
|
|
|
|
|
Status string `json:"status" yaml:"status"`
|
|
|
|
|
DeployedAt string `json:"deployedAt" yaml:"deployedAt"`
|
|
|
|
|
Name string `json:"name" yaml:"name"`
|
|
|
|
|
Chart string `json:"chart" yaml:"chart"`
|
|
|
|
|
Version string `json:"version" yaml:"version"`
|
|
|
|
|
AppVersion string `json:"appVersion" yaml:"appVersion"`
|
|
|
|
|
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
|
|
|
|
Dependencies []*chart.Dependency `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
|
|
|
|
|
Namespace string `json:"namespace" yaml:"namespace"`
|
|
|
|
|
Revision int `json:"revision" yaml:"revision"`
|
|
|
|
|
Status string `json:"status" yaml:"status"`
|
|
|
|
|
DeployedAt string `json:"deployedAt" yaml:"deployedAt"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewGetMetadata creates a new GetMetadata object with the given configuration.
|
|
|
|
@ -57,13 +65,26 @@ func (g *GetMetadata) Run(name string) (*Metadata, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &Metadata{
|
|
|
|
|
Name: rel.Name,
|
|
|
|
|
Chart: rel.Chart.Metadata.Name,
|
|
|
|
|
Version: rel.Chart.Metadata.Version,
|
|
|
|
|
AppVersion: rel.Chart.Metadata.AppVersion,
|
|
|
|
|
Namespace: rel.Namespace,
|
|
|
|
|
Revision: rel.Version,
|
|
|
|
|
Status: rel.Info.Status.String(),
|
|
|
|
|
DeployedAt: rel.Info.LastDeployed.Format(time.RFC3339),
|
|
|
|
|
Name: rel.Name,
|
|
|
|
|
Chart: rel.Chart.Metadata.Name,
|
|
|
|
|
Version: rel.Chart.Metadata.Version,
|
|
|
|
|
AppVersion: rel.Chart.Metadata.AppVersion,
|
|
|
|
|
Dependencies: rel.Chart.Metadata.Dependencies,
|
|
|
|
|
Annotations: rel.Chart.Metadata.Annotations,
|
|
|
|
|
Namespace: rel.Namespace,
|
|
|
|
|
Revision: rel.Version,
|
|
|
|
|
Status: rel.Info.Status.String(),
|
|
|
|
|
DeployedAt: rel.Info.LastDeployed.Format(time.RFC3339),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FormattedDepNames formats metadata.dependencies names into a comma-separated list.
|
|
|
|
|
func (m *Metadata) FormattedDepNames() string {
|
|
|
|
|
depsNames := make([]string, 0, len(m.Dependencies))
|
|
|
|
|
for _, dep := range m.Dependencies {
|
|
|
|
|
depsNames = append(depsNames, dep.Name)
|
|
|
|
|
}
|
|
|
|
|
sort.StringSlice(depsNames).Sort()
|
|
|
|
|
|
|
|
|
|
return strings.Join(depsNames, ",")
|
|
|
|
|
}
|
|
|
|
|