Skip to content

Commit cec7320

Browse files
authored
Merge pull request #534 from estroz/chore/webhooks-v1
⚠️ update dependencies to v1.19.2
2 parents 895eccc + 1903475 commit cec7320

32 files changed

+2885
-3663
lines changed

.run-controller-gen.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,27 @@
44
# it's the equivalent of `go run sigs.k8s.io/controller-tools/cmd/controller-gen`
55
# if you could somehow do that without modifying your go.mod.
66

7-
current_dir=$(pwd)
8-
if ! readlink -f . &>/dev/null; then
9-
echo "you're probably on OSX. Please install gnu readlink -- otherwise you're missing the most useful readlink flag."
10-
exit 1
11-
fi
7+
set -o errexit
8+
set -o nounset
9+
set -o pipefail
10+
11+
readlink=$(command -v readlink)
1212

13-
cd $(dirname $(readlink -f ${BASH_SOURCE[0]}))
13+
check_readlink() {
14+
local test_file="$(mktemp)"
15+
trap "rm -f $test_file" EXIT
16+
if ! ${readlink} -f "$test_file" &>/dev/null; then
17+
if [[ "${OSTYPE}" == "darwin"* ]]; then
18+
if command -v greadlink; then
19+
readlink=$(command -v greadlink)
20+
return
21+
fi
22+
fi
23+
echo "you're probably on OSX. Please install gnu readlink -- otherwise you're missing the most useful readlink flag."
24+
exit 1
25+
fi
26+
}
27+
current_dir=$(pwd)
28+
check_readlink
29+
cd $(dirname $(${readlink} -f ${BASH_SOURCE[0]}))
1430
go run -v -exec "./.run-in.sh ${current_dir} " ./cmd/controller-gen $@

go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
module sigs.k8s.io/controller-tools
22

3-
go 1.13
3+
go 1.15
44

55
require (
6-
github.com/fatih/color v1.7.0
6+
github.com/fatih/color v1.9.0
77
github.com/gobuffalo/flect v0.2.2
8-
github.com/google/go-cmp v0.3.0
9-
github.com/mattn/go-colorable v0.1.2 // indirect
10-
github.com/onsi/ginkgo v1.11.0
11-
github.com/onsi/gomega v1.8.1
8+
github.com/google/go-cmp v0.5.2
9+
github.com/mattn/go-colorable v0.1.8 // indirect
10+
github.com/onsi/ginkgo v1.14.1
11+
github.com/onsi/gomega v1.10.2
1212
github.com/spf13/cobra v1.0.0
1313
github.com/spf13/pflag v1.0.5
14-
golang.org/x/tools v0.0.0-20200616195046-dc31b401abb5
15-
gopkg.in/yaml.v3 v3.0.0-20190905181640-827449938966
16-
k8s.io/api v0.18.2
17-
k8s.io/apiextensions-apiserver v0.18.2
18-
k8s.io/apimachinery v0.18.2
14+
golang.org/x/tools v0.0.0-20201007032633-0806396f153e
15+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
16+
k8s.io/api v0.19.2
17+
k8s.io/apiextensions-apiserver v0.19.2
18+
k8s.io/apimachinery v0.19.2
1919
sigs.k8s.io/yaml v1.2.0
2020
)

go.sum

Lines changed: 218 additions & 122 deletions
Large diffs are not rendered by default.

