Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove webConsolePlugin from ToolchainClusterConfig (phase 2) #588

Merged
merged 8 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ Requires Go version 1.20.x (1.20.11 or higher) - download for your development e

This repository uses https://github.com/golang/go/wiki/Modules[Go modules].

== Building the Web Console Plugin source

The web console plugin serves up some static Javascript files which have been compiled from NodeJS/React source contained in the /webconsole_source directory.

The `make generate-webconsole-scripts` make target will recompile this source by starting up a container with Podman with the necessary tooling, then compile these source files, after which it will overwrite the content in /pkg/consoleplugin/contentserver/static with the newly compiled code.

After executing this target the updated files should be committed to the repo.

== Development

The dev.mk targets in the toolchain-e2e repository can be used to build and deploy the host and member operators for development, or follow the guide - https://github.com/codeready-toolchain/toolchain-e2e/blob/master/dev_install.adoc
Expand Down
21 changes: 0 additions & 21 deletions build/Dockerfile.consoleplugin

This file was deleted.

144 changes: 0 additions & 144 deletions cmd/consoleplugin/main.go

This file was deleted.

2 changes: 0 additions & 2 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ spec:
value: "member-operator"
- name: MEMBER_OPERATOR_WEBHOOK_IMAGE
value: REPLACE_MEMBER_OPERATOR_WEBHOOK_IMAGE
- name: MEMBER_OPERATOR_WEBCONSOLEPLUGIN_IMAGE
value: REPLACE_MEMBER_OPERATOR_WEBCONSOLEPLUGIN_IMAGE
resources:
requests:
cpu: 500m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"

"github.com/codeready-toolchain/member-operator/pkg/autoscaler"
consoledeploy "github.com/codeready-toolchain/member-operator/pkg/consoleplugin/deploy"
"github.com/codeready-toolchain/member-operator/pkg/webhook/deploy"
"github.com/go-logr/logr"
"sigs.k8s.io/controller-runtime/pkg/builder"
Expand Down Expand Up @@ -65,10 +64,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
return reconcile.Result{}, err
}

if err := r.handleWebConsolePluginDeploy(ctx, crtConfig, request.Namespace); err != nil {
return reconcile.Result{}, err
}

return reconcile.Result{}, nil
}

Expand Down Expand Up @@ -116,19 +111,3 @@ func (r *Reconciler) handleWebhookDeploy(ctx context.Context, cfg membercfg.Conf
}
return nil
}

func (r *Reconciler) handleWebConsolePluginDeploy(ctx context.Context, cfg membercfg.Configuration, namespace string) error {
logger := log.FromContext(ctx)

if cfg.WebConsolePlugin().Deploy() {
webconsolepluginImage := os.Getenv("MEMBER_OPERATOR_WEBCONSOLEPLUGIN_IMAGE")
logger.Info("(Re)Deploying web console plugin")
if err := consoledeploy.ConsolePlugin(ctx, r.Client, r.Client.Scheme(), namespace, webconsolepluginImage); err != nil {
return err
}
logger.Info("(Re)Deployed web console plugin")
} else {
logger.Info("Skipping deployment of web console plugin")
}
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
membercfg "github.com/codeready-toolchain/toolchain-common/pkg/configuration/memberoperatorconfig"
"github.com/codeready-toolchain/toolchain-common/pkg/test"
testconfig "github.com/codeready-toolchain/toolchain-common/pkg/test/config"
errs "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -318,68 +317,6 @@ func TestHandleWebhookDeploy(t *testing.T) {
})
}

func TestHandleWebConsolePluginDeploy(t *testing.T) {
t.Run("deployment not created when webconsoleplugin deploy is false", func(t *testing.T) {
// given
config := commonconfig.NewMemberOperatorConfigWithReset(t, testconfig.WebConsolePlugin().Deploy(false))
controller, cl := prepareReconcile(t, config)

actualConfig, err := membercfg.GetConfiguration(cl)
require.NoError(t, err)

ctx := log.IntoContext(context.TODO(), controller.Log)

// when
err = controller.handleWebConsolePluginDeploy(ctx, actualConfig, test.MemberOperatorNs)

// then
require.NoError(t, err)
actualDeployment := &appsv1.Deployment{}
err = cl.Get(context.TODO(), test.NamespacedName(test.MemberOperatorNs, "member-operator-console-plugin"), actualDeployment)
require.Error(t, err)
require.True(t, errors.IsNotFound(err))
})

t.Run("deployment created when webconsoleplugin deploy is true", func(t *testing.T) {
// given
config := commonconfig.NewMemberOperatorConfigWithReset(t, testconfig.WebConsolePlugin().Deploy(true))
controller, cl := prepareReconcile(t, config)
actualConfig, err := membercfg.GetConfiguration(cl)
require.NoError(t, err)

ctx := log.IntoContext(context.TODO(), controller.Log)

// when
err = controller.handleWebConsolePluginDeploy(ctx, actualConfig, test.MemberOperatorNs)

// then
require.NoError(t, err)
actualDeployment := &appsv1.Deployment{}
err = cl.Get(context.TODO(), test.NamespacedName(test.MemberOperatorNs, "member-operator-console-plugin"), actualDeployment)
require.NoError(t, err)
})

t.Run("deployment error", func(t *testing.T) {
// given
config := commonconfig.NewMemberOperatorConfigWithReset(t, testconfig.WebConsolePlugin().Deploy(true))
controller, cl := prepareReconcile(t, config)
actualConfig, err := membercfg.GetConfiguration(cl)
require.NoError(t, err)

ctx := log.IntoContext(context.TODO(), controller.Log)

// when
cl.(*test.FakeClient).MockGet = func(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
return fmt.Errorf("client error")
}
err = controller.handleWebConsolePluginDeploy(ctx, actualConfig, test.MemberOperatorNs)

// then
require.ErrorContains(t, err, "cannot deploy console plugin template")
require.ErrorContains(t, errs.Cause(err), "client error")
})
}

func prepareReconcile(t *testing.T, initObjs ...runtime.Object) (*Reconciler, client.Client) {
os.Setenv("WATCH_NAMESPACE", test.MemberOperatorNs)
restore := test.SetEnvVarAndRestore(t, "MEMBER_OPERATOR_WEBHOOK_IMAGE", "webhookimage")
Expand Down
Loading
Loading