Skip to content

Commit 18df7d7

Browse files
committed
🎨 Rearrange the code so we don't generate a CRD for the Rollout stub.
1 parent 58e2be2 commit 18df7d7

File tree

8 files changed

+19
-18
lines changed

8 files changed

+19
-18
lines changed

β€ŽMakefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ deploy: manifests
4040

4141
# Generate manifests e.g. CRD, RBAC etc.
4242
manifests: controller-gen
43-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
43+
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./api/..." output:crd:artifacts:config=config/crd/bases
44+
$(CONTROLLER_GEN) rbac:roleName=manager-role webhook paths="./..."
4445

4546
# Run go fmt against code
4647
fmt:

β€Žcomponents/migrations.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import (
3939
"sigs.k8s.io/controller-runtime/pkg/reconcile"
4040
"sigs.k8s.io/controller-runtime/pkg/source"
4141

42-
"github.com/coderanger/migrations-operator/api/stubs/argoproj"
4342
migrationsv1beta1 "github.com/coderanger/migrations-operator/api/v1beta1"
43+
argoprojstubv1alpha1 "github.com/coderanger/migrations-operator/stubs/argoproj/v1alpha1"
4444
"github.com/coderanger/migrations-operator/utils"
4545
"github.com/coderanger/migrations-operator/webhook"
4646
)
@@ -333,7 +333,7 @@ func (_ *migrationsComponent) findSpecFor(ctx *cu.Context, obj cu.Object) *corev
333333
return &v.Spec
334334
case *appsv1.Deployment:
335335
return &v.Spec.Template.Spec
336-
case *argoproj.Rollout:
336+
case *argoprojstubv1alpha1.Rollout:
337337
if v.Spec.WorkloadRef != nil {
338338
if v.Spec.WorkloadRef.Kind == "Deployment" {
339339
deployment := appsv1.Deployment{}

β€Žcomponents/migrations_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3131
"k8s.io/apimachinery/pkg/types"
3232

33-
"github.com/coderanger/migrations-operator/api/stubs/argoproj"
3433
migrationsv1beta1 "github.com/coderanger/migrations-operator/api/v1beta1"
34+
argoprojstubsv1alpha1 "github.com/coderanger/migrations-operator/stubs/argoproj/v1alpha1"
3535
)
3636

3737
var _ = Describe("Migrations component", func() {
@@ -262,9 +262,9 @@ var _ = Describe("Migrations component", func() {
262262

263263
It("follows owner references for an argoproj.io rollout", func() {
264264
truep := true
265-
rollout := &argoproj.Rollout{
265+
rollout := &argoprojstubsv1alpha1.Rollout{
266266
ObjectMeta: metav1.ObjectMeta{Name: "testing"},
267-
Spec: argoproj.RolloutSpec{
267+
Spec: argoprojstubsv1alpha1.RolloutSpec{
268268
Template: corev1.PodTemplateSpec{
269269
Spec: corev1.PodSpec{
270270
Containers: []corev1.Container{
@@ -309,13 +309,13 @@ var _ = Describe("Migrations component", func() {
309309

310310
It("follows owner references for an argoproj.io rollout with workloadref to deployment", func() {
311311
truep := true
312-
rollout := &argoproj.Rollout{
312+
rollout := &argoprojstubsv1alpha1.Rollout{
313313
ObjectMeta: metav1.ObjectMeta{Name: "testing"},
314-
Spec: argoproj.RolloutSpec{
315-
WorkloadRef: &argoproj.ObjectRef{
316-
Name: "testing",
314+
Spec: argoprojstubsv1alpha1.RolloutSpec{
315+
WorkloadRef: &argoprojstubsv1alpha1.ObjectRef{
316+
Name: "testing",
317317
APIVersion: "apps/v1",
318-
Kind: "Deployment",
318+
Kind: "Deployment",
319319
},
320320
},
321321
}

β€Žcomponents/suite_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import (
2626
logf "sigs.k8s.io/controller-runtime/pkg/log"
2727
"sigs.k8s.io/controller-runtime/pkg/log/zap"
2828

29-
"github.com/coderanger/migrations-operator/api/stubs/argoproj"
3029
migrationsv1beta1 "github.com/coderanger/migrations-operator/api/v1beta1"
30+
argoprojstubsv1alpha1 "github.com/coderanger/migrations-operator/stubs/argoproj/v1alpha1"
3131
)
3232

3333
var suiteHelper *cu.UnitSuiteHelper
@@ -45,6 +45,6 @@ var _ = BeforeSuite(func() {
4545

4646
suiteHelper = cu.Unit().
4747
API(migrationsv1beta1.AddToScheme).
48-
API(argoproj.AddToScheme).
48+
API(argoprojstubsv1alpha1.AddToScheme).
4949
MustBuild()
5050
})

β€Žmain.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import (
2828
ctrl "sigs.k8s.io/controller-runtime"
2929
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3030

31-
"github.com/coderanger/migrations-operator/api/stubs/argoproj"
3231
migrationsv1beta1 "github.com/coderanger/migrations-operator/api/v1beta1"
3332
"github.com/coderanger/migrations-operator/controllers"
3433
"github.com/coderanger/migrations-operator/http"
34+
argoprojstubv1alpha1 "github.com/coderanger/migrations-operator/stubs/argoproj/v1alpha1"
3535
"github.com/coderanger/migrations-operator/webhook"
3636
// +kubebuilder:scaffold:imports
3737
)
@@ -44,7 +44,7 @@ var (
4444
func init() {
4545
_ = clientgoscheme.AddToScheme(scheme)
4646

47-
_ = argoproj.AddToScheme(scheme)
47+
_ = argoprojstubv1alpha1.AddToScheme(scheme)
4848
_ = migrationsv1beta1.AddToScheme(scheme)
4949
// +kubebuilder:scaffold:scheme
5050
}

β€Žapi/stubs/argoproj/groupversion_info.go renamed to β€Žstubs/argoproj/v1alpha1/groupversion_info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License.
1414

1515
//+kubebuilder:object:generate=true
1616
//+groupName=argoproj.io
17-
package argoproj
17+
package v1alpha1
1818

1919
import (
2020
"k8s.io/apimachinery/pkg/runtime/schema"

β€Žapi/stubs/argoproj/rollout_types.go renamed to β€Žstubs/argoproj/v1alpha1/rollout_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ See the License for the specific language governing permissions and
1212
limitations under the License.
1313
*/
1414

15-
package argoproj
15+
package v1alpha1
1616

1717
import (
1818
v1 "k8s.io/api/core/v1"

β€Žapi/stubs/argoproj/zz_generated.deepcopy.go renamed to β€Žstubs/argoproj/v1alpha1/zz_generated.deepcopy.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)