Skip to content

Commit

Permalink
Fix Unknown warning message
Browse files Browse the repository at this point in the history
Directly show stdout/stderr of helm template command output
  • Loading branch information
jlandowner committed Apr 9, 2024
1 parent 3d877fd commit d500fad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
11 changes: 3 additions & 8 deletions pkg/unstructured/__snapshots__/suite_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,7 @@ SnapShot = """
SnapShot = """
WARN: failed to recognize a resource in stdout/stderr of helm template command output. snapshot it as Unknown:
---
object:
apiVersion: helm-chartsnap.jlandowner.dev/v1alpha1
kind: Unknown
raw: |-
some: raw data
raw:
data: here

some: raw data
raw:
data: here
---"""
7 changes: 1 addition & 6 deletions pkg/unstructured/unknown.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
yaml "sigs.k8s.io/yaml/goyaml.v3"
)

var (
Expand All @@ -22,11 +21,7 @@ type UnknownError struct {
}

func (e *UnknownError) Error() string {
out, err := yaml.Marshal(e.Unstructured())
if err != nil {
panic(err)
}
return fmt.Sprintf("WARN: failed to recognize a resource in stdout/stderr of helm template command output. snapshot it as Unknown: \n---\n%s\n---", out)
return fmt.Sprintf("WARN: failed to recognize a resource in stdout/stderr of helm template command output. snapshot it as Unknown: \n---\n%s\n---", e.Raw)
}

func (e *UnknownError) Unstructured() *metaV1.Unstructured {
Expand Down

0 comments on commit d500fad

Please sign in to comment.