You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	feat(yaml): upgraded from yaml.v2 to yaml.v3 (#3004)
* chore(yaml): upgraded from yaml.v2 to yaml.v3
* provided internal package to take care of backward
  compatible settings:
    * UnmarshalStrict method
    * mute io.EOF unmarshaling errors
    * marshal indenting with 2 chars
* adapted unit tests to new yaml v3
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
* fixed failing tests
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
			
			
This commit is contained in:
		
							
								
								
									
										4
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.mod
									
									
									
									
									
								
							| @@ -38,7 +38,7 @@ require ( | ||||
| 	golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 | ||||
| 	golang.org/x/sync v0.0.0-20210220032951-036812b2e83c | ||||
| 	gopkg.in/mail.v2 v2.3.1 | ||||
| 	gopkg.in/yaml.v2 v2.4.0 | ||||
| 	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| @@ -147,5 +147,5 @@ require ( | ||||
| 	google.golang.org/protobuf v1.27.1 // indirect | ||||
| 	gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect | ||||
| 	gopkg.in/warnings.v0 v0.1.2 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||||
| 	gopkg.in/yaml.v2 v2.4.0 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -5,8 +5,8 @@ import ( | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"github.com/apex/log" | ||||
| 	"github.com/goreleaser/goreleaser/internal/yaml" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/context" | ||||
| 	yaml "gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| // Pipe that writes the effective config file to dist. | ||||
|   | ||||
| @@ -19,9 +19,9 @@ import ( | ||||
| 	"github.com/goreleaser/goreleaser/internal/commitauthor" | ||||
| 	"github.com/goreleaser/goreleaser/internal/pipe" | ||||
| 	"github.com/goreleaser/goreleaser/internal/tmpl" | ||||
| 	"github.com/goreleaser/goreleaser/internal/yaml" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/config" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/context" | ||||
| 	"gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -5,48 +5,48 @@ metadata: | ||||
| spec: | ||||
|   version: v0.1.3 | ||||
|   platforms: | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: arm64 | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: amd64 | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm64 | ||||
|   - bin: test.exe | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_windows_amd64.zip | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: windows | ||||
|         arch: amd64 | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: arm64 | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: amd64 | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm64 | ||||
|     - bin: test.exe | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_windows_amd64.zip | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: windows | ||||
|           arch: amd64 | ||||
|   shortDescription: Short desc | ||||
|   homepage: https://google.com | ||||
|   caveats: some caveat | ||||
|   | ||||
| @@ -5,13 +5,13 @@ metadata: | ||||
| spec: | ||||
|   version: v1.0.1 | ||||
|   platforms: | ||||
|   - bin: name | ||||
|     uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|     - bin: name | ||||
|       uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|   shortDescription: short desc honk | ||||
|   homepage: https://github.com/goreleaser | ||||
|   description: A run pipe test krew manifest and FOO=foo_is_bar | ||||
|   | ||||
| @@ -5,13 +5,13 @@ metadata: | ||||
| spec: | ||||
|   version: v1.0.1 | ||||
|   platforms: | ||||
|   - bin: name | ||||
|     uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|     - bin: name | ||||
|       uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|   shortDescription: short desc honk | ||||
|   homepage: https://gitlab.com/goreleaser | ||||
|   description: A run pipe test krew manifest and FOO=foo_is_bar | ||||
|   | ||||
| @@ -5,27 +5,27 @@ metadata: | ||||
| spec: | ||||
|   version: v1.0.1 | ||||
|   platforms: | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/armv5.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/arm64.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm64 | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/armv5.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/arm64.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm64 | ||||
|   shortDescription: Short desc | ||||
|   homepage: https://github.com/goreleaser | ||||
|   description: A run pipe test krew manifest and FOO=foo_is_bar | ||||
|   | ||||
| @@ -5,27 +5,27 @@ metadata: | ||||
| spec: | ||||
|   version: v1.0.1 | ||||
|   platforms: | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/armv6.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/arm64.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm64 | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/armv6.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/arm64.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm64 | ||||
|   shortDescription: Short desc | ||||
|   homepage: https://github.com/goreleaser | ||||
|   description: A run pipe test krew manifest and FOO=foo_is_bar | ||||
|   | ||||
| @@ -5,27 +5,27 @@ metadata: | ||||
| spec: | ||||
|   version: v1.0.1 | ||||
|   platforms: | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/armv7.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/arm64.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm64 | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/armv7.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/arm64.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm64 | ||||
|   shortDescription: Short desc | ||||
|   homepage: https://github.com/goreleaser | ||||
|   description: A run pipe test krew manifest and FOO=foo_is_bar | ||||
|   | ||||
| @@ -5,12 +5,12 @@ metadata: | ||||
| spec: | ||||
|   version: v1.0.1 | ||||
|   platforms: | ||||
|   - bin: foo | ||||
|     uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|     - bin: foo | ||||
|       uri: https://dummyhost/download/v1.0.1/bin.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|   shortDescription: Short desc | ||||
|   description: Some desc | ||||
|   | ||||
| @@ -5,19 +5,19 @@ metadata: | ||||
| spec: | ||||
|   version: v1.0.1 | ||||
|   platforms: | ||||
|   - bin: unibin | ||||
|     uri: https://dummyhost/download/v1.0.1/unibin.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|   - bin: unibin | ||||
|     uri: https://dummyhost/download/v1.0.1/unibin.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: arm64 | ||||
|     - bin: unibin | ||||
|       uri: https://dummyhost/download/v1.0.1/unibin.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|     - bin: unibin | ||||
|       uri: https://dummyhost/download/v1.0.1/unibin.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: arm64 | ||||
|   shortDescription: Short desc | ||||
|   description: Some desc | ||||
|   | ||||
| @@ -5,19 +5,19 @@ metadata: | ||||
| spec: | ||||
|   version: v1.0.1 | ||||
|   platforms: | ||||
|   - bin: unibin | ||||
|     uri: https://dummyhost/download/v1.0.1/unibin_amd64.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|   - bin: unibin | ||||
|     uri: https://dummyhost/download/v1.0.1/unibin_amd64.tar.gz | ||||
|     sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: arm64 | ||||
|     - bin: unibin | ||||
|       uri: https://dummyhost/download/v1.0.1/unibin_amd64.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|     - bin: unibin | ||||
|       uri: https://dummyhost/download/v1.0.1/unibin_amd64.tar.gz | ||||
|       sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: arm64 | ||||
|   shortDescription: Short desc | ||||
|   description: Some desc | ||||
|   | ||||
							
								
								
									
										84
									
								
								internal/pipe/krew/testdata/TestSimple.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										84
									
								
								internal/pipe/krew/testdata/TestSimple.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -5,48 +5,48 @@ metadata: | ||||
| spec: | ||||
|   version: v0.1.3 | ||||
|   platforms: | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: amd64 | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: darwin | ||||
|         arch: arm64 | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: amd64 | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm | ||||
|   - bin: test | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: linux | ||||
|         arch: arm64 | ||||
|   - bin: test.exe | ||||
|     uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_windows_amd64.zip | ||||
|     sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|     selector: | ||||
|       matchLabels: | ||||
|         os: windows | ||||
|         arch: amd64 | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: amd64 | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: darwin | ||||
|           arch: arm64 | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: amd64 | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm | ||||
|     - bin: test | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: linux | ||||
|           arch: arm64 | ||||
|     - bin: test.exe | ||||
|       uri: https://github.com/caarlos0/test/releases/download/v0.1.3/test_windows_amd64.zip | ||||
|       sha256: 1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67 | ||||
|       selector: | ||||
|         matchLabels: | ||||
|           os: windows | ||||
|           arch: amd64 | ||||
|   shortDescription: Short desc | ||||
|   homepage: https://google.com | ||||
|   caveats: some caveat | ||||
|   | ||||
| @@ -12,7 +12,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/apex/log" | ||||
| 	"gopkg.in/yaml.v2" | ||||
| 	"github.com/goreleaser/goreleaser/internal/yaml" | ||||
|  | ||||
| 	"github.com/goreleaser/goreleaser/internal/artifact" | ||||
| 	"github.com/goreleaser/goreleaser/internal/gio" | ||||
|   | ||||
| @@ -10,10 +10,10 @@ import ( | ||||
| 	"github.com/goreleaser/goreleaser/internal/gio" | ||||
| 	"github.com/goreleaser/goreleaser/internal/pipe" | ||||
| 	"github.com/goreleaser/goreleaser/internal/testlib" | ||||
| 	"github.com/goreleaser/goreleaser/internal/yaml" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/config" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/context" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| 	"gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| func TestDescription(t *testing.T) { | ||||
| @@ -273,7 +273,7 @@ func TestRunPipeMetadata(t *testing.T) { | ||||
| 			RestartDelay:     "42ms", | ||||
| 			Slots:            []string{"foo_slot"}, | ||||
| 			Sockets: map[string]interface{}{ | ||||
| 				"sock": map[interface{}]interface{}{ | ||||
| 				"sock": map[string]interface{}{ | ||||
| 					"listen-stream": "$SNAP_COMMON/socket", | ||||
| 					"socket-group":  "socket-group", | ||||
| 					"socket-mode":   0o640, | ||||
| @@ -287,7 +287,7 @@ func TestRunPipeMetadata(t *testing.T) { | ||||
| 			WatchdogTimeout: "45ms", | ||||
| 		}, | ||||
| 	}, metadata.Apps) | ||||
| 	require.Equal(t, map[interface{}]interface{}{"read": []interface{}{"$HOME/test"}}, metadata.Plugs["personal-files"]) | ||||
| 	require.Equal(t, map[string]interface{}{"read": []interface{}{"$HOME/test"}}, metadata.Plugs["personal-files"]) | ||||
| 	require.Equal(t, "$SNAP_DATA/etc", metadata.Layout["/etc/testprojectname"].Bind) | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										52
									
								
								internal/yaml/yaml.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								internal/yaml/yaml.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| // Package yaml wraps gopkg.in/yaml.v3 and helps transition from v2. | ||||
| package yaml | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"errors" | ||||
| 	"io" | ||||
|  | ||||
| 	yaml "gopkg.in/yaml.v3" | ||||
| ) | ||||
|  | ||||
| // UnmarshalStrict unmarshals a YAML document with strict behavior (only declared fields are tolerated). | ||||
| func UnmarshalStrict(in []byte, out interface{}) error { | ||||
| 	decoder := yaml.NewDecoder(bytes.NewReader(in)) | ||||
| 	decoder.KnownFields(true) | ||||
|  | ||||
| 	return handleErr(decoder.Decode(out)) | ||||
| } | ||||
|  | ||||
| // Unmarshal some struct as a YAML document, without strict behavior. | ||||
| func Unmarshal(in []byte, out interface{}) error { | ||||
| 	decoder := yaml.NewDecoder(bytes.NewReader(in)) | ||||
| 	decoder.KnownFields(false) | ||||
|  | ||||
| 	return handleErr(decoder.Decode(out)) | ||||
| } | ||||
|  | ||||
| // Marshal some struct as a YAML document. | ||||
| func Marshal(in interface{}) ([]byte, error) { | ||||
| 	b := new(bytes.Buffer) | ||||
| 	encoder := yaml.NewEncoder(b) | ||||
| 	encoder.SetIndent(2) // default is 4 | ||||
|  | ||||
| 	if err := encoder.Encode(in); err != nil { | ||||
| 		encoder.Close() | ||||
|  | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	encoder.Close() | ||||
|  | ||||
| 	return b.Bytes(), nil | ||||
| } | ||||
|  | ||||
| // handleErr mutes io.EOF errors for backward-compatibility. | ||||
| func handleErr(err error) error { | ||||
| 	if err != nil && !errors.Is(err, io.EOF) { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										264
									
								
								internal/yaml/yaml_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										264
									
								
								internal/yaml/yaml_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,264 @@ | ||||
| package yaml | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| func TestYAMLMarshalError(t *testing.T) { | ||||
| 	t.Parallel() | ||||
|  | ||||
| 	type yamlMarshalError struct { | ||||
| 		BoolValue bool   `yaml:"bool_value"` | ||||
| 		FuncValue func() `yaml:"func_value"` | ||||
| 	} | ||||
|  | ||||
| 	v := yamlMarshalError{ | ||||
| 		BoolValue: true, | ||||
| 		FuncValue: func() {}, | ||||
| 	} | ||||
|  | ||||
| 	require.Panics(t, func() { | ||||
| 		_, _ = Marshal(v) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func TestYAML(t *testing.T) { | ||||
| 	t.Parallel() | ||||
|  | ||||
| 	type ( | ||||
| 		yamlKey struct { | ||||
| 			BoolValue   bool    `yaml:"bool_value"` | ||||
| 			NumberValue float64 `yaml:"number_value"` | ||||
| 			StringValue string  `yaml:"string_value"` | ||||
| 		} | ||||
| 		yamlObject struct { | ||||
| 			Array []string `yaml:"array"` | ||||
| 			Key   yamlKey  `yaml:"key"` | ||||
| 		} | ||||
| 		yamlReceiver struct { | ||||
| 			Object yamlObject `yaml:"object"` | ||||
| 		} | ||||
|  | ||||
| 		interfaceOrObject struct { | ||||
| 			obj   yamlReceiver | ||||
| 			iface interface{} | ||||
| 		} | ||||
| 	) | ||||
|  | ||||
| 	for _, toPin := range []struct { | ||||
| 		Title        string | ||||
| 		InputYAML    []byte | ||||
| 		ExpectedYAML []byte            // optional: when marshaled YAML is expected to differ from raw input (e.g. on bool flags) | ||||
| 		Expected     interfaceOrObject // maybe either untyped interface{} or yamlObject struct with struct tags | ||||
| 		ExpectError  bool | ||||
| 		WantsStrict  bool // apply Strict mode | ||||
| 	}{ | ||||
| 		{ | ||||
| 			Title:     "happy path, untyped", | ||||
| 			InputYAML: testYAMLObject(), | ||||
| 			Expected: interfaceOrObject{ | ||||
| 				iface: map[string]interface{}{ | ||||
| 					"object": map[string]interface{}{ | ||||
| 						"key": map[string]interface{}{ | ||||
| 							"string_value": "This is a doc.\nOn multiple lines.\n", | ||||
| 							"bool_value":   "y", | ||||
| 							"number_value": 10.23, | ||||
| 						}, | ||||
| 						"array": []interface{}{"x", "y"}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Title:       "happy path strict, untyped", | ||||
| 			InputYAML:   testYAMLObject(), | ||||
| 			WantsStrict: true, | ||||
| 			Expected: interfaceOrObject{ | ||||
| 				iface: map[string]interface{}{ | ||||
| 					"object": map[string]interface{}{ | ||||
| 						"key": map[string]interface{}{ | ||||
| 							"string_value": "This is a doc.\nOn multiple lines.\n", | ||||
| 							"bool_value":   "y", | ||||
| 							"number_value": 10.23, | ||||
| 						}, | ||||
| 						"array": []interface{}{"x", "y"}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Title:        "happy path strict, explicit target", | ||||
| 			InputYAML:    testYAMLObject(), | ||||
| 			ExpectedYAML: testYAMLObjectBool(), | ||||
| 			WantsStrict:  true, | ||||
| 			Expected: interfaceOrObject{ | ||||
| 				iface: nil, | ||||
| 				obj: yamlReceiver{ | ||||
| 					Object: yamlObject{ | ||||
| 						Key: yamlKey{ | ||||
| 							StringValue: "This is a doc.\nOn multiple lines.\n", | ||||
| 							BoolValue:   true, | ||||
| 							NumberValue: 10.23, | ||||
| 						}, | ||||
| 						Array: []string{"x", "y"}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Title:        "happy path non-strict, explicit target", | ||||
| 			InputYAML:    testYAMLObjectNonStrict(), | ||||
| 			ExpectedYAML: testYAMLObjectBool(), | ||||
| 			WantsStrict:  false, | ||||
| 			Expected: interfaceOrObject{ | ||||
| 				iface: nil, | ||||
| 				obj: yamlReceiver{ | ||||
| 					Object: yamlObject{ | ||||
| 						Key: yamlKey{ | ||||
| 							StringValue: "This is a doc.\nOn multiple lines.\n", | ||||
| 							BoolValue:   true, | ||||
| 							NumberValue: 10.23, | ||||
| 						}, | ||||
| 						Array: []string{"x", "y"}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Title:        "happy path strict, explicit target: unknown field failure", | ||||
| 			InputYAML:    testYAMLObjectNonStrict(), | ||||
| 			ExpectedYAML: testYAMLObjectBool(), | ||||
| 			WantsStrict:  true, | ||||
| 			ExpectError:  true, | ||||
| 			Expected: interfaceOrObject{ | ||||
| 				iface: nil, | ||||
| 				obj: yamlReceiver{ | ||||
| 					Object: yamlObject{ | ||||
| 						Key: yamlKey{ | ||||
| 							StringValue: "This is a doc.\nOn multiple lines.\n", | ||||
| 							BoolValue:   true, | ||||
| 							NumberValue: 10.23, | ||||
| 						}, | ||||
| 						Array: []string{"x", "y"}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} { | ||||
| 		testCase := toPin | ||||
|  | ||||
| 		t.Run(testCase.Title, func(t *testing.T) { | ||||
| 			t.Parallel() | ||||
|  | ||||
| 			var ( | ||||
| 				err               error | ||||
| 				b, expectedOutput []byte | ||||
| 			) | ||||
| 			iface := testCase.Expected.iface | ||||
| 			obj := testCase.Expected.obj | ||||
|  | ||||
| 			expectedInput := toPlainYaml(testCase.InputYAML) | ||||
|  | ||||
| 			if testCase.WantsStrict { | ||||
| 				if iface != nil { | ||||
| 					err = UnmarshalStrict(expectedInput, &iface) | ||||
| 				} else { | ||||
| 					err = UnmarshalStrict(expectedInput, &obj) | ||||
| 				} | ||||
| 			} else { | ||||
| 				if iface != nil { | ||||
| 					err = Unmarshal(expectedInput, &iface) | ||||
| 				} else { | ||||
| 					err = Unmarshal(expectedInput, &obj) | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if testCase.ExpectError { | ||||
| 				require.Error(t, err) | ||||
|  | ||||
| 				return | ||||
| 			} | ||||
|  | ||||
| 			require.NoError(t, err) | ||||
|  | ||||
| 			if iface != nil { | ||||
| 				require.EqualValues(t, testCase.Expected.iface, iface) | ||||
|  | ||||
| 				b, err = Marshal(iface) | ||||
| 				require.NoError(t, err) | ||||
| 			} else { | ||||
| 				require.EqualValues(t, testCase.Expected.obj, obj) | ||||
|  | ||||
| 				b, err = Marshal(obj) | ||||
| 				require.NoError(t, err) | ||||
| 			} | ||||
|  | ||||
| 			if testCase.ExpectedYAML == nil { | ||||
| 				expectedOutput = expectedInput | ||||
| 			} else { | ||||
| 				expectedOutput = toPlainYaml(testCase.ExpectedYAML) | ||||
| 			} | ||||
|  | ||||
| 			require.EqualValues(t, expectedOutput, b) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func toPlainYaml(in []byte) []byte { | ||||
| 	// ensure we got legit yaml for go strings that may have been reindented using tabs, or leading new CR in source. | ||||
| 	return bytes.ReplaceAll( | ||||
| 		bytes.TrimLeft(in, "\n\r"), | ||||
| 		[]byte("\t"), bytes.Repeat([]byte(" "), 4), | ||||
| 	) | ||||
| } | ||||
|  | ||||
| func testYAMLObject() []byte { | ||||
| 	return []byte(` | ||||
| object: | ||||
|   array: | ||||
|     - x | ||||
|     - "y" | ||||
|   key: | ||||
|     bool_value: "y" | ||||
|     number_value: 10.23 | ||||
|     string_value: | | ||||
|       This is a doc. | ||||
|       On multiple lines. | ||||
| `) | ||||
| } | ||||
|  | ||||
| func testYAMLObjectBool() []byte { | ||||
| 	// same object, but the "y" YAML for bool has been marshaled as "true" | ||||
| 	return []byte(` | ||||
| object: | ||||
|   array: | ||||
|     - x | ||||
|     - "y" | ||||
|   key: | ||||
|     bool_value: true | ||||
|     number_value: 10.23 | ||||
|     string_value: | | ||||
|       This is a doc. | ||||
|       On multiple lines. | ||||
| `) | ||||
| } | ||||
|  | ||||
| func testYAMLObjectNonStrict() []byte { | ||||
| 	// same object, but with an extra unknown value | ||||
| 	return []byte(` | ||||
| object: | ||||
|   array: | ||||
|     - x | ||||
|     - "y" | ||||
|   key: | ||||
|     bool_value: true | ||||
|     number_value: 10.23 | ||||
|     string_value: | | ||||
|       This is a doc. | ||||
|       On multiple lines. | ||||
|   unknown: 'wrong' | ||||
| `) | ||||
| } | ||||
| @@ -11,8 +11,8 @@ import ( | ||||
| 	"github.com/alecthomas/jsonschema" | ||||
|  | ||||
| 	"github.com/apex/log" | ||||
| 	"github.com/goreleaser/goreleaser/internal/yaml" | ||||
| 	"github.com/goreleaser/nfpm/v2/files" | ||||
| 	yaml "gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| // GitHubURLs holds the URLs to be used when using github enterprise. | ||||
|   | ||||
| @@ -5,8 +5,8 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/goreleaser/goreleaser/internal/yaml" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| 	yaml "gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| func TestArchiveFiles_justString(t *testing.T) { | ||||
|   | ||||
| @@ -3,8 +3,8 @@ package config | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/goreleaser/goreleaser/internal/yaml" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| 	yaml "gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| type Unmarshaled struct { | ||||
|   | ||||
| @@ -3,8 +3,8 @@ package config | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/goreleaser/goreleaser/internal/yaml" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| 	yaml "gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| func TestBuildHook_justString(t *testing.T) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user