@ -16,7 +16,13 @@ limitations under the License.
package action
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.
// GetMetadata is the action for checking a given release's metadata.
//
//
@ -28,14 +34,16 @@ type GetMetadata struct {
}
}
type Metadata struct {
type Metadata struct {
Name string ` json:"name" yaml:"name" `
Name string ` json:"name" yaml:"name" `
Chart string ` json:"chart" yaml:"chart" `
Chart string ` json:"chart" yaml:"chart" `
Version string ` json:"version" yaml:"version" `
Version string ` json:"version" yaml:"version" `
AppVersion string ` json:"appVersion" yaml:"appVersion" `
AppVersion string ` json:"appVersion" yaml:"appVersion" `
Namespace string ` json:"namespace" yaml:"namespace" `
Annotations map [ string ] string ` json:"annotations,omitempty" yaml:"annotations,omitempty" `
Revision int ` json:"revision" yaml:"revision" `
Dependencies [ ] * chart . Dependency ` json:"dependencies,omitempty" yaml:"dependencies,omitempty" `
Status string ` json:"status" yaml:"status" `
Namespace string ` json:"namespace" yaml:"namespace" `
DeployedAt string ` json:"deployedAt" yaml:"deployedAt" `
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.
// NewGetMetadata creates a new GetMetadata object with the given configuration.
@ -57,13 +65,26 @@ func (g *GetMetadata) Run(name string) (*Metadata, error) {
}
}
return & Metadata {
return & Metadata {
Name : rel . Name ,
Name : rel . Name ,
Chart : rel . Chart . Metadata . Name ,
Chart : rel . Chart . Metadata . Name ,
Version : rel . Chart . Metadata . Version ,
Version : rel . Chart . Metadata . Version ,
AppVersion : rel . Chart . Metadata . AppVersion ,
AppVersion : rel . Chart . Metadata . AppVersion ,
Namespace : rel . Namespace ,
Dependencies : rel . Chart . Metadata . Dependencies ,
Revision : rel . Version ,
Annotations : rel . Chart . Metadata . Annotations ,
Status : rel . Info . Status . String ( ) ,
Namespace : rel . Namespace ,
DeployedAt : rel . Info . LastDeployed . Format ( time . RFC3339 ) ,
Revision : rel . Version ,
Status : rel . Info . Status . String ( ) ,
DeployedAt : rel . Info . LastDeployed . Format ( time . RFC3339 ) ,
} , nil
} , 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 , "," )
}