Skip to content

Commit e6a5211

Browse files
authored
Merge pull request #1167 from christopherhein/chore/use-sigs-yaml
Use sigs.k8s.io/yaml for parsing.
2 parents 977ce8b + c69268a commit e6a5211

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ require (
1616
golang.org/x/text v0.3.2 // indirect
1717
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac
1818
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
19-
gopkg.in/yaml.v2 v2.2.2
19+
sigs.k8s.io/yaml v1.1.0
2020
)

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
8989
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
9090
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
9191
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
92+
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
93+
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=

pkg/scaffold/input/input.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,17 @@ type Options struct {
162162
// ProjectFile is deserialized into a PROJECT file
163163
type ProjectFile struct {
164164
// Version is the project version - defaults to "1"
165-
Version string `yaml:"version,omitempty"`
165+
Version string `json:"version,omitempty"`
166166

167167
// Domain is the domain associated with the project and used for API groups
168-
Domain string `yaml:"domain,omitempty"`
168+
Domain string `json:"domain,omitempty"`
169169

170170
// Repo is the go package name of the project root
171-
Repo string `yaml:"repo,omitempty"`
171+
Repo string `json:"repo,omitempty"`
172172

173173
// Resources tracks scaffolded resources in the project. This info is
174174
// tracked only in project with version 2.
175-
Resources []Resource `yaml:"resources,omitempty"`
175+
Resources []Resource `json:"resources,omitempty"`
176176
}
177177

178178
// ResourceGroups returns unique groups of scaffolded resources in the project.
@@ -191,7 +191,7 @@ func (pf *ProjectFile) ResourceGroups() []string {
191191

192192
// Resource contains information about scaffolded resources.
193193
type Resource struct {
194-
Group string `yaml:"group,omitempty"`
195-
Version string `yaml:"version,omitempty"`
196-
Kind string `yaml:"kind,omitempty"`
194+
Group string `json:"group,omitempty"`
195+
Version string `json:"version,omitempty"`
196+
Kind string `json:"kind,omitempty"`
197197
}

pkg/scaffold/project/project.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package project
1919
import (
2020
"fmt"
2121

22-
yaml "gopkg.in/yaml.v2"
22+
"sigs.k8s.io/yaml"
2323
"sigs.k8s.io/kubebuilder/pkg/scaffold/input"
2424
)
2525

pkg/scaffold/scaffold.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"text/template"
2929

3030
"golang.org/x/tools/imports"
31-
yaml "gopkg.in/yaml.v2"
31+
"sigs.k8s.io/yaml"
3232
"sigs.k8s.io/kubebuilder/pkg/model"
3333
"sigs.k8s.io/kubebuilder/pkg/scaffold/input"
3434
"sigs.k8s.io/kubebuilder/pkg/scaffold/project"

testdata/gopath/src/project/PROJECT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version: "1"
21
domain: testproject.org
32
repo: project
3+
version: "1"

testdata/project-v2/PROJECT

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
version: "2"
21
domain: testproject.org
32
repo: sigs.k8s.io/kubebuilder/testdata/project-v2
43
resources:
54
- group: crew
6-
version: v1
75
kind: Captain
8-
- group: crew
96
version: v1
10-
kind: FirstMate
117
- group: crew
8+
kind: FirstMate
129
version: v1
10+
- group: crew
1311
kind: Admiral
12+
version: v1
13+
version: "2"

0 commit comments

Comments
 (0)