refactor(yaml): switch yaml library import paths from gopkg.in to go.yaml.in (#2114)
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
		
							parent
							
								
									9a88372449
								
							
						
					
					
						commit
						959aae5791
					
				|  | @ -574,7 +574,7 @@ Helmfile uses some OS environment variables to override default behaviour: | |||
| * `HELMFILE_ENVIRONMENT` - specify [Helmfile environment](https://helmfile.readthedocs.io/en/latest/#environment), it has lower priority than CLI argument `--environment` | ||||
| * `HELMFILE_TEMPDIR` - specify directory to store temporary files | ||||
| * `HELMFILE_UPGRADE_NOTICE_DISABLED` - expecting any non-empty value to skip the check for the latest version of Helmfile in [helmfile version](https://helmfile.readthedocs.io/en/latest/#version) | ||||
| * `HELMFILE_GO_YAML_V3` - use *gopkg.in/yaml.v3* instead of *gopkg.in/yaml.v2*.  It's `false` by default in Helmfile v0.x, and `true` in Helmfile v1.x. | ||||
| * `HELMFILE_GO_YAML_V3` - use *go.yaml.in/yaml/v3* instead of *go.yaml.in/yaml/v2*.  It's `false` by default in Helmfile v0.x, and `true` in Helmfile v1.x. | ||||
| * `HELMFILE_CACHE_HOME` - specify directory to store cached files for remote operations | ||||
| * `HELMFILE_FILE_PATH` - specify the path to the helmfile.yaml file | ||||
| * `HELMFILE_INTERACTIVE` - enable interactive mode, expecting `true` lower case. The same as `--interactive` CLI flag | ||||
|  | @ -584,7 +584,7 @@ Helmfile uses some OS environment variables to override default behaviour: | |||
| ``` | ||||
| Declaratively deploy your Kubernetes manifests, Kustomize configs, and Charts as Helm releases in one shot | ||||
| V1 mode = false | ||||
| YAML library = gopkg.in/yaml.v3 | ||||
| YAML library = go.yaml.in/yaml/v3 | ||||
| 
 | ||||
| Usage: | ||||
|   helmfile [command] | ||||
|  |  | |||
							
								
								
									
										6
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										6
									
								
								go.mod
								
								
								
								
							|  | @ -25,10 +25,10 @@ require ( | |||
| 	github.com/zclconf/go-cty-yaml v1.1.0 | ||||
| 	go.szostok.io/version v1.2.0 | ||||
| 	go.uber.org/zap v1.27.0 | ||||
| 	go.yaml.in/yaml/v2 v2.4.2 | ||||
| 	go.yaml.in/yaml/v3 v3.0.4 | ||||
| 	golang.org/x/sync v0.16.0 | ||||
| 	golang.org/x/term v0.33.0 | ||||
| 	gopkg.in/yaml.v2 v2.4.0 | ||||
| 	gopkg.in/yaml.v3 v3.0.1 | ||||
| 	helm.sh/helm/v3 v3.18.4 | ||||
| 	k8s.io/apimachinery v0.33.3 | ||||
| ) | ||||
|  | @ -294,6 +294,8 @@ require ( | |||
| 	gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect | ||||
| 	gopkg.in/gookit/color.v1 v1.1.6 // indirect | ||||
| 	gopkg.in/inf.v0 v0.9.1 // indirect | ||||
| 	gopkg.in/yaml.v2 v2.4.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| 	k8s.io/api v0.33.2 // indirect | ||||
| 	k8s.io/apiextensions-apiserver v0.33.2 // indirect | ||||
| 	k8s.io/cli-runtime v0.33.2 // indirect | ||||
|  |  | |||
							
								
								
									
										4
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										4
									
								
								go.sum
								
								
								
								
							|  | @ -1577,6 +1577,10 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= | |||
| go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= | ||||
| go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= | ||||
| go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= | ||||
| go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= | ||||
| go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= | ||||
| go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= | ||||
| go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
| golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
|  |  | |||
|  | @ -411,7 +411,7 @@ releases: | |||
| 		}) | ||||
| 	} | ||||
| 
 | ||||
| 	t.Run("fail due to unknown field with gopkg.in/yaml.v3", func(t *testing.T) { | ||||
| 	t.Run("fail due to unknown field with go.yaml.in/yaml/v3", func(t *testing.T) { | ||||
| 		check(t, testcase{ | ||||
| 			GoYamlV3: true, | ||||
| 			error: `in ./helmfile.yaml: failed to read helmfile.yaml: reading document at index 1. Started seeing this since Helmfile v1? Add the .gotmpl file extension: yaml: unmarshal errors: | ||||
|  | @ -419,7 +419,7 @@ releases: | |||
| 		}) | ||||
| 	}) | ||||
| 
 | ||||
