Merge "Refactor getGvk to use document.Document methods"
This commit is contained in:
commit
be8ea35e6c
@ -76,10 +76,7 @@ func NewStatusMap(client client.Interface) (*StatusMap, error) {
|
|||||||
// GetStatusForResource iterates over all of the stored conditions for the
|
// GetStatusForResource iterates over all of the stored conditions for the
|
||||||
// resource and returns the first status whose conditions are met.
|
// resource and returns the first status whose conditions are met.
|
||||||
func (sm *StatusMap) GetStatusForResource(resource document.Document) (Status, error) {
|
func (sm *StatusMap) GetStatusForResource(resource document.Document) (Status, error) {
|
||||||
gvk, err := getGVK(resource)
|
gvk := getGVK(resource)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
restMapping, err := sm.restMapper.RESTMapping(gvk.GroupKind(), gvk.Version)
|
restMapping, err := sm.restMapper.RESTMapping(gvk.GroupKind(), gvk.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -150,20 +147,13 @@ func getGVRs(crd apiextensions.CustomResourceDefinition) []schema.GroupVersionRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getGVK constructs a schema.GroupVersionKind for a document
|
// getGVK constructs a schema.GroupVersionKind for a document
|
||||||
//
|
func getGVK(doc document.Document) schema.GroupVersionKind {
|
||||||
// TODO(howell): This should probably be a member method of the
|
toSchemaGvk := schema.GroupVersionKind{
|
||||||
// document.Document interface.
|
Group: doc.GetGroup(),
|
||||||
func getGVK(doc document.Document) (schema.GroupVersionKind, error) {
|
Version: doc.GetVersion(),
|
||||||
apiVersion, err := doc.GetString("apiVersion")
|
Kind: doc.GetKind(),
|
||||||
if err != nil {
|
|
||||||
return schema.GroupVersionKind{}, err
|
|
||||||
}
|
}
|
||||||
gv, err := schema.ParseGroupVersion(apiVersion)
|
return toSchemaGvk
|
||||||
if err != nil {
|
|
||||||
return schema.GroupVersionKind{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return gv.WithKind(doc.GetKind()), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseStatusChecks takes a string containing a map of status names (e.g.
|
// parseStatusChecks takes a string containing a map of status names (e.g.
|
||||||
|
Loading…
Reference in New Issue
Block a user