Skip to content

Commit

Permalink
Skip invalid YAML when detecting packages
Browse files Browse the repository at this point in the history
  • Loading branch information
blampe committed Oct 29, 2024
1 parent ca55909 commit 57c0508
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).

## Unreleased

### Bug Fixes

- [runtime] Invalid YAML files no longer cause package detection to fail. [#665](https://github.com/pulumi/pulumi-yaml/pull/665)

## v1.11.1 - 2024-10-10

### Bug Fixes
Expand Down
5 changes: 2 additions & 3 deletions pkg/pulumiyaml/packages/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ func SearchPackageDecls(directory string) ([]PackageDecl, error) {
return fmt.Errorf("reading %s: %w", path, err)
}

// If the file is not valid skip it
var packageDecl PackageDecl
if err := yaml.Unmarshal(data, &packageDecl); err != nil {
return fmt.Errorf("unmarshalling %s: %w", path, err)
return nil
}

// If the file is not valid skip it
ok, err := packageDecl.Validate()
if !ok {
return nil
Expand Down
13 changes: 13 additions & 0 deletions pkg/pulumiyaml/packages/testdata/good/ignored.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "mychart.serviceAccountName" . }}
labels:
{{- include "mychart.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}

0 comments on commit 57c0508

Please sign in to comment.