Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(output/tap): Output qualified resource name #88

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added kubeconform
Binary file not shown.
7 changes: 4 additions & 3 deletions pkg/output/tap.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ func (o *tapo) Write(res validator.Result) error {
switch res.Status {
case validator.Valid:
sig, _ := res.Resource.Signature()
fmt.Fprintf(o.w, "ok %d - %s (%s)\n", o.index, res.Resource.Path, sig.Kind)
fmt.Fprintf(o.w, "ok %d - %s (%s)\n", o.index, res.Resource.Path, sig.QualifiedName())

case validator.Invalid:
sig, _ := res.Resource.Signature()
fmt.Fprintf(o.w, "not ok %d - %s (%s): %s\n", o.index, res.Resource.Path, sig.Kind, res.Err.Error())
fmt.Fprintf(o.w, "not ok %d - %s (%s): %s\n", o.index, res.Resource.Path, sig.QualifiedName(), res.Err.Error())

case validator.Empty:
fmt.Fprintf(o.w, "ok %d - %s (empty)\n", o.index, res.Resource.Path)
Expand All @@ -53,7 +53,8 @@ func (o *tapo) Write(res validator.Result) error {
fmt.Fprintf(o.w, "not ok %d - %s: %s\n", o.index, res.Resource.Path, res.Err.Error())

case validator.Skipped:
fmt.Fprintf(o.w, "ok %d #skip - %s\n", o.index, res.Resource.Path)
sig, _ := res.Resource.Signature()
fmt.Fprintf(o.w, "ok %d - %s (%s) # skip\n", o.index, res.Resource.Path, sig.QualifiedName())
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/output/tap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ metadata:
Err: nil,
},
},
"TAP version 13\nok 1 - deployment.yml (Deployment)\n1..1\n",
"TAP version 13\nok 1 - deployment.yml (apps/v1/Deployment//my-app)\n1..1\n",
},
{
"a single deployment, verbose, with summary",
Expand All @@ -57,7 +57,7 @@ metadata:
Err: nil,
},
},
"TAP version 13\nok 1 - deployment.yml (Deployment)\n1..1\n",
"TAP version 13\nok 1 - deployment.yml (apps/v1/Deployment//my-app)\n1..1\n",
},
} {
w := new(bytes.Buffer)
Expand Down
5 changes: 5 additions & 0 deletions pkg/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,8 @@ func (res *Resource) Resources() []Resource {

return []Resource{*res}
}

// QualifiedName returns a string for a signature in the format version/kind/namespace/name
func (sig *Signature) QualifiedName() string {
return fmt.Sprintf("%s/%s/%s/%s", sig.Version, sig.Kind, sig.Namespace, sig.Name)
yannh marked this conversation as resolved.
Show resolved Hide resolved
}