Repository: vmware-tanzu/octant
Pull request #830 (2020-04-09 19:33:47)

namespace all of Octants actions, even internal
Signed-off-by: Wayne Witzel III <wayne@riotousliving.com>


Finishes the work started with #820 



Patch:
diff --git a/internal/api/action_request_manager.go b/internal/api/action_request_manager.go
index d0646c68..6a772bb3 100644
--- a/internal/api/action_request_manager.go
+++ b/internal/api/action_request_manager.go
@@ -13,7 +13,7 @@ import (
 )
 
 const (
-	RequestPerformAction = "performAction"
+	RequestPerformAction = "action.octant.dev/performAction"
 )
 
 // ActionRequestManager manages action requests. Action requests allow a generic interface
diff --git a/internal/api/context_manager.go b/internal/api/context_manager.go
index 60a2312e..f3394bea 100644
--- a/internal/api/context_manager.go
+++ b/internal/api/context_manager.go
@@ -19,7 +19,7 @@ import (
 )
 
 const (
-	RequestSetContext = "setContext"
+	RequestSetContext = "action.octant.dev/setContext"
 )
 
 // ContextManagerOption is an option for configuring ContextManager.
diff --git a/internal/octant/actions.go b/internal/octant/actions.go
index 4e95af2c..75ce56a8 100644
--- a/internal/octant/actions.go
+++ b/internal/octant/actions.go
@@ -1,5 +1,11 @@
 package octant
 
 const (
-	ActionDeleteObject = "octant/deleteObject"
+	ActionDeleteObject            = "action.octant.dev/deleteObject"
+	ActionOverviewCordon          = "action.octant.dev/cordon"
+	ActionOverviewUncordon        = "action.octant.dev/uncordon"
+	ActionOverviewContainerEditor = "action.octant.dev/containerEditor"
+	ActionOverviewCronjob         = "action.octant.dev/cronJob"
+	ActionOverviewServiceEditor   = "action.octant.dev/serviceEditor"
+	ActionDeploymentConfiguration = "action.octant.dev/deploymentConfiguration"
 )
