feat(output/tap): Output qualified resource name

This commit is contained in:
Maxime Brunet 2021-12-17 19:08:40 -08:00
parent c1b3e93a75
commit ff2ab3d770
No known key found for this signature in database
GPG key ID: 757B11B65F872567
4 changed files with 11 additions and 5 deletions

BIN
kubeconform Executable file

Binary file not shown.

View file

@ -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)
@ -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

View file

@ -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",
@ -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)

View file

@ -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)
}