Skip to content

Commit

Permalink
migrate to ai v1beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhelil committed Aug 7, 2023
1 parent 63d9bd8 commit 415904b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
10 changes: 9 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

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

8 changes: 4 additions & 4 deletions controllers/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/shipwright-io/operator/api/v1alpha1"
"github.com/shipwright-io/operator/api/v1beta1"
"github.com/shipwright-io/operator/test"
)

Expand All @@ -34,7 +34,7 @@ var _ = g.Describe("Reconcile default ShipwrightBuild installation", func() {
// targetNamespace namespace where shipwright Controller and dependencies will be located
const targetNamespace = "target-namespace"
// build Build instance employed during testing
var build *v1alpha1.ShipwrightBuild
var build *v1beta1.ShipwrightBuild

baseClusterRole := &rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -126,12 +126,12 @@ var _ = g.Describe("Reconcile default ShipwrightBuild installation", func() {
o.Expect(err).NotTo(o.HaveOccurred())

g.By("creating a ShipwrightBuild instance")
build = &v1alpha1.ShipwrightBuild{
build = &v1beta1.ShipwrightBuild{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Name: "cluster",
},
Spec: v1alpha1.ShipwrightBuildSpec{
Spec: v1beta1.ShipwrightBuildSpec{
TargetNamespace: targetNamespace,
},
}
Expand Down
10 changes: 5 additions & 5 deletions controllers/shipwrightbuild_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"

"github.com/shipwright-io/operator/api/v1alpha1"
"github.com/shipwright-io/operator/api/v1beta1"
"github.com/shipwright-io/operator/pkg/tekton"
)

Expand All @@ -54,7 +54,7 @@ type ShipwrightBuildReconciler struct {
}

// setFinalizer append finalizer on the resource, and uses local client to update it immediately.
func (r *ShipwrightBuildReconciler) setFinalizer(ctx context.Context, b *v1alpha1.ShipwrightBuild) error {
func (r *ShipwrightBuildReconciler) setFinalizer(ctx context.Context, b *v1beta1.ShipwrightBuild) error {
if contains(b.GetFinalizers(), FinalizerAnnotation) {
return nil
}
Expand All @@ -63,7 +63,7 @@ func (r *ShipwrightBuildReconciler) setFinalizer(ctx context.Context, b *v1alpha
}

// unsetFinalizer remove all instances of local finalizer string, updating the resource immediately.
func (r *ShipwrightBuildReconciler) unsetFinalizer(ctx context.Context, b *v1alpha1.ShipwrightBuild) error {
func (r *ShipwrightBuildReconciler) unsetFinalizer(ctx context.Context, b *v1beta1.ShipwrightBuild) error {
finalizers := []string{}
for _, f := range b.GetFinalizers() {
if f == FinalizerAnnotation {
Expand All @@ -90,7 +90,7 @@ func (r *ShipwrightBuildReconciler) Reconcile(ctx context.Context, req ctrl.Requ
return Requeue()
}
// retrieving the ShipwrightBuild instance requested for reconcile
b := &v1alpha1.ShipwrightBuild{}
b := &v1beta1.ShipwrightBuild{}
if err := r.Get(ctx, req.NamespacedName, b); err != nil {
if errors.IsNotFound(err) {
logger.Info("Resource is not found!")
Expand Down Expand Up @@ -236,7 +236,7 @@ func (r *ShipwrightBuildReconciler) SetupWithManager(mgr ctrl.Manager) error {
return err
}
return ctrl.NewControllerManagedBy(mgr).
For(&v1alpha1.ShipwrightBuild{}, builder.WithPredicates(predicate.Funcs{
For(&v1beta1.ShipwrightBuild{}, builder.WithPredicates(predicate.Funcs{
CreateFunc: func(ce event.CreateEvent) bool {
// all new objects must be subject to reconciliation
return true
Expand Down
12 changes: 6 additions & 6 deletions controllers/shipwrightbuild_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/shipwright-io/operator/api/v1alpha1"
"github.com/shipwright-io/operator/api/v1beta1"
tektonoperatorv1alpha1 "github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
tektonoperatorv1alpha1client "github.com/tektoncd/operator/pkg/client/clientset/versioned/fake"
crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand All @@ -31,7 +31,7 @@ import (
// ready to interact with Manifestival, returning the Manifestival instance and the client.
func bootstrapShipwrightBuildReconciler(
t *testing.T,
b *v1alpha1.ShipwrightBuild,
b *v1beta1.ShipwrightBuild,
tcfg *tektonoperatorv1alpha1.TektonConfig,
tcrds []*crdv1.CustomResourceDefinition,
) (client.Client, *crdclientv1.Clientset, *tektonoperatorv1alpha1client.Clientset, *ShipwrightBuildReconciler) {
Expand All @@ -40,7 +40,7 @@ func bootstrapShipwrightBuildReconciler(
s := runtime.NewScheme()
s.AddKnownTypes(corev1.SchemeGroupVersion, &corev1.Namespace{})
s.AddKnownTypes(appsv1.SchemeGroupVersion, &appsv1.Deployment{})
s.AddKnownTypes(v1alpha1.GroupVersion, &v1alpha1.ShipwrightBuild{})
s.AddKnownTypes(v1beta1.GroupVersion, &v1beta1.ShipwrightBuild{})

logger := zap.New()

Expand Down Expand Up @@ -91,7 +91,7 @@ func bootstrapShipwrightBuildReconciler(
func TestShipwrightBuildReconciler_Finalizers(t *testing.T) {
g := o.NewGomegaWithT(t)

b := &v1alpha1.ShipwrightBuild{ObjectMeta: metav1.ObjectMeta{Name: "name", Namespace: "default"}}
b := &v1beta1.ShipwrightBuild{ObjectMeta: metav1.ObjectMeta{Name: "name", Namespace: "default"}}
_, _, _, r := bootstrapShipwrightBuildReconciler(t, b, &tektonoperatorv1alpha1.TektonConfig{}, []*crdv1.CustomResourceDefinition{})

// adding one entry on finalizers slice, making sure it's registered
Expand Down Expand Up @@ -123,12 +123,12 @@ func testShipwrightBuildReconcilerReconcile(t *testing.T, targetNamespace string
}
req := reconcile.Request{NamespacedName: namespacedName}

b := &v1alpha1.ShipwrightBuild{
b := &v1beta1.ShipwrightBuild{
ObjectMeta: metav1.ObjectMeta{
Name: namespacedName.Name,
Namespace: namespacedName.Namespace,
},
Spec: v1alpha1.ShipwrightBuildSpec{
Spec: v1beta1.ShipwrightBuildSpec{
TargetNamespace: targetNamespace,
},
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

operatorv1alpha1 "github.com/shipwright-io/operator/api/v1alpha1"
operatorv1beta1 "github.com/shipwright-io/operator/api/v1beta1"
// +kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -65,7 +65,7 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

err = operatorv1alpha1.AddToScheme(scheme.Scheme)
err = operatorv1beta1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

err = apiextv1.AddToScheme(scheme.Scheme)
Expand Down

0 comments on commit 415904b

Please sign in to comment.