Skip to content

Commit

Permalink
Upgrade conversion-gen and conversion-verifier (#204)
Browse files Browse the repository at this point in the history
Also pick up some lint fixes for conversion_test.go from the cluster-api repo.

Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe authored Jun 28, 2024
1 parent 0eac099 commit 167b501
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest

CONVERSION_GEN_BIN := conversion-gen
CONVERSION_GEN := $(LOCALBIN)/$(CONVERSION_GEN_BIN)
CONVERSION_GEN_OUTPUT_BASE := --output-base=.
CONVERSION_GEN_PKG := k8s.io/code-generator/cmd/conversion-gen

CONVERSION_VERIFIER_BIN := conversion-verifier
Expand All @@ -231,12 +230,12 @@ CONVERSION_VERIFIER_PKG := sigs.k8s.io/cluster-api/hack/tools/conversion-verifie
## Tool Versions
KUSTOMIZE_VERSION ?= v5.1.1
CONTROLLER_TOOLS_VERSION ?= v0.14.0
CONVERSION_GEN_VER := v0.28.2
CONVERSION_GEN_VER := v0.30.2

# Can be "latest", but cannot be a tag, such as "v1.3.3". However, it will
# work with the short-form git commit rev that has been tagged.
#CONVERSION_VERIFIER_VER := 09030092b # v1.3.3
CONVERSION_VERIFIER_VER := 3290c5a # v1.5.2
CONVERSION_VERIFIER_VER := b0284d8b # v1.7.3

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down Expand Up @@ -268,10 +267,9 @@ $(CONVERSION_GEN): $(LOCALBIN) # Build conversion-gen from tools folder.
generate-go-conversions: $(CONVERSION_GEN) ## Generate conversions go code
$(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha1"
$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha1 \
--build-tag=ignore_autogenerated_core \
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate.go.txt
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate.go.txt \
./api/v1alpha1

.PHONY: clean-generated-conversions
clean-generated-conversions: ## Remove files generated by conversion-gen from the mentioned dirs
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions github/cluster-api/util/conversion/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
func TestMarshalData(t *testing.T) {
g := NewWithT(t)

t.Run("should write source object to destination", func(t *testing.T) {
t.Run("should write source object to destination", func(*testing.T) {
src := &dwsv1alpha2.Workflow{
ObjectMeta: metav1.ObjectMeta{
Name: "test-1",
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestMarshalData(t *testing.T) {
g.Expect(dst.GetAnnotations()[DataAnnotation]).ToNot(ContainSubstring("label1"))
})

t.Run("should append the annotation", func(t *testing.T) {
t.Run("should append the annotation", func(*testing.T) {
src := &dwsv1alpha2.Workflow{
ObjectMeta: metav1.ObjectMeta{
Name: "test-1",
Expand All @@ -94,7 +94,7 @@ func TestMarshalData(t *testing.T) {
func TestUnmarshalData(t *testing.T) {
g := NewWithT(t)

t.Run("should return false without errors if annotation doesn't exist", func(t *testing.T) {
t.Run("should return false without errors if annotation doesn't exist", func(*testing.T) {
src := &dwsv1alpha2.Workflow{
ObjectMeta: metav1.ObjectMeta{
Name: "test-1",
Expand All @@ -109,7 +109,7 @@ func TestUnmarshalData(t *testing.T) {
g.Expect(err).ToNot(HaveOccurred())
})

t.Run("should return true when a valid annotation with data exists", func(t *testing.T) {
t.Run("should return true when a valid annotation with data exists", func(*testing.T) {
src := &unstructured.Unstructured{}
src.SetGroupVersionKind(oldWorkflowGVK)
src.SetName("test-1")
Expand All @@ -133,7 +133,7 @@ func TestUnmarshalData(t *testing.T) {
g.Expect(dst.GetAnnotations()).To(BeEmpty())
})

t.Run("should clean the annotation on successful unmarshal", func(t *testing.T) {
t.Run("should clean the annotation on successful unmarshal", func(*testing.T) {
src := &unstructured.Unstructured{}
src.SetGroupVersionKind(oldWorkflowGVK)
src.SetName("test-1")
Expand Down

0 comments on commit 167b501

Please sign in to comment.