From 5c1888bfc60e3bbf6c8aa0aeb13d8d7b2a991057 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Mon, 15 Feb 2021 01:33:21 +0200 Subject: [PATCH] fix(endpoint): show correct windows agent deploy command (#4795) * fix(endpoint): show correct windows agent deploy command * format(endpoint): fix code format * fix(endpoints): move deploy command to one place --- .../create/createEndpointController.js | 18 ++++++++++++------ .../views/endpoints/create/createendpoint.html | 16 ++++------------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/app/portainer/views/endpoints/create/createEndpointController.js b/app/portainer/views/endpoints/create/createEndpointController.js index abb039440..728230341 100644 --- a/app/portainer/views/endpoints/create/createEndpointController.js +++ b/app/portainer/views/endpoints/create/createEndpointController.js @@ -43,6 +43,14 @@ angular ], }; + const deployCommands = { + kubeLoadBalancer: `curl -L https://downloads.portainer.io/portainer-agent-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml`, + kubeNodePort: `curl -L https://downloads.portainer.io/portainer-agent-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml`, + agentLinux: `curl -L https://downloads.portainer.io/agent-stack.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent`, + agentWindows: `curl -L https://downloads.portainer.io/agent-stack-windows.yml -o agent-stack-windows.yml && docker stack deploy --compose-file=agent-stack-windows.yml portainer-agent`, + }; + $scope.deployCommands = deployCommands; + $scope.formValues = { Name: '', URL: '', @@ -58,15 +66,13 @@ angular $scope.copyAgentCommand = function () { if ($scope.state.deploymentTab === 2 && $scope.state.PlatformType === 'linux') { - clipboard.copyText('curl -L https://downloads.portainer.io/agent-stack.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent'); + clipboard.copyText(deployCommands.agentLinux); } else if ($scope.state.deploymentTab === 2 && $scope.state.PlatformType === 'windows') { - clipboard.copyText( - 'curl -L https://downloads.portainer.io/agent-stack-windows.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack-windows.yml portainer-agent' - ); + clipboard.copyText(deployCommands.agentWindows); } else if ($scope.state.deploymentTab === 1) { - clipboard.copyText('curl -L https://downloads.portainer.io/portainer-agent-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml'); + clipboard.copyText(deployCommands.kubeNodePort); } else { - clipboard.copyText('curl -L https://downloads.portainer.io/portainer-agent-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml'); + clipboard.copyText(deployCommands.kubeLoadBalancer); } $('#copyNotification').show().fadeOut(2500); }; diff --git a/app/portainer/views/endpoints/create/createendpoint.html b/app/portainer/views/endpoints/create/createendpoint.html index 2f3f62814..985b2d76f 100644 --- a/app/portainer/views/endpoints/create/createendpoint.html +++ b/app/portainer/views/endpoints/create/createendpoint.html @@ -101,24 +101,16 @@
- curl -L https://downloads.portainer.io/portainer-agent-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml + {{ deployCommands.kubeLoadBalancer }} - curl -L https://downloads.portainer.io/portainer-agent-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml + {{ deployCommands.kubeNodePort }} - curl -L https://downloads.portainer.io/agent-stack.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent - curl -L https://downloads.portainer.io/agent-stack-windows.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack-windows.yml portainer-agent + {{ deployCommands.agentLinux }} + {{ deployCommands.agentWindows }}