mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-15 16:07:02 +00:00
feat(output/tap): Output qualified resource name
This commit is contained in:
parent
c1b3e93a75
commit
ff2ab3d770
4 changed files with 11 additions and 5 deletions
BIN
kubeconform
Executable file
BIN
kubeconform
Executable file
Binary file not shown.
|
|
@ -40,11 +40,11 @@ func (o *tapo) Write(res validator.Result) error {
|
||||||
switch res.Status {
|
switch res.Status {
|
||||||
case validator.Valid:
|
case validator.Valid:
|
||||||
sig, _ := res.Resource.Signature()
|
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:
|
case validator.Invalid:
|
||||||
sig, _ := res.Resource.Signature()
|
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:
|
case validator.Empty:
|
||||||
fmt.Fprintf(o.w, "ok %d - %s (empty)\n", o.index, res.Resource.Path)
|
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())
|
fmt.Fprintf(o.w, "not ok %d - %s: %s\n", o.index, res.Resource.Path, res.Err.Error())
|
||||||
|
|
||||||
case validator.Skipped:
|
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
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ metadata:
|
||||||
Err: nil,
|
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",
|
"a single deployment, verbose, with summary",
|
||||||
|
|
@ -57,7 +57,7 @@ metadata:
|
||||||
Err: nil,
|
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)
|
w := new(bytes.Buffer)
|
||||||
|
|
|
||||||
|
|
@ -119,3 +119,8 @@ func (res *Resource) Resources() []Resource {
|
||||||
|
|
||||||
return []Resource{*res}
|
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)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue