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

match all k8s list resources #606

Merged
merged 1 commit into from
May 9, 2024
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
2 changes: 1 addition & 1 deletion manifest/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func parseContent(content string, defaultNamespace string, normalizeManifests bo
return nil, nil
}

if parsedMetadata.Kind == "List" {
if strings.HasSuffix(parsedMetadata.Kind, "List") {
type ListV1 struct {
Items []yaml.MapSlice `yaml:"items"`
}
Expand Down
26 changes: 26 additions & 0 deletions manifest/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,32 @@ func TestList(t *testing.T) {
)
}

func TestConfigMapList(t *testing.T) {
spec, err := os.ReadFile("testdata/configmaplist_v1.yaml")
require.NoError(t, err)

require.Equal(t,
[]string{
"default, configmap-2-1, ConfigMap (v1)",
"default, configmap-2-2, ConfigMap (v1)",
},
foundObjects(Parse(string(spec), "default", false)),
)
}

func TestSecretList(t *testing.T) {
spec, err := os.ReadFile("testdata/secretlist_v1.yaml")
require.NoError(t, err)

require.Equal(t,
[]string{
"default, my-secret-1, Secret (v1)",
"default, my-secret-2, Secret (v1)",
},
foundObjects(Parse(string(spec), "default", false)),
)
}

func TestEmpty(t *testing.T) {
spec, err := os.ReadFile("testdata/empty.yaml")
require.NoError(t, err)
Expand Down
15 changes: 15 additions & 0 deletions manifest/testdata/configmaplist_v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMapList
items:
- apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-2-1
data:
key1: data1
- apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-2-2
data:
key2: data2
18 changes: 18 additions & 0 deletions manifest/testdata/secretlist_v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: SecretList
items:
- apiVersion: v1
kind: Secret
metadata:
name: my-secret-1
type: Opaque
data:
username: YWRtaW4=
password: MWYyZDFlMmU2N2Rm
- apiVersion: v1
kind: Secret
metadata:
name: my-secret-2
type: Opaque
data:
token: ZXlKaGJHY2lPaUpTVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SjFhV1FpT2pFc0luUnBiV1VpT2pFMU56RXlPRGd3TmpFeE1qQXdNVGN5TWpFeE1qQXdNVEE0TWpVMUxDSmhiR2NpT2lKSVV6STFOaUo5LmV5SjFhV1FpT2pFc0luUnBiV1VpT2pFMU56RXlPRGd3TmpFeE1qQXdNVGN5TWpFeE1qQXdNVEE0TWpVMUxDSmhiR2NpT2lKSVV6STFOaUo=
Loading