Skip to content

Commit

Permalink
Upgrade controller-gen to 0.15.0 (#7556)
Browse files Browse the repository at this point in the history
# Description

To upgrade golang 1.22.x, we first need to use the latest controller-gen
due to the indirect package which is incompatible with 1.22.x.

golang 1.22 has test coverage drop issue. I extracted controller-gen
update part from #7533

## Type of change

- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: #issue_number

Signed-off-by: Young Bu Park <[email protected]>
  • Loading branch information
youngbupark authored Apr 29, 2024
1 parent e59b3ac commit d7ea006
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/contributor/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
// Prerequisite for Code Generation, see https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-code/contributing-code-prerequisites#code-generation
// Adding workspace as safe directory to avoid permission issues
"postCreateCommand": "git config --global --add safe.directory /workspaces/radius && cd typespec && npm ci && npm install -g autorest && npm install -g oav && go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.1 && go install github.com/golang/mock/[email protected]",
"postCreateCommand": "git config --global --add safe.directory /workspaces/radius && cd typespec && npm ci && npm install -g autorest && npm install -g oav && go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0 && go install github.com/golang/mock/[email protected]",
"hostRequirements": {
"memory": "8gb"
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: Install mockgen
run: go install github.com/golang/mock/[email protected]
- name: Install controller-gen
run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.1
run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0
- name: Install helm
uses: azure/setup-helm@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Install controller-gen
run: |
cd radius
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.1
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0
# Generate Bicep docs
- name: Generate Bicep docs
run: |
Expand Down
6 changes: 3 additions & 3 deletions build/generate.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ generate-autorest-installed:
.PHONY: generate-controller-gen-installed
generate-controller-gen-installed:
@echo "$(ARROW) Detecting controller-gen..."
@which controller-gen > /dev/null || { echo "run 'go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.1'"; exit 1; }
@which controller-gen > /dev/null || { echo "run 'go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0'"; exit 1; }
@echo "$(ARROW) OK"

.PHONY: generate-ucp-crd
generate-ucp-crd: generate-controller-gen-installed ## Generates the CRDs for UCP APIServer store.
@echo "$(ARROW) Generating CRDs for ucp.dev..."
controller-gen object paths=./pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1/... object:headerFile=./boilerplate.go.txt
controller-gen object:headerFile=./boilerplate.go.txt paths=./pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1/...
controller-gen crd paths=./pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1/... output:crd:dir=./deploy/Chart/crds/ucpd

.PHONY: generate-controller
generate-controller: generate-controller-gen-installed ## Generates the CRDs for the Radius controller.
@echo "$(ARROW) Generating CRDs for radapp.io..."
controller-gen object paths=./pkg/controller/api/... object:headerFile=./boilerplate.go.txt
controller-gen object:headerFile=./boilerplate.go.txt paths=./pkg/controller/api/...
controller-gen crd paths=./pkg/controller/api/... output:crd:dir=./deploy/Chart/crds/radius

.PHONY: generate-genericcliclient
Expand Down
79 changes: 45 additions & 34 deletions deploy/Chart/crds/radius/radapp.io_recipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.1
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.15.0
name: recipes.radapp.io
spec:
group: radapp.io
Expand Down Expand Up @@ -37,29 +36,34 @@ spec:
description: Recipe is the Schema for the recipes API
properties:
apiVersion:
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'
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
type: string
kind:
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'
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
type: string
metadata:
type: object
spec:
description: RecipeSpec defines the desired state of Recipe
properties:
application:
description: Application is the name of the Radius application to
use. If unset the namespace of the Recipe will be used as the application
name.
description: |-
Application is the name of the Radius application to use. If unset the namespace of the
Recipe will be used as the application name.
type: string
environment:
description: Environment is the name of the Radius environment to
use. If unset the value 'default' will be used as the environment
name.
description: |-
Environment is the name of the Radius environment to use. If unset the value 'default' will be
used as the environment name.
type: string
secretName:
description: SecretName is the name of a Kubernetes secret to create
Expand All @@ -79,9 +83,9 @@ spec:
description: Environment is the resource ID of the environment.
type: string
observedGeneration:
description: ObservedGeneration is the most recent generation observed
for this Recipe. It corresponds to the Recipe's generation, which
is updated on mutation by the API Server.
description: |-
ObservedGeneration is the most recent generation observed for this Recipe. It corresponds to the
Recipe's generation, which is updated on mutation by the API Server.
format: int64
type: integer
operation:
Expand Down Expand Up @@ -114,33 +118,40 @@ spec:
description: API version of the referent.
type: string
fieldPath:
description: 'If referring to a piece of an object instead of
an entire object, this string should contain a valid JSON/Go
field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within
a pod, this would take on a value like: "spec.containers{name}"
(where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]"
(container with index 2 in this pod). This syntax is chosen
only to have some well-defined way of referencing a part of
an object. TODO: this design is not final and this field is
subject to change in the future.'
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
TODO: this design is not final and this field is subject to change in the future.
type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
namespace:
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
type: string
resourceVersion:
description: 'Specific resourceVersion to which this reference
is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
type: string
uid:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
type: string
type: object
x-kubernetes-map-type: atomic
Expand Down
20 changes: 12 additions & 8 deletions deploy/Chart/crds/ucpd/ucp.dev_queuemessages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.1
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.15.0
name: queuemessages.ucp.dev
spec:
group: ucp.dev
Expand All @@ -21,14 +20,19 @@ spec:
description: QueueMessage is the Schema for QueueMessage API.
properties:
apiVersion:
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'
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
type: string
kind:
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'
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
type: string
metadata:
type: object
Expand Down
20 changes: 12 additions & 8 deletions deploy/Chart/crds/ucpd/ucp.dev_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.1
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.15.0
name: resources.ucp.dev
spec:
group: ucp.dev
Expand All @@ -21,9 +20,11 @@ spec:
description: Resource is the Schema for the resources API
properties:
apiVersion:
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'
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
type: string
entries:
items:
Expand All @@ -47,9 +48,12 @@ spec:
type: object
type: array
kind:
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'
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
type: string
metadata:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ Enter the following commands to install all of the required tools.
cd typespec && npm ci
npm install -g autorest
npm install -g oav
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.1
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0
go install github.com/golang/mock/[email protected]
```

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

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

2 changes: 1 addition & 1 deletion test/magpiego/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Issues on M1 mac: https://github.com/docker/for-mac/issues/5831
# it is a multistage docker creation for small magpie image
FROM amd64/golang:1.20-alpine
FROM amd64/golang:1.21-alpine
WORKDIR /usr/src/tmpapp

# Download necessary Go modules
Expand Down
2 changes: 1 addition & 1 deletion test/magpiego/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/radius-project/radius/test/magpiego

go 1.20
go 1.21

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1
Expand Down
4 changes: 2 additions & 2 deletions test/testrp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Issues on M1 mac: https://github.com/docker/for-mac/issues/5831
# it is a multistage docker creation for small magpie image
FROM amd64/golang:1.20-alpine3.16
FROM amd64/golang:1.21-alpine
WORKDIR /usr/src/tmpapp

# Download necessary Go modules
Expand All @@ -10,7 +10,7 @@ COPY *.go ./
# create the go binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o testrp .

FROM amd64/alpine:3.16
FROM amd64/alpine:3
WORKDIR /usr/src/app
COPY --from=0 /usr/src/tmpapp/testrp ./
EXPOSE 3000
Expand Down

0 comments on commit d7ea006

Please sign in to comment.