Skip to content

Commit c32562e

Browse files
authoredDec 18, 2021
Merge pull request #88 from maxbrunet/feature/output-tap/qualified-name
feat(output/tap): Output qualified resource name
2 parents c1b3e93 + ff2ab3d commit c32562e

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed
 

‎kubeconform

9.42 MB
Binary file not shown.

‎pkg/output/tap.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ func (o *tapo) Write(res validator.Result) error {
4040
switch res.Status {
4141
case validator.Valid:
4242
sig, _ := res.Resource.Signature()
43-
fmt.Fprintf(o.w, "ok %d - %s (%s)\n", o.index, res.Resource.Path, sig.Kind)
43+
fmt.Fprintf(o.w, "ok %d - %s (%s)\n", o.index, res.Resource.Path, sig.QualifiedName())
4444

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

4949
case validator.Empty:
5050
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 {
5353
fmt.Fprintf(o.w, "not ok %d - %s: %s\n", o.index, res.Resource.Path, res.Err.Error())
5454

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

5960
return nil

‎pkg/output/tap_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ metadata:
3636
Err: nil,
3737
},
3838
},
39-
"TAP version 13\nok 1 - deployment.yml (Deployment)\n1..1\n",
39+
"TAP version 13\nok 1 - deployment.yml (apps/v1/Deployment//my-app)\n1..1\n",
4040
},
4141
{
4242
"a single deployment, verbose, with summary",
@@ -57,7 +57,7 @@ metadata:
5757
Err: nil,
5858
},
5959
},
60-
"TAP version 13\nok 1 - deployment.yml (Deployment)\n1..1\n",
60+
"TAP version 13\nok 1 - deployment.yml (apps/v1/Deployment//my-app)\n1..1\n",
6161
},
6262
} {
6363
w := new(bytes.Buffer)

‎pkg/resource/resource.go

+5
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,8 @@ func (res *Resource) Resources() []Resource {
119119

120120
return []Resource{*res}
121121
}
122+
123+
// QualifiedName returns a string for a signature in the format version/kind/namespace/name
124+
func (sig *Signature) QualifiedName() string {
125+
return fmt.Sprintf("%s/%s/%s/%s", sig.Version, sig.Kind, sig.Namespace, sig.Name)
126+
}

0 commit comments

Comments
 (0)
Please sign in to comment.