diff --git a/.github/actions/cmx-versions/dist/index.js b/.github/actions/cmx-versions/dist/index.js index 85624a1de8..74168e22f1 100644 --- a/.github/actions/cmx-versions/dist/index.js +++ b/.github/actions/cmx-versions/dist/index.js @@ -7661,7 +7661,7 @@ async function getClusterVersions() { clusterVersions.forEach((distribution) => { const distroName = distribution.short_name; - if (distroName === 'helmvm' || distroName === 'kurl') { + if (distroName === 'embedded_cluster' || distroName === 'kurl') { // excluding the embedded distributions return; } @@ -7710,4 +7710,4 @@ getClusterVersions(); module.exports = __webpack_exports__; /******/ })() -; \ No newline at end of file +; diff --git a/.github/actions/cmx-versions/index.js b/.github/actions/cmx-versions/index.js index 213ffe0939..ffc802451d 100644 --- a/.github/actions/cmx-versions/index.js +++ b/.github/actions/cmx-versions/index.js @@ -41,7 +41,7 @@ async function getClusterVersions() { clusterVersions.forEach((distribution) => { const distroName = distribution.short_name; - if (distroName === 'helmvm' || distroName === 'kurl') { + if (distroName === 'embedded_cluster' || distroName === 'kurl') { // excluding the embedded distributions return; } diff --git a/.github/workflows/regression.yaml b/.github/workflows/regression.yaml index 2a99593730..bd40a77491 100644 --- a/.github/workflows/regression.yaml +++ b/.github/workflows/regression.yaml @@ -191,9 +191,9 @@ jobs: is_upgrade: "1" }, { - name: "type=helmvm cluster, env=online, phase=new install, rbac=cluster admin", - backend_config: "helmvm-online-install-backend-config.tfvars", - terraform_script: "helmvm-online-install.sh" + name: "type=embeddedcluster cluster, env=online, phase=new install, rbac=cluster admin", + backend_config: "embeddedcluster-online-install-backend-config.tfvars", + terraform_script: "embeddedcluster-online-install.sh" } ] steps: diff --git a/migrations/tables/k0s_tokens.yaml b/migrations/tables/embeded_cluster_tokens.yaml similarity index 84% rename from migrations/tables/k0s_tokens.yaml rename to migrations/tables/embeded_cluster_tokens.yaml index 1ae6760972..6c233ba4d9 100644 --- a/migrations/tables/k0s_tokens.yaml +++ b/migrations/tables/embeded_cluster_tokens.yaml @@ -1,9 +1,9 @@ apiVersion: schemas.schemahero.io/v1alpha4 kind: Table metadata: - name: k0s-tokens + name: embedded-cluster-tokens spec: - name: k0s_tokens + name: embedded_cluster_tokens requires: [] schema: rqlite: diff --git a/pkg/helmvm/delete_node.go b/pkg/embeddedcluster/delete_node.go similarity index 90% rename from pkg/helmvm/delete_node.go rename to pkg/embeddedcluster/delete_node.go index 24d7e5e46d..a50a99eb75 100644 --- a/pkg/helmvm/delete_node.go +++ b/pkg/embeddedcluster/delete_node.go @@ -1,4 +1,4 @@ -package helmvm +package embeddedcluster import ( "context" diff --git a/pkg/helmvm/drain_node.go b/pkg/embeddedcluster/drain_node.go similarity index 88% rename from pkg/helmvm/drain_node.go rename to pkg/embeddedcluster/drain_node.go index b8fa55afbb..0d1439b979 100644 --- a/pkg/helmvm/drain_node.go +++ b/pkg/embeddedcluster/drain_node.go @@ -1,4 +1,4 @@ -package helmvm +package embeddedcluster import ( "context" diff --git a/pkg/helmvm/exec.go b/pkg/embeddedcluster/exec.go similarity index 94% rename from pkg/helmvm/exec.go rename to pkg/embeddedcluster/exec.go index 04f94635de..be71e0a014 100644 --- a/pkg/helmvm/exec.go +++ b/pkg/embeddedcluster/exec.go @@ -1,4 +1,4 @@ -package helmvm +package embeddedcluster import ( corev1client "k8s.io/client-go/kubernetes/typed/core/v1" diff --git a/pkg/helmvm/helmvm_node.go b/pkg/embeddedcluster/helmvm_node.go similarity index 98% rename from pkg/helmvm/helmvm_node.go rename to pkg/embeddedcluster/helmvm_node.go index a9b17f497e..2b7fff9dd7 100644 --- a/pkg/helmvm/helmvm_node.go +++ b/pkg/embeddedcluster/helmvm_node.go @@ -1,4 +1,4 @@ -package helmvm +package embeddedcluster import ( "context" @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/replicatedhq/kots/pkg/helmvm/types" + "github.com/replicatedhq/kots/pkg/embeddedcluster/types" "github.com/replicatedhq/kots/pkg/k8sutil" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/helmvm/helmvm_nodes.go b/pkg/embeddedcluster/helmvm_nodes.go similarity index 88% rename from pkg/helmvm/helmvm_nodes.go rename to pkg/embeddedcluster/helmvm_nodes.go index 9396e6508c..7b0eb7729e 100644 --- a/pkg/helmvm/helmvm_nodes.go +++ b/pkg/embeddedcluster/helmvm_nodes.go @@ -1,9 +1,10 @@ -package helmvm +package embeddedcluster import ( "context" + "github.com/pkg/errors" - "github.com/replicatedhq/kots/pkg/helmvm/types" + "github.com/replicatedhq/kots/pkg/embeddedcluster/types" "github.com/replicatedhq/kots/pkg/k8sutil" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -12,7 +13,7 @@ import ( ) // GetNodes will get a list of nodes with stats -func GetNodes(ctx context.Context, client kubernetes.Interface) (*types.HelmVMNodes, error) { +func GetNodes(ctx context.Context, client kubernetes.Interface) (*types.EmbeddedClusterNodes, error) { nodes, err := client.CoreV1().Nodes().List(ctx, metav1.ListOptions{}) if err != nil { return nil, errors.Wrap(err, "list nodes") @@ -28,7 +29,7 @@ func GetNodes(ctx context.Context, client kubernetes.Interface) (*types.HelmVMNo return nil, errors.Wrap(err, "failed to create metrics client") } - toReturn := types.HelmVMNodes{} + toReturn := types.EmbeddedClusterNodes{} for _, node := range nodes.Items { nodeMet, err := nodeMetrics(ctx, client, metricsClient, node) @@ -39,11 +40,11 @@ func GetNodes(ctx context.Context, client kubernetes.Interface) (*types.HelmVMNo toReturn.Nodes = append(toReturn.Nodes, *nodeMet) } - isHelmVM, err := IsHelmVM(client) + isEmbeddedCluster, err := IsEmbeddedCluster(client) if err != nil { - return nil, errors.Wrap(err, "is helmvm") + return nil, errors.Wrap(err, "is embeddedcluster") } - toReturn.IsHelmVMEnabled = isHelmVM + toReturn.IsEmbeddedClusterEnabled = isEmbeddedCluster isHA, err := IsHA(client) if err != nil { diff --git a/pkg/helmvm/node_join.go b/pkg/embeddedcluster/node_join.go similarity index 97% rename from pkg/helmvm/node_join.go rename to pkg/embeddedcluster/node_join.go index 4a4bb6c068..b0835b3761 100644 --- a/pkg/helmvm/node_join.go +++ b/pkg/embeddedcluster/node_join.go @@ -1,4 +1,4 @@ -package helmvm +package embeddedcluster import ( "context" @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/replicatedhq/kots/pkg/helmvm/types" + "github.com/replicatedhq/kots/pkg/embeddedcluster/types" corev1 "k8s.io/api/core/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -24,7 +24,7 @@ type joinTokenEntry struct { var joinTokenMapMut = sync.Mutex{} var joinTokenMap = map[string]*joinTokenEntry{} -// GenerateAddNodeToken will generate the HelmVM node add command for a primary or secondary node +// GenerateAddNodeToken will generate the embedded cluster node add command for a node with the specified roles // join commands will last for 24 hours, and will be cached for 1 hour after first generation func GenerateAddNodeToken(ctx context.Context, client kubernetes.Interface, nodeRole string) (string, error) { // get the joinToken struct entry for this node role @@ -214,7 +214,7 @@ func runAddNodeCommandPod(ctx context.Context, client kubernetes.Interface, node } // GenerateAddNodeCommand returns the command a user should run to add a node with the provided token -// the command will be of the form 'helmvm node join ip:port UUID' +// the command will be of the form 'embeddedcluster node join ip:port UUID' func GenerateAddNodeCommand(ctx context.Context, client kubernetes.Interface, token string) (string, error) { cm, err := ReadConfigMap(client) if err != nil { diff --git a/pkg/helmvm/types/types.go b/pkg/embeddedcluster/types/types.go similarity index 88% rename from pkg/helmvm/types/types.go rename to pkg/embeddedcluster/types/types.go index 10bf390368..f9b93a4b8c 100644 --- a/pkg/helmvm/types/types.go +++ b/pkg/embeddedcluster/types/types.go @@ -3,10 +3,10 @@ package types const EMBEDDED_CLUSTER_LABEL = "kots.io/embedded-cluster" const EMBEDDED_CLUSTER_ROLE_LABEL = EMBEDDED_CLUSTER_LABEL + "-role" -type HelmVMNodes struct { - Nodes []Node `json:"nodes"` - HA bool `json:"ha"` - IsHelmVMEnabled bool `json:"isHelmVMEnabled"` +type EmbeddedClusterNodes struct { + Nodes []Node `json:"nodes"` + HA bool `json:"ha"` + IsEmbeddedClusterEnabled bool `json:"isEmbeddedClusterEnabled"` } type Node struct { diff --git a/pkg/helmvm/util.go b/pkg/embeddedcluster/util.go similarity index 93% rename from pkg/helmvm/util.go rename to pkg/embeddedcluster/util.go index 87b6bfe285..87f120b7d8 100644 --- a/pkg/helmvm/util.go +++ b/pkg/embeddedcluster/util.go @@ -1,4 +1,4 @@ -package helmvm +package embeddedcluster import ( "context" @@ -18,7 +18,7 @@ func ReadConfigMap(client kubernetes.Interface) (*corev1.ConfigMap, error) { return client.CoreV1().ConfigMaps(configMapNamespace).Get(context.TODO(), configMapName, metav1.GetOptions{}) } -func IsHelmVM(clientset kubernetes.Interface) (bool, error) { +func IsEmbeddedCluster(clientset kubernetes.Interface) (bool, error) { if clientset == nil { return false, fmt.Errorf("clientset is nil") } diff --git a/pkg/handlers/helmvm_delete_node.go b/pkg/handlers/embedded_cluster_delete_node.go similarity index 82% rename from pkg/handlers/helmvm_delete_node.go rename to pkg/handlers/embedded_cluster_delete_node.go index 1b732ab07f..ea55401654 100644 --- a/pkg/handlers/helmvm_delete_node.go +++ b/pkg/handlers/embedded_cluster_delete_node.go @@ -5,14 +5,14 @@ import ( "net/http" "github.com/gorilla/mux" - "github.com/replicatedhq/kots/pkg/helmvm" + "github.com/replicatedhq/kots/pkg/embeddedcluster" "github.com/replicatedhq/kots/pkg/k8sutil" "github.com/replicatedhq/kots/pkg/logger" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func (h *Handler) DeleteHelmVMNode(w http.ResponseWriter, r *http.Request) { +func (h *Handler) DeleteEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) { client, err := k8sutil.GetClientset() if err != nil { logger.Error(err) @@ -41,7 +41,7 @@ func (h *Handler) DeleteHelmVMNode(w http.ResponseWriter, r *http.Request) { return } - if err := helmvm.DeleteNode(ctx, client, restconfig, node); err != nil { + if err := embeddedcluster.DeleteNode(ctx, client, restconfig, node); err != nil { logger.Error(err) w.WriteHeader(http.StatusInternalServerError) return diff --git a/pkg/handlers/helmvm_drain_node.go b/pkg/handlers/embedded_cluster_drain_node.go similarity index 82% rename from pkg/handlers/helmvm_drain_node.go rename to pkg/handlers/embedded_cluster_drain_node.go index ae0a337f6f..ae59dc5071 100644 --- a/pkg/handlers/helmvm_drain_node.go +++ b/pkg/handlers/embedded_cluster_drain_node.go @@ -5,14 +5,14 @@ import ( "net/http" "github.com/gorilla/mux" - "github.com/replicatedhq/kots/pkg/helmvm" + "github.com/replicatedhq/kots/pkg/embeddedcluster" "github.com/replicatedhq/kots/pkg/k8sutil" "github.com/replicatedhq/kots/pkg/logger" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func (h *Handler) DrainHelmVMNode(w http.ResponseWriter, r *http.Request) { +func (h *Handler) DrainEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) { client, err := k8sutil.GetClientset() if err != nil { logger.Error(err) @@ -36,7 +36,7 @@ func (h *Handler) DrainHelmVMNode(w http.ResponseWriter, r *http.Request) { // This pod may get evicted and not be able to respond to the request go func() { - if err := helmvm.DrainNode(ctx, client, node); err != nil { + if err := embeddedcluster.DrainNode(ctx, client, node); err != nil { logger.Error(err) return } diff --git a/pkg/handlers/helmvm_get.go b/pkg/handlers/embedded_cluster_get.go similarity index 67% rename from pkg/handlers/helmvm_get.go rename to pkg/handlers/embedded_cluster_get.go index 4f736996ed..b08d02072a 100644 --- a/pkg/handlers/helmvm_get.go +++ b/pkg/handlers/embedded_cluster_get.go @@ -4,12 +4,12 @@ import ( "net/http" "github.com/gorilla/mux" - "github.com/replicatedhq/kots/pkg/helmvm" + "github.com/replicatedhq/kots/pkg/embeddedcluster" "github.com/replicatedhq/kots/pkg/k8sutil" "github.com/replicatedhq/kots/pkg/logger" ) -func (h *Handler) GetHelmVMNodes(w http.ResponseWriter, r *http.Request) { +func (h *Handler) GetEmbeddedClusterNodes(w http.ResponseWriter, r *http.Request) { client, err := k8sutil.GetClientset() if err != nil { logger.Error(err) @@ -17,7 +17,7 @@ func (h *Handler) GetHelmVMNodes(w http.ResponseWriter, r *http.Request) { return } - nodes, err := helmvm.GetNodes(r.Context(), client) + nodes, err := embeddedcluster.GetNodes(r.Context(), client) if err != nil { logger.Error(err) w.WriteHeader(http.StatusInternalServerError) @@ -26,7 +26,7 @@ func (h *Handler) GetHelmVMNodes(w http.ResponseWriter, r *http.Request) { JSON(w, http.StatusOK, nodes) } -func (h *Handler) GetHelmVMNode(w http.ResponseWriter, r *http.Request) { +func (h *Handler) GetEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) { client, err := k8sutil.GetClientset() if err != nil { logger.Error(err) @@ -35,7 +35,7 @@ func (h *Handler) GetHelmVMNode(w http.ResponseWriter, r *http.Request) { } nodeName := mux.Vars(r)["nodeName"] - node, err := helmvm.GetNode(r.Context(), client, nodeName) + node, err := embeddedcluster.GetNode(r.Context(), client, nodeName) if err != nil { logger.Error(err) w.WriteHeader(http.StatusInternalServerError) diff --git a/pkg/handlers/helmvm_node_join_command.go b/pkg/handlers/embedded_cluster_node_join_command.go similarity index 64% rename from pkg/handlers/helmvm_node_join_command.go rename to pkg/handlers/embedded_cluster_node_join_command.go index b4d6a0da4f..ca1dbed32a 100644 --- a/pkg/handlers/helmvm_node_join_command.go +++ b/pkg/handlers/embedded_cluster_node_join_command.go @@ -5,36 +5,36 @@ import ( "fmt" "net/http" - "github.com/replicatedhq/kots/pkg/helmvm" + "github.com/replicatedhq/kots/pkg/embeddedcluster" "github.com/replicatedhq/kots/pkg/k8sutil" "github.com/replicatedhq/kots/pkg/logger" "github.com/replicatedhq/kots/pkg/store/kotsstore" ) -type GenerateK0sNodeJoinCommandResponse struct { +type GenerateEmbeddedClusterNodeJoinCommandResponse struct { Command []string `json:"command"` } -type GetK0sNodeJoinCommandResponse struct { +type GetEmbeddedClusterNodeJoinCommandResponse struct { ClusterID string `json:"clusterID"` K0sJoinCommand string `json:"k0sJoinCommand"` K0sToken string `json:"k0sToken"` } -type GenerateHelmVMNodeJoinCommandRequest struct { +type GenerateEmbeddedClusterNodeJoinCommandRequest struct { Roles []string `json:"roles"` } -func (h *Handler) GenerateK0sNodeJoinCommand(w http.ResponseWriter, r *http.Request) { - generateHelmVMNodeJoinCommandRequest := GenerateHelmVMNodeJoinCommandRequest{} - if err := json.NewDecoder(r.Body).Decode(&generateHelmVMNodeJoinCommandRequest); err != nil { +func (h *Handler) GenerateEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *http.Request) { + generateEmbeddedClusterNodeJoinCommandRequest := GenerateEmbeddedClusterNodeJoinCommandRequest{} + if err := json.NewDecoder(r.Body).Decode(&generateEmbeddedClusterNodeJoinCommandRequest); err != nil { logger.Error(fmt.Errorf("failed to decode request body: %w", err)) w.WriteHeader(http.StatusBadRequest) return } store := kotsstore.StoreFromEnv() - token, err := store.SetK0sInstallCommandRoles(generateHelmVMNodeJoinCommandRequest.Roles) + token, err := store.SetEmbeddedClusterInstallCommandRoles(generateEmbeddedClusterNodeJoinCommandRequest.Roles) if err != nil { logger.Error(fmt.Errorf("failed to set k0s install command roles: %w", err)) w.WriteHeader(http.StatusInternalServerError) @@ -47,24 +47,24 @@ func (h *Handler) GenerateK0sNodeJoinCommand(w http.ResponseWriter, r *http.Requ w.WriteHeader(http.StatusInternalServerError) return } - nodeJoinCommand, err := helmvm.GenerateAddNodeCommand(r.Context(), client, token) + nodeJoinCommand, err := embeddedcluster.GenerateAddNodeCommand(r.Context(), client, token) if err != nil { logger.Error(fmt.Errorf("failed to generate add node command: %w", err)) w.WriteHeader(http.StatusInternalServerError) return } - JSON(w, http.StatusOK, GenerateK0sNodeJoinCommandResponse{ + JSON(w, http.StatusOK, GenerateEmbeddedClusterNodeJoinCommandResponse{ Command: []string{nodeJoinCommand}, }) } // this function relies on the token being valid for authentication -func (h *Handler) GetK0sNodeJoinCommand(w http.ResponseWriter, r *http.Request) { +func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *http.Request) { // read query string, ensure that the token is valid token := r.URL.Query().Get("token") store := kotsstore.StoreFromEnv() - roles, err := store.GetK0sInstallCommandRoles(token) + roles, err := store.GetEmbeddedClusterInstallCommandRoles(token) if err != nil { logger.Error(fmt.Errorf("failed to get k0s install command roles: %w", err)) w.WriteHeader(http.StatusInternalServerError) @@ -87,28 +87,28 @@ func (h *Handler) GetK0sNodeJoinCommand(w http.ResponseWriter, r *http.Request) } } - k0sToken, err := helmvm.GenerateAddNodeToken(r.Context(), client, k0sRole) + k0sToken, err := embeddedcluster.GenerateAddNodeToken(r.Context(), client, k0sRole) if err != nil { logger.Error(fmt.Errorf("failed to generate add node token: %w", err)) w.WriteHeader(http.StatusInternalServerError) return } - k0sJoinCommand, err := helmvm.GenerateK0sJoinCommand(r.Context(), client, roles) + k0sJoinCommand, err := embeddedcluster.GenerateK0sJoinCommand(r.Context(), client, roles) if err != nil { logger.Error(fmt.Errorf("failed to generate k0s join command: %w", err)) w.WriteHeader(http.StatusInternalServerError) return } - clusterID, err := helmvm.ClusterID(client) + clusterID, err := embeddedcluster.ClusterID(client) if err != nil { logger.Error(fmt.Errorf("failed to get cluster id: %w", err)) w.WriteHeader(http.StatusInternalServerError) return } - JSON(w, http.StatusOK, GetK0sNodeJoinCommandResponse{ + JSON(w, http.StatusOK, GetEmbeddedClusterNodeJoinCommandResponse{ ClusterID: clusterID, K0sJoinCommand: k0sJoinCommand, K0sToken: k0sToken, diff --git a/pkg/handlers/handlers.go b/pkg/handlers/handlers.go index 2ebf1fea32..f8853fc4b1 100644 --- a/pkg/handlers/handlers.go +++ b/pkg/handlers/handlers.go @@ -275,18 +275,18 @@ func RegisterSessionAuthRoutes(r *mux.Router, kotsStore store.Store, handler KOT r.Name("GetKurlNodes").Path("/api/v1/kurl/nodes").Methods("GET"). HandlerFunc(middleware.EnforceAccess(policy.ClusterRead, handler.GetKurlNodes)) - // HelmVM - r.Name("HelmVM").Path("/api/v1/helmvm").HandlerFunc(NotImplemented) - r.Name("GenerateK0sNodeJoinCommand").Path("/api/v1/helmvm/generate-node-join-command").Methods("POST"). - HandlerFunc(middleware.EnforceAccess(policy.ClusterWrite, handler.GenerateK0sNodeJoinCommand)) - r.Name("DrainHelmVMNode").Path("/api/v1/helmvm/nodes/{nodeName}/drain").Methods("POST"). - HandlerFunc(middleware.EnforceAccess(policy.ClusterWrite, handler.DrainHelmVMNode)) - r.Name("DeleteHelmVMNode").Path("/api/v1/helmvm/nodes/{nodeName}").Methods("DELETE"). - HandlerFunc(middleware.EnforceAccess(policy.ClusterWrite, handler.DeleteHelmVMNode)) - r.Name("GetHelmVMNodes").Path("/api/v1/helmvm/nodes").Methods("GET"). - HandlerFunc(middleware.EnforceAccess(policy.ClusterRead, handler.GetHelmVMNodes)) - r.Name("GetHelmVMNode").Path("/api/v1/helmvm/node/{nodeName}").Methods("GET"). - HandlerFunc(middleware.EnforceAccess(policy.ClusterRead, handler.GetHelmVMNode)) + // Embedded Cluster + r.Name("EmbeddedCluster").Path("/api/v1/embedded-cluster").HandlerFunc(NotImplemented) + r.Name("GenerateEmbeddedClusterNodeJoinCommand").Path("/api/v1/embedded-cluster/generate-node-join-command").Methods("POST"). + HandlerFunc(middleware.EnforceAccess(policy.ClusterWrite, handler.GenerateEmbeddedClusterNodeJoinCommand)) + r.Name("DrainEmbeddedClusterNode").Path("/api/v1/embedded-cluster/nodes/{nodeName}/drain").Methods("POST"). + HandlerFunc(middleware.EnforceAccess(policy.ClusterWrite, handler.DrainEmbeddedClusterNode)) + r.Name("DeleteEmbeddedClusterNode").Path("/api/v1/embedded-cluster/nodes/{nodeName}").Methods("DELETE"). + HandlerFunc(middleware.EnforceAccess(policy.ClusterWrite, handler.DeleteEmbeddedClusterNode)) + r.Name("GetEmbeddedClusterNodes").Path("/api/v1/embedded-cluster/nodes").Methods("GET"). + HandlerFunc(middleware.EnforceAccess(policy.ClusterRead, handler.GetEmbeddedClusterNodes)) + r.Name("GetEmbeddedClusterNode").Path("/api/v1/embedded-cluster/node/{nodeName}").Methods("GET"). + HandlerFunc(middleware.EnforceAccess(policy.ClusterRead, handler.GetEmbeddedClusterNode)) // Prometheus r.Name("SetPrometheusAddress").Path("/api/v1/prometheus").Methods("POST"). @@ -357,7 +357,7 @@ func RegisterUnauthenticatedRoutes(handler *Handler, kotsStore store.Store, debu loggingRouter.Path("/api/v1/app/custom-metrics").Methods("POST").HandlerFunc(handler.GetSendCustomAppMetricsHandler(kotsStore)) // This handler requires a valid token in the query - loggingRouter.Path("/api/v1/embedded-cluster/join").Methods("GET").HandlerFunc(handler.GetK0sNodeJoinCommand) + loggingRouter.Path("/api/v1/embedded-cluster/join").Methods("GET").HandlerFunc(handler.GetEmbeddedClusterNodeJoinCommand) } func StreamJSON(c *websocket.Conn, payload interface{}) { diff --git a/pkg/handlers/handlers_test.go b/pkg/handlers/handlers_test.go index 9d4ee77a74..c502bb6733 100644 --- a/pkg/handlers/handlers_test.go +++ b/pkg/handlers/handlers_test.go @@ -1209,66 +1209,56 @@ var HandlerPolicyTests = map[string][]HandlerPolicyTest{ }, }, - "HelmVM": {}, // Not implemented - "GenerateK0sNodeJoinCommand": { + "EmbeddedCluster": {}, // Not implemented + "GenerateEmbeddedClusterNodeJoinCommand": { { Roles: []rbactypes.Role{rbac.ClusterAdminRole}, SessionRoles: []string{rbac.ClusterAdminRoleID}, Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) { - handlerRecorder.GenerateK0sNodeJoinCommand(gomock.Any(), gomock.Any()) + handlerRecorder.GenerateEmbeddedClusterNodeJoinCommand(gomock.Any(), gomock.Any()) }, ExpectStatus: http.StatusOK, }, }, - "DrainHelmVMNode": { + "DrainEmbeddedClusterNode": { { Vars: map[string]string{"nodeName": "node-name"}, Roles: []rbactypes.Role{rbac.ClusterAdminRole}, SessionRoles: []string{rbac.ClusterAdminRoleID}, Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) { - handlerRecorder.DrainHelmVMNode(gomock.Any(), gomock.Any()) + handlerRecorder.DrainEmbeddedClusterNode(gomock.Any(), gomock.Any()) }, ExpectStatus: http.StatusOK, }, }, - "DeleteHelmVMNode": { + "DeleteEmbeddedClusterNode": { { Vars: map[string]string{"nodeName": "node-name"}, Roles: []rbactypes.Role{rbac.ClusterAdminRole}, SessionRoles: []string{rbac.ClusterAdminRoleID}, Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) { - handlerRecorder.DeleteHelmVMNode(gomock.Any(), gomock.Any()) + handlerRecorder.DeleteEmbeddedClusterNode(gomock.Any(), gomock.Any()) }, ExpectStatus: http.StatusOK, }, }, - "GetHelmVMNodes": { + "GetEmbeddedClusterNodes": { { Roles: []rbactypes.Role{rbac.ClusterAdminRole}, SessionRoles: []string{rbac.ClusterAdminRoleID}, Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) { - handlerRecorder.GetHelmVMNodes(gomock.Any(), gomock.Any()) + handlerRecorder.GetEmbeddedClusterNodes(gomock.Any(), gomock.Any()) }, ExpectStatus: http.StatusOK, }, }, - "GetHelmVMNode": { + "GetEmbeddedClusterNode": { { Vars: map[string]string{"nodeName": "node-name"}, Roles: []rbactypes.Role{rbac.ClusterAdminRole}, SessionRoles: []string{rbac.ClusterAdminRoleID}, Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) { - handlerRecorder.GetHelmVMNode(gomock.Any(), gomock.Any()) - }, - ExpectStatus: http.StatusOK, - }, - }, - "GetK0sNodeJoinCommand": { - { - Roles: []rbactypes.Role{rbac.ClusterAdminRole}, - SessionRoles: []string{rbac.ClusterAdminRoleID}, - Calls: func(storeRecorder *mock_store.MockStoreMockRecorder, handlerRecorder *mock_handlers.MockKOTSHandlerMockRecorder) { - handlerRecorder.GetK0sNodeJoinCommand(gomock.Any(), gomock.Any()) + handlerRecorder.GetEmbeddedClusterNode(gomock.Any(), gomock.Any()) }, ExpectStatus: http.StatusOK, }, diff --git a/pkg/handlers/interface.go b/pkg/handlers/interface.go index 67dd05d3bc..a8fe1bd4dc 100644 --- a/pkg/handlers/interface.go +++ b/pkg/handlers/interface.go @@ -138,13 +138,12 @@ type KOTSHandler interface { DeleteKurlNode(w http.ResponseWriter, r *http.Request) GetKurlNodes(w http.ResponseWriter, r *http.Request) - // HelmVM - GenerateK0sNodeJoinCommand(w http.ResponseWriter, r *http.Request) - DrainHelmVMNode(w http.ResponseWriter, r *http.Request) - DeleteHelmVMNode(w http.ResponseWriter, r *http.Request) - GetHelmVMNodes(w http.ResponseWriter, r *http.Request) - GetHelmVMNode(w http.ResponseWriter, r *http.Request) - GetK0sNodeJoinCommand(w http.ResponseWriter, r *http.Request) + // EmbeddedCLuster + GenerateEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *http.Request) + DrainEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) + DeleteEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) + GetEmbeddedClusterNodes(w http.ResponseWriter, r *http.Request) + GetEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) // Prometheus SetPrometheusAddress(w http.ResponseWriter, r *http.Request) diff --git a/pkg/handlers/metadata.go b/pkg/handlers/metadata.go index 81903b26dd..cc7253551e 100644 --- a/pkg/handlers/metadata.go +++ b/pkg/handlers/metadata.go @@ -50,9 +50,9 @@ type MetadataResponseBranding struct { } type AdminConsoleMetadata struct { - IsAirgap bool `json:"isAirgap"` - IsKurl bool `json:"isKurl"` - IsHelmVM bool `json:"isHelmVM"` + IsAirgap bool `json:"isAirgap"` + IsKurl bool `json:"isKurl"` + IsEmbeddedCluster bool `json:"isEmbeddedCluster"` } // GetMetadataHandler helper function that returns a http handler func that returns metadata. It takes a function that @@ -73,7 +73,7 @@ func GetMetadataHandler(getK8sInfoFn MetadataK8sFn, kotsStore store.Store) http. if kuberneteserrors.IsNotFound(err) { metadataResponse.AdminConsoleMetadata.IsAirgap = kotsadmMetadata.IsAirgap metadataResponse.AdminConsoleMetadata.IsKurl = kotsadmMetadata.IsKurl - metadataResponse.AdminConsoleMetadata.IsHelmVM = kotsadmMetadata.IsHelmVM + metadataResponse.AdminConsoleMetadata.IsEmbeddedCluster = kotsadmMetadata.IsEmbeddedCluster logger.Info(fmt.Sprintf("config map %q not found", metadataConfigMapName)) JSON(w, http.StatusOK, &metadataResponse) @@ -114,9 +114,9 @@ func GetMetadataHandler(getK8sInfoFn MetadataK8sFn, kotsStore store.Store) http. metadataResponse.UpstreamURI = brandingConfigMap.Data[upstreamUriKey] metadataResponse.ConsoleFeatureFlags = application.Spec.ConsoleFeatureFlags metadataResponse.AdminConsoleMetadata = AdminConsoleMetadata{ - IsAirgap: kotsadmMetadata.IsAirgap, - IsKurl: kotsadmMetadata.IsKurl, - IsHelmVM: kotsadmMetadata.IsHelmVM, + IsAirgap: kotsadmMetadata.IsAirgap, + IsKurl: kotsadmMetadata.IsKurl, + IsEmbeddedCluster: kotsadmMetadata.IsEmbeddedCluster, } JSON(w, http.StatusOK, metadataResponse) diff --git a/pkg/handlers/mock/mock.go b/pkg/handlers/mock/mock.go index 736883ad70..c122017330 100644 --- a/pkg/handlers/mock/mock.go +++ b/pkg/handlers/mock/mock.go @@ -262,16 +262,16 @@ func (mr *MockKOTSHandlerMockRecorder) DeleteBackup(w, r interface{}) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBackup", reflect.TypeOf((*MockKOTSHandler)(nil).DeleteBackup), w, r) } -// DeleteHelmVMNode mocks base method. -func (m *MockKOTSHandler) DeleteHelmVMNode(w http.ResponseWriter, r *http.Request) { +// DeleteEmbeddedClusterNode mocks base method. +func (m *MockKOTSHandler) DeleteEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) { m.ctrl.T.Helper() - m.ctrl.Call(m, "DeleteHelmVMNode", w, r) + m.ctrl.Call(m, "DeleteEmbeddedClusterNode", w, r) } -// DeleteHelmVMNode indicates an expected call of DeleteHelmVMNode. -func (mr *MockKOTSHandlerMockRecorder) DeleteHelmVMNode(w, r interface{}) *gomock.Call { +// DeleteEmbeddedClusterNode indicates an expected call of DeleteEmbeddedClusterNode. +func (mr *MockKOTSHandlerMockRecorder) DeleteEmbeddedClusterNode(w, r interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteHelmVMNode", reflect.TypeOf((*MockKOTSHandler)(nil).DeleteHelmVMNode), w, r) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteEmbeddedClusterNode", reflect.TypeOf((*MockKOTSHandler)(nil).DeleteEmbeddedClusterNode), w, r) } // DeleteKurlNode mocks base method. @@ -394,16 +394,16 @@ func (mr *MockKOTSHandlerMockRecorder) DownloadSupportBundle(w, r interface{}) * return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DownloadSupportBundle", reflect.TypeOf((*MockKOTSHandler)(nil).DownloadSupportBundle), w, r) } -// DrainHelmVMNode mocks base method. -func (m *MockKOTSHandler) DrainHelmVMNode(w http.ResponseWriter, r *http.Request) { +// DrainEmbeddedClusterNode mocks base method. +func (m *MockKOTSHandler) DrainEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) { m.ctrl.T.Helper() - m.ctrl.Call(m, "DrainHelmVMNode", w, r) + m.ctrl.Call(m, "DrainEmbeddedClusterNode", w, r) } -// DrainHelmVMNode indicates an expected call of DrainHelmVMNode. -func (mr *MockKOTSHandlerMockRecorder) DrainHelmVMNode(w, r interface{}) *gomock.Call { +// DrainEmbeddedClusterNode indicates an expected call of DrainEmbeddedClusterNode. +func (mr *MockKOTSHandlerMockRecorder) DrainEmbeddedClusterNode(w, r interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DrainHelmVMNode", reflect.TypeOf((*MockKOTSHandler)(nil).DrainHelmVMNode), w, r) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DrainEmbeddedClusterNode", reflect.TypeOf((*MockKOTSHandler)(nil).DrainEmbeddedClusterNode), w, r) } // DrainKurlNode mocks base method. @@ -442,16 +442,16 @@ func (mr *MockKOTSHandlerMockRecorder) GarbageCollectImages(w, r interface{}) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GarbageCollectImages", reflect.TypeOf((*MockKOTSHandler)(nil).GarbageCollectImages), w, r) } -// GenerateK0sNodeJoinCommand mocks base method. -func (m *MockKOTSHandler) GenerateK0sNodeJoinCommand(w http.ResponseWriter, r *http.Request) { +// GenerateEmbeddedClusterNodeJoinCommand mocks base method. +func (m *MockKOTSHandler) GenerateEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *http.Request) { m.ctrl.T.Helper() - m.ctrl.Call(m, "GenerateK0sNodeJoinCommand", w, r) + m.ctrl.Call(m, "GenerateEmbeddedClusterNodeJoinCommand", w, r) } -// GenerateK0sNodeJoinCommand indicates an expected call of GenerateK0sNodeJoinCommand. -func (mr *MockKOTSHandlerMockRecorder) GenerateK0sNodeJoinCommand(w, r interface{}) *gomock.Call { +// GenerateEmbeddedClusterNodeJoinCommand indicates an expected call of GenerateEmbeddedClusterNodeJoinCommand. +func (mr *MockKOTSHandlerMockRecorder) GenerateEmbeddedClusterNodeJoinCommand(w, r interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenerateK0sNodeJoinCommand", reflect.TypeOf((*MockKOTSHandler)(nil).GenerateK0sNodeJoinCommand), w, r) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenerateEmbeddedClusterNodeJoinCommand", reflect.TypeOf((*MockKOTSHandler)(nil).GenerateEmbeddedClusterNodeJoinCommand), w, r) } // GenerateKurlNodeJoinCommandMaster mocks base method. @@ -706,6 +706,30 @@ func (mr *MockKOTSHandlerMockRecorder) GetDownstreamOutput(w, r interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDownstreamOutput", reflect.TypeOf((*MockKOTSHandler)(nil).GetDownstreamOutput), w, r) } +// GetEmbeddedClusterNode mocks base method. +func (m *MockKOTSHandler) GetEmbeddedClusterNode(w http.ResponseWriter, r *http.Request) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "GetEmbeddedClusterNode", w, r) +} + +// GetEmbeddedClusterNode indicates an expected call of GetEmbeddedClusterNode. +func (mr *MockKOTSHandlerMockRecorder) GetEmbeddedClusterNode(w, r interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEmbeddedClusterNode", reflect.TypeOf((*MockKOTSHandler)(nil).GetEmbeddedClusterNode), w, r) +} + +// GetEmbeddedClusterNodes mocks base method. +func (m *MockKOTSHandler) GetEmbeddedClusterNodes(w http.ResponseWriter, r *http.Request) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "GetEmbeddedClusterNodes", w, r) +} + +// GetEmbeddedClusterNodes indicates an expected call of GetEmbeddedClusterNodes. +func (mr *MockKOTSHandlerMockRecorder) GetEmbeddedClusterNodes(w, r interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEmbeddedClusterNodes", reflect.TypeOf((*MockKOTSHandler)(nil).GetEmbeddedClusterNodes), w, r) +} + // GetFileSystemSnapshotProviderInstructions mocks base method. func (m *MockKOTSHandler) GetFileSystemSnapshotProviderInstructions(w http.ResponseWriter, r *http.Request) { m.ctrl.T.Helper() @@ -742,30 +766,6 @@ func (mr *MockKOTSHandlerMockRecorder) GetGlobalSnapshotSettings(w, r interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGlobalSnapshotSettings", reflect.TypeOf((*MockKOTSHandler)(nil).GetGlobalSnapshotSettings), w, r) } -// GetHelmVMNode mocks base method. -func (m *MockKOTSHandler) GetHelmVMNode(w http.ResponseWriter, r *http.Request) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "GetHelmVMNode", w, r) -} - -// GetHelmVMNode indicates an expected call of GetHelmVMNode. -func (mr *MockKOTSHandlerMockRecorder) GetHelmVMNode(w, r interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHelmVMNode", reflect.TypeOf((*MockKOTSHandler)(nil).GetHelmVMNode), w, r) -} - -// GetHelmVMNodes mocks base method. -func (m *MockKOTSHandler) GetHelmVMNodes(w http.ResponseWriter, r *http.Request) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "GetHelmVMNodes", w, r) -} - -// GetHelmVMNodes indicates an expected call of GetHelmVMNodes. -func (mr *MockKOTSHandlerMockRecorder) GetHelmVMNodes(w, r interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHelmVMNodes", reflect.TypeOf((*MockKOTSHandler)(nil).GetHelmVMNodes), w, r) -} - // GetIdentityServiceConfig mocks base method. func (m *MockKOTSHandler) GetIdentityServiceConfig(w http.ResponseWriter, r *http.Request) { m.ctrl.T.Helper() @@ -802,18 +802,6 @@ func (mr *MockKOTSHandlerMockRecorder) GetInstanceSnapshotConfig(w, r interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInstanceSnapshotConfig", reflect.TypeOf((*MockKOTSHandler)(nil).GetInstanceSnapshotConfig), w, r) } -// GetK0sNodeJoinCommand mocks base method. -func (m *MockKOTSHandler) GetK0sNodeJoinCommand(w http.ResponseWriter, r *http.Request) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "GetK0sNodeJoinCommand", w, r) -} - -// GetK0sNodeJoinCommand indicates an expected call of GetK0sNodeJoinCommand. -func (mr *MockKOTSHandlerMockRecorder) GetK0sNodeJoinCommand(w, r interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetK0sNodeJoinCommand", reflect.TypeOf((*MockKOTSHandler)(nil).GetK0sNodeJoinCommand), w, r) -} - // GetKotsadmRegistry mocks base method. func (m *MockKOTSHandler) GetKotsadmRegistry(w http.ResponseWriter, r *http.Request) { m.ctrl.T.Helper() diff --git a/pkg/kotsadm/metadata.go b/pkg/kotsadm/metadata.go index 9c9b045cb0..9c2c09b90a 100644 --- a/pkg/kotsadm/metadata.go +++ b/pkg/kotsadm/metadata.go @@ -1,7 +1,7 @@ package kotsadm import ( - "github.com/replicatedhq/kots/pkg/helmvm" + "github.com/replicatedhq/kots/pkg/embeddedcluster" "github.com/replicatedhq/kots/pkg/kotsadm/types" "github.com/replicatedhq/kots/pkg/kurl" "k8s.io/client-go/kubernetes" @@ -9,12 +9,12 @@ import ( func GetMetadata(clientset kubernetes.Interface) types.Metadata { isKurl, _ := kurl.IsKurl(clientset) - isHelmVM, _ := helmvm.IsHelmVM(clientset) + isEmbeddedCluster, _ := embeddedcluster.IsEmbeddedCluster(clientset) metadata := types.Metadata{ - IsAirgap: IsAirgap(), - IsKurl: isKurl, - IsHelmVM: isHelmVM, + IsAirgap: IsAirgap(), + IsKurl: isKurl, + IsEmbeddedCluster: isEmbeddedCluster, } return metadata diff --git a/pkg/kotsadm/types/metadata.go b/pkg/kotsadm/types/metadata.go index 79e8b142a6..8ff2225f42 100644 --- a/pkg/kotsadm/types/metadata.go +++ b/pkg/kotsadm/types/metadata.go @@ -1,7 +1,7 @@ package types type Metadata struct { - IsAirgap bool - IsKurl bool - IsHelmVM bool + IsAirgap bool + IsKurl bool + IsEmbeddedCluster bool } diff --git a/pkg/store/kotsstore/k0s_store.go b/pkg/store/kotsstore/embedded_cluster_store.go similarity index 71% rename from pkg/store/kotsstore/k0s_store.go rename to pkg/store/kotsstore/embedded_cluster_store.go index 4eb7a9bd7b..39cc5cda5b 100644 --- a/pkg/store/kotsstore/k0s_store.go +++ b/pkg/store/kotsstore/embedded_cluster_store.go @@ -9,18 +9,18 @@ import ( "github.com/replicatedhq/kots/pkg/rand" ) -func (s *KOTSStore) SetK0sInstallCommandRoles(roles []string) (string, error) { +func (s *KOTSStore) SetEmbeddedClusterInstallCommandRoles(roles []string) (string, error) { db := persistence.MustGetDBSession() installID := rand.StringWithCharset(24, rand.LOWER_CASE+rand.UPPER_CASE) - query := `delete from k0s_tokens where token = ?` + query := `delete from embedded_cluster_tokens where token = ?` wr, err := db.WriteOneParameterized(gorqlite.ParameterizedStatement{ Query: query, Arguments: []interface{}{installID}, }) if err != nil { - return "", fmt.Errorf("delete k0s join token: %v: %v", err, wr.Err) + return "", fmt.Errorf("delete embedded_cluster join token: %v: %v", err, wr.Err) } jsonRoles, err := json.Marshal(roles) @@ -28,21 +28,21 @@ func (s *KOTSStore) SetK0sInstallCommandRoles(roles []string) (string, error) { return "", fmt.Errorf("failed to marshal roles: %w", err) } - query = `insert into k0s_tokens (token, roles) values (?, ?)` + query = `insert into embedded_cluster_tokens (token, roles) values (?, ?)` wr, err = db.WriteOneParameterized(gorqlite.ParameterizedStatement{ Query: query, Arguments: []interface{}{installID, string(jsonRoles)}, }) if err != nil { - return "", fmt.Errorf("insert k0s join token: %v: %v", err, wr.Err) + return "", fmt.Errorf("insert embedded_cluster join token: %v: %v", err, wr.Err) } return installID, nil } -func (s *KOTSStore) GetK0sInstallCommandRoles(token string) ([]string, error) { +func (s *KOTSStore) GetEmbeddedClusterInstallCommandRoles(token string) ([]string, error) { db := persistence.MustGetDBSession() - query := `select roles from k0s_tokens where token = ?` + query := `select roles from embedded_cluster_tokens where token = ?` rows, err := db.QueryOneParameterized(gorqlite.ParameterizedStatement{ Query: query, Arguments: []interface{}{token}, diff --git a/web/src/Root.tsx b/web/src/Root.tsx index a78e3b46bc..61fb86c592 100644 --- a/web/src/Root.tsx +++ b/web/src/Root.tsx @@ -1,6 +1,6 @@ -import React, { useReducer, useEffect } from "react"; +import React, { useEffect, useReducer } from "react"; import { createBrowserHistory } from "history"; -import { Route, Routes, Navigate, useNavigate } from "react-router-dom"; +import { Navigate, Route, Routes, useNavigate } from "react-router-dom"; import { Helmet } from "react-helmet"; import Modal from "react-modal"; import find from "lodash/find"; @@ -10,10 +10,10 @@ import PreflightResultPage from "./components/PreflightResultPage"; import AppConfig from "./features/AppConfig/components/AppConfig"; import { AppDetailPage } from "./components/apps/AppDetailPage"; import KurlClusterManagement from "./components/apps/KurlClusterManagement"; -import HelmVMClusterManagement from "./components/apps/HelmVMClusterManagement"; +import EmbeddedClusterManagement from "@components/apps/EmbeddedClusterManagement"; import UnsupportedBrowser from "./components/static/UnsupportedBrowser"; import NotFound from "./components/static/NotFound"; -import { Utilities, parseUpstreamUri } from "./utilities/utilities"; +import { parseUpstreamUri, Utilities } from "./utilities/utilities"; import fetch from "./utilities/fetchWithTimeout"; import { SecureAdminConsole } from "@features/Auth"; import UploadLicenseFile from "./components/UploadLicenseFile"; @@ -58,7 +58,7 @@ import SnapshotDetails from "@components/snapshots/SnapshotDetails"; import SnapshotRestore from "@components/snapshots/SnapshotRestore"; import AppSnapshots from "@components/snapshots/AppSnapshots"; import AppSnapshotRestore from "@components/snapshots/AppSnapshotRestore"; -import HelmVMViewNode from "@components/apps/HelmVMViewNode"; +import EmbeddedClusterViewNode from "@components/apps/EmbeddedClusterViewNode"; // react-query client const queryClient = new QueryClient(); @@ -467,7 +467,9 @@ const Root = () => { refetchAppsList={getAppsList} fetchingMetadata={state.fetchingMetadata} isKurlEnabled={Boolean(state.adminConsoleMetadata?.isKurl)} - isHelmVMEnabled={Boolean(state.adminConsoleMetadata?.isHelmVM)} + isEmbeddedClusterEnabled={Boolean( + state.adminConsoleMetadata?.isEmbeddedCluster + )} isGitOpsSupported={isGitOpsSupported()} isIdentityServiceSupported={isIdentityServiceSupported()} appsList={state.appsList} @@ -532,7 +534,9 @@ const Root = () => { appSlugFromMetadata={state.appSlugFromMetadata || ""} fetchingMetadata={state.fetchingMetadata} onUploadSuccess={getAppsList} - isHelmVM={Boolean(state.adminConsoleMetadata?.isHelmVM)} + isEmbeddedCluster={Boolean( + state.adminConsoleMetadata?.isEmbeddedCluster + )} /> } /> @@ -575,33 +579,38 @@ const Root = () => { } /> } /> - {state.adminConsoleMetadata?.isHelmVM && ( + {state.adminConsoleMetadata?.isEmbeddedCluster && ( <> } + element={ + + } /> } + element={} /> )} {(state.adminConsoleMetadata?.isKurl || - state.adminConsoleMetadata?.isHelmVM) && ( + state.adminConsoleMetadata?.isEmbeddedCluster) && ( ) : ( - + ) } /> )} - {state.adminConsoleMetadata?.isHelmVM && ( - } /> + {state.adminConsoleMetadata?.isEmbeddedCluster && ( + } + /> )} { snapshotInProgressApps={state.snapshotInProgressApps} ping={ping} isHelmManaged={state.isHelmManaged} - isHelmVM={Boolean(state.adminConsoleMetadata?.isHelmVM)} + isEmbeddedCluster={Boolean( + state.adminConsoleMetadata?.isEmbeddedCluster + )} /> } /> @@ -708,7 +719,9 @@ const Root = () => { snapshotInProgressApps={state.snapshotInProgressApps} ping={ping} isHelmManaged={state.isHelmManaged} - isHelmVM={Boolean(state.adminConsoleMetadata?.isHelmVM)} + isEmbeddedCluster={Boolean( + state.adminConsoleMetadata?.isEmbeddedCluster + )} /> } > diff --git a/web/src/components/UploadLicenseFile.tsx b/web/src/components/UploadLicenseFile.tsx index e08cf5b829..9af2e5e3c4 100644 --- a/web/src/components/UploadLicenseFile.tsx +++ b/web/src/components/UploadLicenseFile.tsx @@ -67,7 +67,7 @@ type Props = { onUploadSuccess: () => Promise; logo: string | null; snapshot?: { name: string }; - isHelmVM: boolean; + isEmbeddedCluster: boolean; }; const UploadLicenseFile = (props: Props) => { @@ -261,7 +261,7 @@ const UploadLicenseFile = (props: Props) => { return; } - if (props.isHelmVM) { + if (props.isEmbeddedCluster) { navigate(`/${data.slug}/cluster/manage`, { replace: true }); return; } diff --git a/web/src/components/apps/AppDetailPage.tsx b/web/src/components/apps/AppDetailPage.tsx index 46fbe7a2e2..aa0b2d0ef1 100644 --- a/web/src/components/apps/AppDetailPage.tsx +++ b/web/src/components/apps/AppDetailPage.tsx @@ -1,10 +1,12 @@ -import React, { Fragment, useReducer, useEffect, useState } from "react"; +import React, { Fragment, useEffect, useReducer, useState } from "react"; import classNames from "classnames"; -import { useNavigate, useParams, Outlet } from "react-router-dom"; +import { Outlet, useNavigate, useParams } from "react-router-dom"; import Modal from "react-modal"; import { useTheme } from "@src/components/context/withTheme"; -import { KotsSidebarItem } from "@src/components/watches/WatchSidebarItem"; -import { HelmChartSidebarItem } from "@src/components/watches/WatchSidebarItem"; +import { + HelmChartSidebarItem, + KotsSidebarItem, +} from "@src/components/watches/WatchSidebarItem"; import { isAwaitingResults } from "../../utilities/utilities"; import SubNavBar from "@src/components/shared/SubNavBar"; @@ -15,7 +17,7 @@ import Loader from "../shared/Loader"; import ErrorModal from "../modals/ErrorModal"; // Types -import { App, Metadata, KotsParams, Version } from "@types"; +import { App, KotsParams, Metadata, Version } from "@types"; import { useApps, useSelectedApp } from "@features/App"; type Props = { @@ -30,7 +32,7 @@ type Props = { refetchAppsList: () => void; refetchAppMetadata: () => void; snapshotInProgressApps: string[]; - isHelmVM: boolean; + isEmbeddedCluster: boolean; }; type State = { @@ -322,12 +324,12 @@ function AppDetailPage(props: Props) { const firstVersion = downstream.pendingVersions.find( (version: Version) => version?.sequence === 0 ); - if (firstVersion?.status === "unknown" && props.isHelmVM) { + if (firstVersion?.status === "unknown" && props.isEmbeddedCluster) { navigate(`/${appNeedsConfiguration.slug}/cluster/manage`); return; } if (firstVersion?.status === "pending_config") { - if (props.isHelmVM) { + if (props.isEmbeddedCluster) { navigate(`/${appNeedsConfiguration.slug}/cluster/manage`); return; } diff --git a/web/src/components/apps/AppVersionHistory.tsx b/web/src/components/apps/AppVersionHistory.tsx index f39ff953ef..a0a9277c3d 100644 --- a/web/src/components/apps/AppVersionHistory.tsx +++ b/web/src/components/apps/AppVersionHistory.tsx @@ -19,12 +19,12 @@ import DeployWarningModal from "../shared/modals/DeployWarningModal"; import AutomaticUpdatesModal from "@src/components/modals/AutomaticUpdatesModal"; import SkipPreflightsModal from "../shared/modals/SkipPreflightsModal"; import { - Utilities, + getCommitHashFromUrl, + getGitProviderDiffUrl, + getPreflightResultState, isAwaitingResults, secondsAgo, - getPreflightResultState, - getGitProviderDiffUrl, - getCommitHashFromUrl, + Utilities, } from "../../utilities/utilities"; import { Repeater } from "../../utilities/repeater"; import { AirgapUploader } from "../../utilities/airgapUploader"; @@ -59,7 +59,7 @@ type Props = { adminConsoleMetadata: { isAirgap: boolean; isKurl: boolean; - isHelmVM: boolean; + isEmbeddedCluster: boolean; }; app: App; displayErrorModal: boolean; diff --git a/web/src/components/apps/HelmVMClusterManagement.tsx b/web/src/components/apps/EmbeddedClusterManagement.tsx similarity index 94% rename from web/src/components/apps/HelmVMClusterManagement.tsx rename to web/src/components/apps/EmbeddedClusterManagement.tsx index f7ced8bec4..1f946217fc 100644 --- a/web/src/components/apps/HelmVMClusterManagement.tsx +++ b/web/src/components/apps/EmbeddedClusterManagement.tsx @@ -12,7 +12,7 @@ import { Utilities } from "../../utilities/utilities"; import Icon from "../Icon"; import CodeSnippet from "../shared/CodeSnippet"; -import "@src/scss/components/apps/HelmVMClusterManagement.scss"; +import "@src/scss/components/apps/EmbeddedClusterManagement.scss"; const testData = { nodes: undefined, @@ -20,7 +20,7 @@ const testData = { // const testData = { // nodes: [ // { -// name: "laverya-helmvm", +// name: "laverya-embeddedcluster", // isConnected: true, // isReady: true, // isPrimaryNode: true, @@ -43,7 +43,7 @@ const testData = { // }, // ], // ha: true, -// isHelmVMEnabled: true, +// isEmbeddedClusterEnabled: true, // }; type State = { @@ -56,7 +56,7 @@ type State = { drainNodeSuccessful: boolean; }; -const HelmVMClusterManagement = ({ +const EmbeddedClusterManagement = ({ fromLicenseFlow = false, }: { fromLicenseFlow?: boolean; @@ -79,7 +79,7 @@ const HelmVMClusterManagement = ({ const [selectedNodeTypes, setSelectedNodeTypes] = useState([]); const { data: appsData } = useApps(); - // we grab the first app because helmvm users should only ever have one app + // we grab the first app because embeddedcluster users should only ever have one app const app = appsData?.apps?.[0]; const { slug } = useParams(); @@ -87,7 +87,7 @@ const HelmVMClusterManagement = ({ // #region queries type NodesResponse = { ha: boolean; - isHelmVMEnabled: boolean; + isEmbeddedClusterEnabled: boolean; nodes: { name: string; isConnected: boolean; @@ -122,15 +122,18 @@ const HelmVMClusterManagement = ({ isInitialLoading: nodesLoading, error: nodesError, } = useQuery({ - queryKey: ["helmVmNodes"], + queryKey: ["embeddedClusterNodes"], queryFn: async () => { - const res = await fetch(`${process.env.API_ENDPOINT}/helmvm/nodes`, { - headers: { - Accept: "application/json", - }, - credentials: "include", - method: "GET", - }); + const res = await fetch( + `${process.env.API_ENDPOINT}/embedded-cluster/nodes`, + { + headers: { + Accept: "application/json", + }, + credentials: "include", + method: "GET", + } + ); if (!res.ok) { if (res.status === 401) { Utilities.logoutUser(); @@ -168,7 +171,7 @@ const HelmVMClusterManagement = ({ queryFn: async ({ queryKey }) => { const [, nodeTypes] = queryKey; const res = await fetch( - `${process.env.API_ENDPOINT}/helmvm/generate-node-join-command`, + `${process.env.API_ENDPOINT}/embedded-cluster/generate-node-join-command`, { headers: { "Content-Type": "application/json", @@ -334,7 +337,7 @@ const HelmVMClusterManagement = ({ // #endregion return ( -
+

@@ -517,4 +520,4 @@ const HelmVMClusterManagement = ({ ); }; -export default HelmVMClusterManagement; +export default EmbeddedClusterManagement; diff --git a/web/src/components/apps/HelmVMViewNode.jsx b/web/src/components/apps/EmbeddedClusterViewNode.jsx similarity index 92% rename from web/src/components/apps/HelmVMViewNode.jsx rename to web/src/components/apps/EmbeddedClusterViewNode.jsx index 6bd7651568..a581009c3c 100644 --- a/web/src/components/apps/HelmVMViewNode.jsx +++ b/web/src/components/apps/EmbeddedClusterViewNode.jsx @@ -1,12 +1,12 @@ import { MaterialReactTable } from "material-react-table"; -import React, { useMemo, setState } from "react"; +import React, { useMemo } from "react"; import { useQuery } from "@tanstack/react-query"; import { Link, useParams } from "react-router-dom"; import Loader from "@components/shared/Loader"; const testData = undefined; // const testData = { -// name: "laverya-helmvm", +// name: "laverya-embeddedcluster", // isConnected: true, // isReady: true, // isPrimaryNode: true, @@ -29,27 +29,30 @@ const testData = undefined; // { // name: "example-es-85fc9df74-8x8l6", // status: "Running", -// namespace: "helmvm", +// namespace: "embeddedcluster", // cpu: "0.0345789345 GB", // memory: 0, // }, // ], // }; -const HelmVMViewNode = () => { +const EmbeddedClusterViewNode = () => { const { slug, nodeName } = useParams(); const { data: nodeData, isLoading: nodeLoading } = useQuery({ - queryKey: ["helmVmNode", nodeName], + queryKey: ["embeddedClusterNode", nodeName], queryFn: async ({ queryKey }) => { const [, nodeName] = queryKey; return ( - await fetch(`${process.env.API_ENDPOINT}/helmvm/node/${nodeName}`, { - headers: { - Accept: "application/json", - }, - credentials: "include", - method: "GET", - }) + await fetch( + `${process.env.API_ENDPOINT}/embedded-cluster/node/${nodeName}`, + { + headers: { + Accept: "application/json", + }, + credentials: "include", + method: "GET", + } + ) ).json(); }, onError: (err) => { @@ -239,4 +242,4 @@ const HelmVMViewNode = () => { ); }; -export default HelmVMViewNode; +export default EmbeddedClusterViewNode; diff --git a/web/src/components/apps/HelmVMNodeRow.test.js b/web/src/components/apps/EmbeddedClustrNodeRow.test.js similarity index 57% rename from web/src/components/apps/HelmVMNodeRow.test.js rename to web/src/components/apps/EmbeddedClustrNodeRow.test.js index b7a4d8324c..18b6d130ad 100644 --- a/web/src/components/apps/HelmVMNodeRow.test.js +++ b/web/src/components/apps/EmbeddedClustrNodeRow.test.js @@ -1,3 +1,3 @@ -describe("HelmVMNodeRow", () => { +describe("EmbeddedClusterNodeRow", () => { it.todo("upgrade to react 18 and add unit tests"); }); diff --git a/web/src/components/shared/NavBar.tsx b/web/src/components/shared/NavBar.tsx index 09c6dc2c9d..48ee8c0624 100644 --- a/web/src/components/shared/NavBar.tsx +++ b/web/src/components/shared/NavBar.tsx @@ -1,7 +1,7 @@ import React, { PureComponent } from "react"; import PropTypes from "prop-types"; import classNames from "classnames"; -import { withRouter, RouterProps } from "@src/utilities/react-router-utilities"; +import { RouterProps, withRouter } from "@src/utilities/react-router-utilities"; import { Link } from "react-router-dom"; import { Utilities } from "@src/utilities/utilities"; import ErrorModal from "../modals/ErrorModal"; @@ -19,7 +19,7 @@ type Props = { isHelmManaged: boolean; isIdentityServiceSupported: boolean; isKurlEnabled: boolean; - isHelmVMEnabled: boolean; + isEmbeddedClusterEnabled: boolean; isSnapshotsSupported: boolean; logo: string | null; onLogoutError: (message: string) => void; @@ -144,7 +144,7 @@ export class NavBar extends PureComponent { className, fetchingMetadata, isKurlEnabled, - isHelmVMEnabled, + isEmbeddedClusterEnabled, isGitOpsSupported, isIdentityServiceSupported, appsList, @@ -228,7 +228,7 @@ export class NavBar extends PureComponent {

)} - {(isKurlEnabled || isHelmVMEnabled) && + {(isKurlEnabled || isEmbeddedClusterEnabled) && location.pathname !== `${selectedApp?.slug}/cluster/manage` && (