Skip to content

Commit

Permalink
Update status remove bundle path (#106)
Browse files Browse the repository at this point in the history
* remove bundle path from Operator.Status
* reconciler: only update the resource being reconciled after resolution
* update condition reasons and conditions types lists

Signed-off-by: perdasilva <perdasilva@redhat.com>
  • Loading branch information
perdasilva committed Jan 27, 2023
1 parent edca8be commit 931493a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions api/v1alpha1/operator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func init() {
)
// TODO(user): add Reasons from above
operatorutil.ConditionReasons = append(operatorutil.ConditionReasons,
ReasonNotImplemented,
ReasonNotImplemented, ReasonResolutionSucceeded, ReasonResolutionFailed,
)
}

Expand All @@ -55,7 +55,6 @@ type OperatorStatus struct {
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
BundlePath string `json:"BundlePath,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ spec:
status:
description: OperatorStatus defines the observed state of Operator
properties:
BundlePath:
type: string
conditions:
items:
description: "Condition contains details for one aspect of the current
Expand Down
13 changes: 7 additions & 6 deletions controllers/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ package controllers
import (
"context"

operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
"github.com/operator-framework/operator-controller/internal/resolution"
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/bundles_and_dependencies"
"k8s.io/apimachinery/pkg/api/equality"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -30,6 +27,10 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"

operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
"github.com/operator-framework/operator-controller/internal/resolution"
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/bundles_and_dependencies"
)

// OperatorReconciler reconciles a Operator object
Expand Down Expand Up @@ -112,7 +113,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
message = err.Error()
} else {
// extract package bundle path from resolved variable
var bundlePath = ""
for _, variable := range solution.SelectedVariables() {
switch v := variable.(type) {
case *bundles_and_dependencies.BundleVariable:
Expand All @@ -121,15 +121,16 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
return ctrl.Result{}, err
}
if packageName == op.Spec.PackageName {
bundlePath, err = v.BundleEntity().BundlePath()
bundlePath, err := v.BundleEntity().BundlePath()
if err != nil {
return ctrl.Result{}, err
}
// TODO(perdasilva): use bundlePath to stamp out bundle deployment
_ = bundlePath
break
}
}
}
op.Status.BundlePath = bundlePath
}

// update operator status
Expand Down
7 changes: 4 additions & 3 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
"github.com/operator-framework/operator-controller/controllers"
operatorutil "github.com/operator-framework/operator-controller/internal/util"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
Expand All @@ -38,6 +35,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
"github.com/operator-framework/operator-controller/controllers"
operatorutil "github.com/operator-framework/operator-controller/internal/util"
//+kubebuilder:scaffold:imports
)

Expand Down

0 comments on commit 931493a

Please sign in to comment.