Skip to content

Commit

Permalink
Merge pull request #3962 from natasha41575/resourceRef
Browse files Browse the repository at this point in the history
remove metadata field from resourceRef schema
  • Loading branch information
k8s-ci-robot authored Jun 3, 2021
2 parents da1bd90 + 0205090 commit 0305860
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
12 changes: 7 additions & 5 deletions kyaml/fn/framework/command/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,12 @@ func ExampleBuild_validate() {
continue
}
validationResults = append(validationResults, framework.ResultItem{
Severity: framework.Error,
Message: "field is required",
ResourceRef: meta,
Severity: framework.Error,
Message: "field is required",
ResourceRef: yaml.ResourceIdentifier{
TypeMeta: meta.TypeMeta,
NameMeta: meta.ObjectMeta.NameMeta,
},
Field: framework.Field{
Path: "spec.replicas",
SuggestedValue: "1",
Expand Down Expand Up @@ -374,8 +377,7 @@ items:
// resourceRef:
// apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: foo
// name: foo
// field:
// path: spec.replicas
// suggestedValue: "1"
Expand Down
11 changes: 4 additions & 7 deletions kyaml/fn/framework/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ func TestExecute_Result(t *testing.T) {
{
Message: "bad value for replicas",
Severity: framework.Error,
ResourceRef: yaml.ResourceMeta{
ResourceRef: yaml.ResourceIdentifier{
TypeMeta: yaml.TypeMeta{APIVersion: "v1", Kind: "Deployment"},
ObjectMeta: yaml.ObjectMeta{
NameMeta: yaml.NameMeta{Name: "tester", Namespace: "default"},
},
NameMeta: yaml.NameMeta{Name: "tester", Namespace: "default"},
},
Field: framework.Field{
Path: ".spec.Replicas",
Expand Down Expand Up @@ -83,9 +81,8 @@ results:
resourceRef:
apiVersion: v1
kind: Deployment
metadata:
name: tester
namespace: default
name: tester
namespace: default
field:
path: .spec.Replicas
currentValue: "0"
Expand Down
4 changes: 2 additions & 2 deletions kyaml/fn/framework/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ResultItem struct {
Severity Severity `yaml:"severity,omitempty"`

// ResourceRef is a reference to a resource
ResourceRef yaml.ResourceMeta `yaml:"resourceRef,omitempty"`
ResourceRef yaml.ResourceIdentifier `yaml:"resourceRef,omitempty"`

// Field is a reference to the field in a resource this result refers to
Field Field `yaml:"field,omitempty"`
Expand All @@ -42,7 +42,7 @@ type ResultItem struct {

// String provides a human-readable message for the result item
func (i ResultItem) String() string {
identifier := i.ResourceRef.GetIdentifier()
identifier := i.ResourceRef
var idStringList []string
if identifier.APIVersion != "" {
idStringList = append(idStringList, identifier.APIVersion)
Expand Down

0 comments on commit 0305860

Please sign in to comment.