Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Mar 2, 2021
1 parent 814cdf0 commit 38a4e07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
17 changes: 9 additions & 8 deletions pkg/deploy/dev-workspace/dev_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/eclipse/che-operator/pkg/deploy"
"github.com/eclipse/che-operator/pkg/util"
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
Expand Down Expand Up @@ -87,20 +88,16 @@ func ReconcileDevWorkspace(deployContext *deploy.DeployContext) (bool, error) {
return true, nil
}

devWorkspaceDeploymentExists, err := deploy.IsExists(
devWorkspaceWebhookExists, err := deploy.IsExists(
deployContext,
client.ObjectKey{Name: DevWorkspaceDeploymentName, Namespace: DevWorkspaceNamespace},
&appsv1.Deployment{},
client.ObjectKey{Name: DevWorkspaceWebhookName},
&admissionregistrationv1.MutatingWebhookConfiguration{},
)
if err != nil {
return false, err
}

if !devWorkspaceDeploymentExists {
if err := checkWebTerminalSubscription(deployContext); err != nil {
return false, err
}

if !devWorkspaceWebhookExists {
for _, syncItem := range syncItems {
done, err := syncItem(deployContext)
if !util.IsTestMode() {
Expand All @@ -109,6 +106,10 @@ func ReconcileDevWorkspace(deployContext *deploy.DeployContext) (bool, error) {
}
}
}
} else {
if err := checkWebTerminalSubscription(deployContext); err != nil {
return false, err
}
}

return true, nil
Expand Down
10 changes: 9 additions & 1 deletion pkg/deploy/dev-workspace/dev_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/eclipse/che-operator/pkg/deploy"
"github.com/eclipse/che-operator/pkg/util"
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
Expand Down Expand Up @@ -72,11 +73,18 @@ func TestReconcileDevWorkspaceShouldThrowErrorIfWebTerminalSubscriptionExists(t
Spec: &operatorsv1alpha1.SubscriptionSpec{},
}

webhook := admissionregistrationv1.MutatingWebhookConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: DevWorkspaceWebhookName,
},
}

scheme := scheme.Scheme
orgv1.SchemeBuilder.AddToScheme(scheme)
scheme.AddKnownTypes(operatorsv1alpha1.SchemeGroupVersion, &operatorsv1alpha1.Subscription{})
scheme.AddKnownTypes(admissionregistrationv1.SchemeGroupVersion, &admissionregistrationv1.MutatingWebhookConfiguration{})

cli := fake.NewFakeClientWithScheme(scheme, subscription)
cli := fake.NewFakeClientWithScheme(scheme, subscription, &webhook)

deployContext := &deploy.DeployContext{
CheCluster: &orgv1.CheCluster{
Expand Down

0 comments on commit 38a4e07

Please sign in to comment.