pkg/crd/gen_integration_test.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import (
2121
"io"
2222
"io/ioutil"
2323
"os"
24+
"path/filepath"
2425

26+
"github.com/google/go-cmp/cmp"
2527
. "github.com/onsi/ginkgo"
2628
. "github.com/onsi/gomega"
2729
"sigs.k8s.io/controller-tools/pkg/crd"
@@ -32,13 +34,18 @@ import (
3234
)
3335

3436
var _ = Describe("CRD Generation proper defaulting", func() {
35-
var ctx *genall.GenerationContext
36-
var out *outputRule
37+
var (
38+
ctx *genall.GenerationContext
39+
out *outputRule
40+
41+
genDir = filepath.Join("testdata", "gen")
42+
)
43+
3744
BeforeEach(func() {
3845
By("switching into testdata to appease go modules")
3946
cwd, err := os.Getwd()
4047
Expect(err).NotTo(HaveOccurred())
41-
Expect(os.Chdir("./testdata/gen")).To(Succeed()) // go modules are directory-sensitive
48+
Expect(os.Chdir(genDir)).To(Succeed()) // go modules are directory-sensitive
4249
defer func() { Expect(os.Chdir(cwd)).To(Succeed()) }()
4350

4451
By("loading the roots")
@@ -68,11 +75,12 @@ var _ = Describe("CRD Generation proper defaulting", func() {
6875
Expect(gen.Generate(ctx)).NotTo(HaveOccurred())
6976

7077
By("loading the desired YAML")
71-
expectedFile, err := ioutil.ReadFile("./testdata/gen/foo_crd_v1beta1.yaml")
78+
expectedFile, err := ioutil.ReadFile(filepath.Join(genDir, "bar.example.com_foos.v1beta1.yaml"))
7279
Expect(err).NotTo(HaveOccurred())
80+
expectedFile = fixAnnotations(expectedFile)
7381

7482
By("comparing the two")
75-
Expect(out.buf.Bytes()).To(Equal(expectedFile))
83+
Expect(out.buf.String()).To(Equal(string(expectedFile)), cmp.Diff(out.buf.String(), string(expectedFile)))
7684

7785
})
7886

@@ -84,15 +92,20 @@ var _ = Describe("CRD Generation proper defaulting", func() {
8492
Expect(gen.Generate(ctx)).NotTo(HaveOccurred())
8593

8694
By("loading the desired YAML")
87-
expectedFile, err := ioutil.ReadFile("./testdata/gen/foo_crd_v1.yaml")
95+
expectedFile, err := ioutil.ReadFile(filepath.Join(genDir, "bar.example.com_foos.yaml"))
8896
Expect(err).NotTo(HaveOccurred())
97+
expectedFile = fixAnnotations(expectedFile)
8998

9099
By("comparing the two")
91-
Expect(out.buf.Bytes()).To(Equal(expectedFile))
92-
100+
Expect(out.buf.String()).To(Equal(string(expectedFile)), cmp.Diff(out.buf.String(), string(expectedFile)))
93101
})
94102
})
95103

104+
// fixAnnotations fixes the attribution annotation for tests.
105+
func fixAnnotations(crdBytes []byte) []byte {
106+
return bytes.Replace(crdBytes, []byte("(devel)"), []byte("(unknown)"), 1)
107+
}
108+
96109
type outputRule struct {
97110
buf *bytes.Buffer
98111
}

pkg/crd/testdata/cronjob_types.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616
// TODO(directxman12): test this across both versions (right now we're just
1717
// trusting k/k conversion, which is probably fine though)
1818

19-
//go:generate ../../../.run-controller-gen.sh paths=. output:dir=.
19+
//go:generate ../../../.run-controller-gen.sh crd paths=. output:dir=.
2020

2121
// +groupName=testdata.kubebuilder.io
2222
// +versionName=v1
@@ -159,9 +159,10 @@ type CronJobSpec struct {
159159
// +kubebuilder:validation:Type=object
160160
// +kubebuilder:pruning:PreserveUnknownFields
161161
type Preserved struct {
162-
ConcreteField string `json:"concreteField"`
163-
Rest map[string]interface{} `json:"-"`
162+
ConcreteField string `json:"concreteField"`
163+
Rest map[string]interface{} `json:"-"`
164164
}
165+
165166
func (p *Preserved) UnmarshalJSON(data []byte) error {
166167
if err := json.Unmarshal(data, &p.Rest); err != nil {
167168
return err
@@ -303,7 +304,3 @@ type CronJobList struct {
303304
metav1.ListMeta `json:"metadata,omitempty"`
304305
Items []CronJob `json:"items"`
305306
}
306-
307-
func init() {
308-
SchemeBuilder.Register(&CronJob{}, &CronJobList{})
309-
}

pkg/crd/testdata/gen/foo_crd_v1beta1.yaml renamed to pkg/crd/testdata/gen/bar.example.com_foos.v1beta1.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: (unknown)
7+
controller-gen.kubebuilder.io/version: (devel)
88
creationTimestamp: null
99
name: foos.bar.example.com
1010
spec:
@@ -19,22 +19,17 @@ spec:
1919
openAPIV3Schema:
2020
properties:
2121
apiVersion:
22-
description: 'APIVersion defines the versioned schema of this representation
23-
of an object. Servers should convert recognized schemas to the latest
24-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
22+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
2523
type: string
2624
kind:
27-
description: 'Kind is a string value representing the REST resource this
28-
object represents. Servers may infer this from the endpoint the client
29-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
25+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
3026
type: string
3127
metadata:
3228
type: object
3329
spec:
3430
properties:
3531
defaultedString:
36-
description: This tests that defaulted fields are stripped for v1beta1,
37-
but not for v1
32+
description: This tests that defaulted fields are stripped for v1beta1, but not for v1
3833
type: string
3934
required:
4035
- defaultedString

pkg/crd/testdata/gen/foo_crd_v1.yaml renamed to pkg/crd/testdata/gen/bar.example.com_foos.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: (unknown)
7+
controller-gen.kubebuilder.io/version: (devel)
88
creationTimestamp: null
99
name: foos.bar.example.com
1010
spec:
@@ -21,23 +21,18 @@ spec:
2121
openAPIV3Schema:
2222
properties:
2323
apiVersion:
24-
description: 'APIVersion defines the versioned schema of this representation
25-
of an object. Servers should convert recognized schemas to the latest
26-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
24+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
2725
type: string
2826
kind:
29-
description: 'Kind is a string value representing the REST resource this
30-
object represents. Servers may infer this from the endpoint the client
31-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
27+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
3228
type: string
3329
metadata:
3430
type: object
3531
spec:
3632
properties:
3733
defaultedString:
3834
default: fooDefaultString
39-
description: This tests that defaulted fields are stripped for v1beta1,
40-
but not for v1
35+
description: This tests that defaulted fields are stripped for v1beta1, but not for v1
4136
type: string
4237
required:
4338
- defaultedString

pkg/crd/testdata/gen/foo_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
*/
1515

16-
//go:generate ../../../../.run-controller-gen.sh paths=. output:dir=.
16+
//go:generate ../../../../.run-controller-gen.sh crd:crdVersions=v1beta1 paths=. output:dir=.
17+
//go:generate mv bar.example.com_foos.yaml bar.example.com_foos.v1beta1.yaml
18+
//go:generate ../../../../.run-controller-gen.sh crd:crdVersions=v1 paths=. output:dir=.
19+
1720
// +groupName=bar.example.com
1821
package foo
1922

pkg/crd/testdata/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module testdata.kubebuilder.io/cronjob
22

3-
go 1.13
3+
go 1.15
44

55
require (
6-
k8s.io/api v0.0.0-20190615205754-1d1b8b084b30
7-
k8s.io/apimachinery v0.0.0-20190612125636-6a5db36e93ad
6+
k8s.io/api v0.19.2
7+
k8s.io/apimachinery v0.19.2
88
)

0 commit comments

Comments
 (0)