| 	t.Run("fail due to unknown field with gopkg.in/yaml.v2", func(t *testing.T) { | ||||
| 	t.Run("fail due to unknown field with go.yaml.in/yaml/v2", func(t *testing.T) { | ||||
| 		check(t, testcase{ | ||||
| 			GoYamlV3: false, | ||||
| 			error: `in ./helmfile.yaml: failed to read helmfile.yaml: reading document at index 1. Started seeing this since Helmfile v1? Add the .gotmpl file extension: yaml: unmarshal errors: | ||||
|  |  | |||
|  | @ -4161,21 +4161,21 @@ releases: | |||
| } | ||||
| 
 | ||||
| func TestSetValuesTemplate(t *testing.T) { | ||||
| 	t.Run("with gopkg.in/yaml.v3", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v3", func(t *testing.T) { | ||||
| 		testSetValuesTemplate(t, true) | ||||
| 	}) | ||||
| 
 | ||||
| 	t.Run("with gopkg.in/yaml.v2", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v2", func(t *testing.T) { | ||||
| 		testSetValuesTemplate(t, false) | ||||
| 	}) | ||||
| } | ||||
| 
 | ||||
| func TestSetStringValuesTemplate(t *testing.T) { | ||||
| 	t.Run("with gopkg.in/yaml.v3", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v3", func(t *testing.T) { | ||||
| 		testSetStringValuesTemplate(t, true) | ||||
| 	}) | ||||
| 
 | ||||
| 	t.Run("with gopkg.in/yaml.v2", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v2", func(t *testing.T) { | ||||
| 		testSetStringValuesTemplate(t, false) | ||||
| 	}) | ||||
| } | ||||
|  |  | |||
|  | @ -9,15 +9,15 @@ import ( | |||
| 
 | ||||
| var ( | ||||
| 	// GoYamlV3 is set to true in order to let Helmfile use
 | ||||
| 	// gopkg.in/yaml.v3 instead of gopkg.in/yaml.v2.
 | ||||
| 	// go.yaml.in/yaml/v3 instead of go.yaml.in/yaml/v2.
 | ||||
| 	// It's false by default in Helmfile v0.x and true in Helmfile v1.x.
 | ||||
| 	GoYamlV3 bool | ||||
| ) | ||||
| 
 | ||||
| func Info() string { | ||||
| 	yamlLib := "gopkg.in/yaml.v2" | ||||
| 	yamlLib := "go.yaml.in/yaml/v2" | ||||
| 	if GoYamlV3 { | ||||
| 		yamlLib = "gopkg.in/yaml.v3" | ||||
| 		yamlLib = "go.yaml.in/yaml/v3" | ||||
| 	} | ||||
| 
 | ||||
| 	return fmt.Sprintf("YAML library = %v", yamlLib) | ||||
|  |  | |||
|  | @ -358,11 +358,11 @@ func testFromYaml(t *testing.T, GoYamlV3 bool) { | |||
| } | ||||
| 
 | ||||
| func TestFromYaml(t *testing.T) { | ||||
| 	t.Run("with gopkg.in/yaml.v2", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v2", func(t *testing.T) { | ||||
| 		testFromYaml(t, true) | ||||
| 	}) | ||||
| 
 | ||||
| 	t.Run("with gopkg.in/yaml.v3", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v3", func(t *testing.T) { | ||||
| 		testFromYaml(t, false) | ||||
| 	}) | ||||
| } | ||||
|  |  | |||
|  | @ -4,8 +4,8 @@ import ( | |||
| 	"bytes" | ||||
| 	"io" | ||||
| 
 | ||||
| 	v2 "gopkg.in/yaml.v2" | ||||
| 	v3 "gopkg.in/yaml.v3" | ||||
| 	v2 "go.yaml.in/yaml/v2" | ||||
| 	v3 "go.yaml.in/yaml/v3" | ||||
| 
 | ||||
| 	"github.com/helmfile/helmfile/pkg/runtime" | ||||
| ) | ||||
|  |  | |||
|  | @ -13,9 +13,9 @@ func testYamlMarshal(t *testing.T, GoYamlV3 bool) { | |||
| 
 | ||||
| 	var yamlLibraryName string | ||||
| 	if GoYamlV3 { | ||||
| 		yamlLibraryName = "gopkg.in/yaml.v3" | ||||
| 		yamlLibraryName = "go.yaml.in/yaml/v3" | ||||
| 	} else { | ||||
| 		yamlLibraryName = "gopkg.in/yaml.v2" | ||||
| 		yamlLibraryName = "go.yaml.in/yaml/v2" | ||||
| 	} | ||||
| 
 | ||||
| 	v := runtime.GoYamlV3 | ||||
|  | @ -49,8 +49,8 @@ func testYamlMarshal(t *testing.T, GoYamlV3 bool) { | |||
| 				Annotation: "on", | ||||
| 			}}, | ||||
| 			expected: map[string]string{ | ||||
| 				"gopkg.in/yaml.v2": "name: John\ninfo:\n- age: 20\n  address: New York\n  annotation: \"on\"\n", | ||||
| 				"gopkg.in/yaml.v3": "name: John\ninfo:\n  - age: 20\n    address: New York\n    annotation: \"on\"\n", | ||||
| 				"go.yaml.in/yaml/v2": "name: John\ninfo:\n- age: 20\n  address: New York\n  annotation: \"on\"\n", | ||||
| 				"go.yaml.in/yaml/v3": "name: John\ninfo:\n  - age: 20\n    address: New York\n    annotation: \"on\"\n", | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
|  | @ -63,11 +63,11 @@ func testYamlMarshal(t *testing.T, GoYamlV3 bool) { | |||
| } | ||||
| 
 | ||||
| func TestYamlMarshal(t *testing.T) { | ||||
| 	t.Run("with gopkg.in/yaml.v2", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v2", func(t *testing.T) { | ||||
| 		testYamlMarshal(t, true) | ||||
| 	}) | ||||
| 
 | ||||
| 	t.Run("with gopkg.in/yaml.v3", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v3", func(t *testing.T) { | ||||
| 		testYamlMarshal(t, false) | ||||
| 	}) | ||||
| } | ||||
|  |  | |||
|  | @ -58,11 +58,11 @@ func (f fakeInit) Force() bool { | |||
| } | ||||
| 
 | ||||
| func TestHelmfileTemplateWithBuildCommand(t *testing.T) { | ||||
| 	t.Run("with gopkg.in/yaml.v3", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v3", func(t *testing.T) { | ||||
| 		testHelmfileTemplateWithBuildCommand(t, true) | ||||
| 	}) | ||||
| 
 | ||||
| 	t.Run("with gopkg.in/yaml.v2", func(t *testing.T) { | ||||
| 	t.Run("with go.yaml.in/yaml/v2", func(t *testing.T) { | ||||
| 		testHelmfileTemplateWithBuildCommand(t, false) | ||||
| 	}) | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue