cli for status

This commit is contained in:
Morten Torkildsen
2019-12-05 08:57:40 -08:00
parent 54b1549586
commit 1b3b8522f9
15 changed files with 1490 additions and 54 deletions

View File

@@ -241,6 +241,46 @@ type ObjectMeta struct {
Annotations map[string]string `yaml:"annotations,omitempty"`
}
// GetIdentifier returns a ResourceIdentifier that includes
// the information needed to uniquely identify a resource in a cluster.
func (m *ResourceMeta) GetIdentifier() ResourceIdentifier {
return ResourceIdentifier{
Name: m.Name,
Namespace: m.Namespace,
APIVersion: m.APIVersion,
Kind: m.Kind,
}
}
// ResourceIdentifier contains the information needed to uniquely
// identify a resource in a cluster.
type ResourceIdentifier struct {
// Name is the name of the resource as set in metadata.name
Name string `yaml:"name,omitempty"`
// Namespace is the namespace of the resource as set in metadata.namespace
Namespace string `yaml:"namespace,omitempty"`
// ApiVersion is the apiVersion of the resource
APIVersion string `yaml:"apiVersion,omitempty"`
// Kind is the kind of the resource
Kind string `yaml:"kind,omitempty"`
}
func (r *ResourceIdentifier) GetName() string {
return r.Name
}
func (r *ResourceIdentifier) GetNamespace() string {
return r.Namespace
}
func (r *ResourceIdentifier) GetAPIVersion() string {
return r.APIVersion
}
func (r *ResourceIdentifier) GetKind() string {
return r.Kind
}
var ErrMissingMetadata = fmt.Errorf("missing Resource metadata")
// GetMeta returns the ResourceMeta for a RNode