Skip to content

Commit

Permalink
fix: Improve error message when missing required fields in resource m…
Browse files Browse the repository at this point in the history
…anifest (#5578)
  • Loading branch information
terrytangyuan authored Apr 6, 2021
1 parent 4f3bbdc commit 2651bd6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions workflow/executor/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ func (we *WorkflowExecutor) ExecResource(action string, manifestPath string, fla
if err != nil {
return "", "", "", err
}
resourceName := fmt.Sprintf("%s.%s/%s", obj.GroupVersionKind().Kind, obj.GroupVersionKind().Group, obj.GetName())
resourceGroup := obj.GroupVersionKind().Group
resourceName := obj.GetName()
resourceKind := obj.GroupVersionKind().Kind
if resourceGroup == "" || resourceName == "" || resourceKind == "" {
return "", "", "", errors.New(errors.CodeBadRequest, "Group, kind, and name are all required but at least one of them is missing from the manifest")
}
resourceFullName := fmt.Sprintf("%s.%s/%s", resourceKind, resourceGroup, resourceName)
selfLink := obj.GetSelfLink()
log.Infof("Resource: %s/%s. SelfLink: %s", obj.GetNamespace(), resourceName, selfLink)
return obj.GetNamespace(), resourceName, selfLink, nil
log.Infof("Resource: %s/%s. SelfLink: %s", obj.GetNamespace(), resourceFullName, selfLink)
return obj.GetNamespace(), resourceFullName, selfLink, nil
}

func (we *WorkflowExecutor) getKubectlArguments(action string, manifestPath string, flags []string) ([]string, error) {
Expand Down

0 comments on commit 2651bd6

Please sign in to comment.