diff --git a/internal/octant/container_editor.go b/internal/octant/container_editor.go
index 2e416449..fdc5f22d 100644
--- a/internal/octant/container_editor.go
+++ b/internal/octant/container_editor.go
@@ -37,7 +37,7 @@ func NewContainerEditor(objectStore store.Store) *ContainerEditor {
 
 // ActionName returns name of this action.
 func (e *ContainerEditor) ActionName() string {
-	return "overview/containerEditor"
+	return "action.octant.dev/containerEditor"
 }
 
 // Handle edits a container. Supported edits:
diff --git a/internal/octant/cordon.go b/internal/octant/cordon.go
index b9db6661..69f13512 100644
--- a/internal/octant/cordon.go
+++ b/internal/octant/cordon.go
@@ -44,7 +44,7 @@ func NewCordon(objectStore store.Store, clusterClient cluster.ClientInterface) *
 
 // ActionName returns the name of this action
 func (c *Cordon) ActionName() string {
-	return "overview/cordon"
+	return "action.octant.dev/cordon"
 }
 
 // Handle executing cordon
@@ -147,7 +147,7 @@ func NewUncordon(objectStore store.Store, clusterClient cluster.ClientInterface)
 
 // ActionName returns the name of this action
 func (u *Uncordon) ActionName() string {
-	return "overview/uncordon"
+	return "action.octant.dev/uncordon"
 }
 
 // Handle executing uncordon
diff --git a/internal/octant/cronjob.go b/internal/octant/cronjob.go
index a8ac10d1..d8235991 100644
--- a/internal/octant/cronjob.go
+++ b/internal/octant/cronjob.go
@@ -42,7 +42,7 @@ func NewCronJobTrigger(objectStore store.Store, clusterClient cluster.ClientInte
 
 // ActionName returns the name of this action
 func (c *CronJobTrigger) ActionName() string {
-	return "overview/cronjob"
+	return "action.octant.dev/cronJob"
 }
 
 // Handle executing cronjob
diff --git a/internal/octant/deployment_configuration_editor.go b/internal/octant/deployment_configuration_editor.go
index bf7b6ee9..8d54cfd2 100644
--- a/internal/octant/deployment_configuration_editor.go
+++ b/internal/octant/deployment_configuration_editor.go
@@ -34,7 +34,7 @@ func NewDeploymentConfigurationEditor(logger log.Logger, objectStore store.Store
 
 // ActionName returns the action name for this editor.
 func (e *DeploymentConfigurationEditor) ActionName() string {
-	return "deployment/configuration"
+	return "action.octant.dev/deploymentConfiguration"
 }
 
 // Handle edits a deployment. Supported edits:
diff --git a/internal/octant/service_configuration_editor.go b/internal/octant/service_configuration_editor.go
index 906465b3..a96fdb7b 100644
--- a/internal/octant/service_configuration_editor.go
+++ b/internal/octant/service_configuration_editor.go
@@ -33,7 +33,7 @@ func NewServiceConfigurationEditor(objectStore store.Store) *ServiceConfiguratio
 
 // ActionName returns the name of this action.
 func (s *ServiceConfigurationEditor) ActionName() string {
-	return "overview/serviceEditor"
+	return "action.octant.dev/serviceEditor"
 }
 
 // Handle edits a service: Supported edits:
diff --git a/internal/printer/container.go b/internal/printer/container.go
index f0eb2fce..92b3653f 100644
--- a/internal/printer/container.go
+++ b/internal/printer/container.go
@@ -13,6 +13,8 @@ import (
 	"sort"
 	"strings"
 
+	"github.com/vmware-tanzu/octant/internal/octant"
+
 	"github.com/vmware-tanzu/octant/internal/portforward"
 
 	"github.com/pkg/errors"
@@ -487,7 +489,7 @@ func editContainerAction(owner runtime.Object, container *corev1.Container) (com
 		return component.Action{}, err
 	}
 
-	form, err := component.CreateFormForObject("overview/containerEditor", owner,
+	form, err := component.CreateFormForObject(octant.ActionOverviewContainerEditor, owner,
 		component.NewFormFieldText("Image", "containerImage", container.Image),
 		component.NewFormFieldHidden("containersPath", string(containersPathData)),
 		component.NewFormFieldHidden("containerName", container.Name),
diff --git a/internal/printer/cronjob.go b/internal/printer/cronjob.go
index a9f05f4e..800fa851 100644
--- a/internal/printer/cronjob.go
+++ b/internal/printer/cronjob.go
@@ -8,6 +8,7 @@ package printer
 import (
 	"context"
 	"fmt"
+	"github.com/vmware-tanzu/octant/internal/octant"
 	"strconv"
 
 	"github.com/pkg/errors"
@@ -39,7 +40,7 @@ func CronJobListHandler(ctx context.Context, list *batchv1beta1.CronJobList, opt
 		buttonGroup := component.NewButtonGroup()
 		buttonGroup.AddButton(
 			component.NewButton("Trigger",
-				action.CreatePayload("overview/cronjob", action.Payload{
+				action.CreatePayload(octant.ActionOverviewCronjob, action.Payload{
 					"namespace":  c.Namespace,
 					"apiVersion": c.APIVersion,
 					"kind":       c.Kind,
diff --git a/internal/printer/deployment.go b/internal/printer/deployment.go
index cdd226d0..67879fa3 100644
--- a/internal/printer/deployment.go
+++ b/internal/printer/deployment.go
@@ -8,6 +8,7 @@ package printer
 import (
 	"context"
 	"fmt"
+	"github.com/vmware-tanzu/octant/internal/octant"
 
 	"github.com/pkg/errors"
 	appsv1 "k8s.io/api/apps/v1"
@@ -261,7 +262,7 @@ func editDeploymentAction(deployment *appsv1.Deployment) ([]component.Action, er
 		return []component.Action{}, nil
 	}
 
-	form, err := component.CreateFormForObject("deployment/configuration", deployment,
+	form, err := component.CreateFormForObject(octant.ActionDeploymentConfiguration, deployment,
 		component.NewFormFieldNumber("Replicas", "replicas", fmt.Sprintf("%d", *replicas)),
 	)
 	if err != nil {
diff --git a/internal/printer/service.go b/internal/printer/service.go
index bc00fba0..408e0eb9 100644
--- a/internal/printer/service.go
+++ b/internal/printer/service.go
@@ -8,6 +8,7 @@ package printer
 import (
 	"context"
 	"fmt"
+	"github.com/vmware-tanzu/octant/internal/octant"
 	"strings"
 
 	"github.com/pkg/errors"
@@ -237,7 +238,7 @@ func editServiceAction(ctx context.Context, service *corev1.Service, options Opt
 		}
 	}
 
-	form, err := component.CreateFormForObject("overview/serviceEditor", service,
+	form, err := component.CreateFormForObject(octant.ActionOverviewServiceEditor, service,
 		component.NewFormFieldSelect("Selectors", "selectors", choices, true))
 	if err != nil {
 		return component.Action{}, err
diff --git a/web/src/app/modules/shared/terminals/terminals.service.ts b/web/src/app/modules/shared/terminals/terminals.service.ts
index 171f1b1a..775bff38 100644
--- a/web/src/app/modules/shared/terminals/terminals.service.ts
+++ b/web/src/app/modules/shared/terminals/terminals.service.ts
@@ -33,7 +33,7 @@ export class TerminalOutputStreamer {
 
   private terminalUrl(): string {
     return [
-      'event.octant.dev',
+      'event.octant.dev/',
       'terminals',
       `namespace/${this.namespace}`,
       `pod/${this.pod}`,


Test patch:
diff --git a/internal/octant/container_editor_test.go b/internal/octant/container_editor_test.go
index 98f18b14..91aa904b 100644
--- a/internal/octant/container_editor_test.go
+++ b/internal/octant/container_editor_test.go
@@ -53,7 +53,7 @@ func TestNewContainerEditor(t *testing.T) {
 
 	ctx := context.Background()
 
-	payload := action.CreatePayload("overview/containerEditor", map[string]interface{}{
+	payload := action.CreatePayload(ActionOverviewContainerEditor, map[string]interface{}{
 		"apiVersion":     "apps/v1",
 		"kind":           "Deployment",
 		"namespace":      "default",
diff --git a/internal/octant/cordon_test.go b/internal/octant/cordon_test.go
index a8788fb1..25e928fa 100644
--- a/internal/octant/cordon_test.go
+++ b/internal/octant/cordon_test.go
@@ -95,9 +95,9 @@ func Test_Cordon(t *testing.T) {
 			require.NoError(t, err)
 
 			cordon := octant.NewCordon(objectStore, clusterClient)
-			assert.Equal(t, "overview/cordon", cordon.ActionName())
+			assert.Equal(t, octant.ActionOverviewCordon, cordon.ActionName())
 
-			payload := action.CreatePayload("overview/cordon", map[string]interface{}{
+			payload := action.CreatePayload(octant.ActionOverviewCordon, map[string]interface{}{
 				"apiVersion": "v1",
 				"kind":       "Node",
 				"name":       tc.key.Name,
@@ -178,16 +178,16 @@ func Test_Uncordon(t *testing.T) {
 			_, err := fakeClientset.CoreV1().Nodes().Create(node)
 			require.NoError(t, err)
 
-			cordon := octant.NewUncordon(objectStore, clusterClient)
-			assert.Equal(t, "overview/uncordon", cordon.ActionName())
+			uncordon := octant.NewUncordon(objectStore, clusterClient)
+			assert.Equal(t, octant.ActionOverviewUncordon, uncordon.ActionName())
 
-			payload := action.CreatePayload("overview/uncordon", map[string]interface{}{
+			payload := action.CreatePayload(octant.ActionOverviewUncordon, map[string]interface{}{
 				"apiVersion": "v1",
 				"kind":       "Node",
 				"name":       tc.key.Name,
 			})
 
-			require.NoError(t, cordon.Handle(ctx, alerter, payload))
+			require.NoError(t, uncordon.Handle(ctx, alerter, payload))
 		})
 	}
 }
diff --git a/internal/octant/cronjob_test.go b/internal/octant/cronjob_test.go
index fc418072..7d5f823b 100644
--- a/internal/octant/cronjob_test.go
+++ b/internal/octant/cronjob_test.go
@@ -76,9 +76,9 @@ func Test_CronJobTrigger(t *testing.T) {
 	require.NoError(t, err)
 
 	trigger := octant.NewCronJobTrigger(objectStore, clusterClient)
-	assert.Equal(t, "overview/cronjob", trigger.ActionName())
+	assert.Equal(t, octant.ActionOverviewCronjob, trigger.ActionName())
 
-	payload := action.CreatePayload("overview/cronjob", map[string]interface{}{
+	payload := action.CreatePayload(octant.ActionOverviewCronjob, map[string]interface{}{
 		"namespace":  key.Namespace,
 		"apiVersion": key.APIVersion,
 		"kind":       key.Kind,
diff --git a/internal/octant/deployment_configuration_editor_test.go b/internal/octant/deployment_configuration_editor_test.go
index cf60676b..334cd717 100644
--- a/internal/octant/deployment_configuration_editor_test.go
+++ b/internal/octant/deployment_configuration_editor_test.go
@@ -56,7 +56,7 @@ func TestDeploymentConfigurationEditor(t *testing.T) {
 		})
 
 	configurationEditor := NewDeploymentConfigurationEditor(logger, objectStore)
-	assert.Equal(t, "deployment/configuration", configurationEditor.ActionName())
+	assert.Equal(t, ActionDeploymentConfiguration, configurationEditor.ActionName())
 
 	ctx := context.Background()
 
diff --git a/internal/octant/service_configuration_editor_test.go b/internal/octant/service_configuration_editor_test.go
index 5eb88473..147bade7 100644
--- a/internal/octant/service_configuration_editor_test.go
+++ b/internal/octant/service_configuration_editor_test.go
@@ -54,7 +54,7 @@ func TestServiceConfigurationEditor(t *testing.T) {
 		})
 
 	configurationEditor := NewServiceConfigurationEditor(objectStore)
-	assert.Equal(t, "overview/serviceEditor", configurationEditor.ActionName())
+	assert.Equal(t, ActionOverviewServiceEditor, configurationEditor.ActionName())
 
 	ctx := context.Background()
 
diff --git a/internal/printer/container_test.go b/internal/printer/container_test.go
index d45e1391..d7927d91 100644
--- a/internal/printer/container_test.go
+++ b/internal/printer/container_test.go
@@ -8,6 +8,7 @@ package printer
 import (
 	"context"
 	"fmt"
+	"github.com/vmware-tanzu/octant/internal/octant"
 	"reflect"
 	"testing"
 	"time"
@@ -471,7 +472,7 @@ func Test_editContainerAction(t *testing.T) {
 	got, err := editContainerAction(deployment, &container)
 	require.NoError(t, err)
 
-	form, err := component.CreateFormForObject("overview/containerEditor", deployment,
+	form, err := component.CreateFormForObject(octant.ActionOverviewContainerEditor, deployment,
 		component.NewFormFieldText("Image", "containerImage", container.Image),
 		component.NewFormFieldHidden("containersPath", `["spec","template","spec","containers"]`),
 		component.NewFormFieldHidden("containerName", container.Name),
diff --git a/internal/printer/cronjob_test.go b/internal/printer/cronjob_test.go
index c8b3ed43..a383d28b 100644
--- a/internal/printer/cronjob_test.go
+++ b/internal/printer/cronjob_test.go
@@ -7,6 +7,7 @@ package printer
 
 import (
 	"context"
+	"github.com/vmware-tanzu/octant/internal/octant"
 	"testing"
 	"time"
 
@@ -70,7 +71,7 @@ func Test_CronJobListHandler(t *testing.T) {
 	buttonGroup := component.NewButtonGroup()
 	buttonGroup.AddButton(
 		component.NewButton("Trigger",
-			action.CreatePayload("overview/cronjob", action.Payload{
+			action.CreatePayload(octant.ActionOverviewCronjob, action.Payload{
 				"namespace":  cronJob.Namespace,
 				"apiVersion": cronJob.APIVersion,
 				"kind":       cronJob.Kind,
diff --git a/internal/printer/deployment_test.go b/internal/printer/deployment_test.go
index 6d16bdec..31bc4ece 100644
--- a/internal/printer/deployment_test.go
+++ b/internal/printer/deployment_test.go
@@ -7,6 +7,7 @@ package printer
 
 import (
 	"context"
+	"github.com/vmware-tanzu/octant/internal/octant"
 	"testing"
 	"time"
 
@@ -371,7 +372,7 @@ func Test_editDeploymentAction(t *testing.T) {
 				component.NewFormFieldHidden("kind", kind),
 				component.NewFormFieldHidden("name", deployment.Name),
 				component.NewFormFieldHidden("namespace", deployment.Namespace),
-				component.NewFormFieldHidden("action", "deployment/configuration"),
+				component.NewFormFieldHidden("action", octant.ActionDeploymentConfiguration),
 			},
 		},
 	}