@spinnaker/kubernetes 2025.0.6 → 2025.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1178 -641
  3. package/dist/index.js.map +1 -1
  4. package/dist/interfaces/infrastructure.types.d.ts +4 -1
  5. package/dist/manifest/AnnotationCustomSections.d.ts +5 -0
  6. package/dist/manifest/annotationCustomSections.component.d.ts +2 -0
  7. package/dist/manifest/artifact/ManifestArtifact.d.ts +6 -0
  8. package/dist/manifest/index.d.ts +1 -1
  9. package/dist/manifest/manifest.service.d.ts +1 -1
  10. package/dist/manifest/rollout/RollingRestart.d.ts +9 -1
  11. package/dist/manifest/status/ManifestStatus.d.ts +8 -0
  12. package/dist/rawResource/controller/FiltersPubSub.d.ts +1 -1
  13. package/dist/reactShims/index.d.ts +1 -0
  14. package/dist/reactShims/kubernetes.react.injector.d.ts +11 -0
  15. package/dist/reactShims/kubernetes.react.module.d.ts +1 -0
  16. package/dist/serverGroup/details/KubernetesServerGroupActions.d.ts +7 -0
  17. package/dist/serverGroup/details/kubernetesServerGroupDetailsGetter.d.ts +4 -0
  18. package/dist/serverGroup/details/sections/IKubernetesServerGroupDetailsSectionProps.d.ts +5 -0
  19. package/dist/serverGroup/details/sections/ServerGroupAnnotationCustomSection.d.ts +3 -0
  20. package/dist/serverGroup/details/sections/ServerGroupEventsSection.d.ts +3 -0
  21. package/dist/serverGroup/details/sections/ServerGroupHealthSection.d.ts +3 -0
  22. package/dist/serverGroup/details/sections/ServerGroupImagesSection.d.ts +3 -0
  23. package/dist/serverGroup/details/sections/ServerGroupInformationSection.d.ts +3 -0
  24. package/dist/serverGroup/details/sections/ServerGroupLabelsSection.d.ts +3 -0
  25. package/dist/serverGroup/details/sections/ServerGroupManifestStatusSection.d.ts +3 -0
  26. package/dist/serverGroup/details/sections/ServerGroupSizeSection.d.ts +3 -0
  27. package/dist/serverGroup/details/sections/index.d.ts +9 -0
  28. package/dist/serverGroup/details/useManifest.d.ts +8 -0
  29. package/dist/serverGroup/index.d.ts +3 -4
  30. package/dist/serverGroup/{serverGroupCommandBuilder.service.d.ts → serverGroupCommandBuilder.d.ts} +0 -1
  31. package/dist/serverGroup/{serverGroupTransformer.service.d.ts → serverGroupTransformer.d.ts} +0 -1
  32. package/dist/serverGroupManager/details/ServerGroupManagerActions.d.ts +9 -0
  33. package/dist/serverGroupManager/details/ServerGroupManagerDetails.d.ts +7 -0
  34. package/dist/serverGroupManager/details/sections/IKubernetesServerGroupManagerDetailsSectionProps.d.ts +6 -0
  35. package/dist/serverGroupManager/details/sections/ServerGroupManagerAnnotationCustomSection.d.ts +3 -0
  36. package/dist/serverGroupManager/details/sections/ServerGroupManagerArtifactsSection.d.ts +3 -0
  37. package/dist/serverGroupManager/details/sections/ServerGroupManagerEventsSection.d.ts +3 -0
  38. package/dist/serverGroupManager/details/sections/ServerGroupManagerInformationSection.d.ts +3 -0
  39. package/dist/serverGroupManager/details/sections/ServerGroupManagerLabelsSection.d.ts +3 -0
  40. package/dist/serverGroupManager/details/sections/ServerGroupManagerManifestConditionSection.d.ts +3 -0
  41. package/dist/serverGroupManager/details/sections/ServerGroupManagerManifestStatusSection.d.ts +3 -0
  42. package/dist/serverGroupManager/details/sections/index.d.ts +8 -0
  43. package/dist/serverGroupManager/details/useKubernetesServerGroupManagerDetails.d.ts +4 -0
  44. package/dist/serverGroupManager/index.d.ts +1 -1
  45. package/package.json +3 -3
  46. package/src/index.ts +1 -0
  47. package/src/interfaces/infrastructure.types.ts +5 -0
  48. package/src/kubernetes.module.ts +32 -21
  49. package/src/manifest/AnnotationCustomSections.tsx +6 -0
  50. package/src/manifest/annotationCustomSections.component.ts +1 -1
  51. package/src/manifest/artifact/ManifestArtifact.tsx +16 -0
  52. package/src/manifest/index.ts +1 -1
  53. package/src/manifest/rollout/RollingRestart.tsx +2 -10
  54. package/src/manifest/status/ManifestStatus.tsx +39 -0
  55. package/src/manifest/status/status.component.ts +7 -32
  56. package/src/reactShims/index.ts +1 -0
  57. package/src/reactShims/kubernetes.react.injector.ts +30 -0
  58. package/src/reactShims/kubernetes.react.module.ts +12 -0
  59. package/src/serverGroup/details/KubernetesServerGroupActions.tsx +138 -0
  60. package/src/serverGroup/details/kubernetesServerGroupDetailsGetter.ts +63 -0
  61. package/src/serverGroup/details/sections/IKubernetesServerGroupDetailsSectionProps.ts +6 -0
  62. package/src/serverGroup/details/sections/ServerGroupAnnotationCustomSection.tsx +11 -0
  63. package/src/serverGroup/details/sections/ServerGroupEventsSection.tsx +14 -0
  64. package/src/serverGroup/details/sections/ServerGroupHealthSection.tsx +19 -0
  65. package/src/serverGroup/details/sections/ServerGroupImagesSection.tsx +14 -0
  66. package/src/serverGroup/details/sections/ServerGroupInformationSection.tsx +46 -0
  67. package/src/serverGroup/details/sections/ServerGroupLabelsSection.tsx +14 -0
  68. package/src/serverGroup/details/sections/ServerGroupManifestStatusSection.tsx +9 -0
  69. package/src/serverGroup/details/sections/ServerGroupSizeSection.tsx +35 -0
  70. package/src/serverGroup/details/sections/index.ts +9 -0
  71. package/src/serverGroup/details/useManifest.ts +42 -0
  72. package/src/serverGroup/index.ts +3 -4
  73. package/src/serverGroup/{serverGroupCommandBuilder.service.ts → serverGroupCommandBuilder.ts} +0 -9
  74. package/src/serverGroup/{serverGroupTransformer.service.spec.ts → serverGroupTransformer.spec.ts} +1 -1
  75. package/src/serverGroup/{serverGroupTransformer.service.ts → serverGroupTransformer.ts} +0 -7
  76. package/src/serverGroupManager/details/ServerGroupManagerActions.tsx +171 -0
  77. package/src/serverGroupManager/details/ServerGroupManagerDetails.tsx +72 -0
  78. package/src/serverGroupManager/details/sections/IKubernetesServerGroupManagerDetailsSectionProps.ts +7 -0
  79. package/src/serverGroupManager/details/sections/ServerGroupManagerAnnotationCustomSection.tsx +12 -0
  80. package/src/serverGroupManager/details/sections/ServerGroupManagerArtifactsSection.tsx +18 -0
  81. package/src/serverGroupManager/details/sections/ServerGroupManagerEventsSection.tsx +14 -0
  82. package/src/serverGroupManager/details/sections/ServerGroupManagerInformationSection.tsx +51 -0
  83. package/src/serverGroupManager/details/sections/ServerGroupManagerLabelsSection.tsx +14 -0
  84. package/src/serverGroupManager/details/sections/ServerGroupManagerManifestConditionSection.tsx +21 -0
  85. package/src/serverGroupManager/details/sections/ServerGroupManagerManifestStatusSection.tsx +10 -0
  86. package/src/serverGroupManager/details/sections/index.ts +8 -0
  87. package/src/serverGroupManager/details/useKubernetesServerGroupManagerDetails.tsx +53 -0
  88. package/src/serverGroupManager/index.ts +1 -1
  89. package/dist/manifest/artifact/artifact.component.d.ts +0 -1
  90. package/dist/serverGroup/details/details.controller.d.ts +0 -1
  91. package/dist/serverGroup/details/resize/resize.controller.d.ts +0 -1
  92. package/dist/serverGroupManager/details/details.controller.d.ts +0 -1
  93. package/src/manifest/artifact/artifact.component.ts +0 -23
  94. package/src/serverGroup/details/details.controller.ts +0 -207
  95. package/src/serverGroup/details/details.html +0 -153
  96. package/src/serverGroup/details/resize/resize.controller.ts +0 -73
  97. package/src/serverGroup/details/resize/resize.html +0 -57
  98. package/src/serverGroupManager/details/details.controller.ts +0 -191
  99. package/src/serverGroupManager/details/details.html +0 -136
@@ -1,207 +0,0 @@
1
- import type { StateService } from '@uirouter/angularjs';
2
- import type { IController, IQService, IScope } from 'angular';
3
- import { module } from 'angular';
4
- import type { IModalService } from 'angular-ui-bootstrap';
5
-
6
- import type { Application, IManifest, IOwnerOption, IServerGroup } from '@spinnaker/core';
7
- import {
8
- ClusterTargetBuilder,
9
- ConfirmationModalService,
10
- ManifestReader,
11
- SERVER_GROUP_WRITER,
12
- ServerGroupReader,
13
- SETTINGS,
14
- } from '@spinnaker/core';
15
-
16
- import type { IKubernetesServerGroup } from '../../interfaces';
17
- import { KubernetesManifestCommandBuilder } from '../../manifest/manifestCommandBuilder.service';
18
- import { ManifestTrafficService } from '../../manifest/traffic/ManifestTrafficService';
19
- import { ManifestWizard } from '../../manifest/wizard/ManifestWizard';
20
-
21
- interface IServerGroupFromStateParams {
22
- accountId: string;
23
- region: string;
24
- name: string;
25
- }
26
-
27
- class KubernetesServerGroupDetailsController implements IController {
28
- public state = { loading: true };
29
- public serverGroup: IKubernetesServerGroup;
30
- public manifest: IManifest;
31
- public entityTagTargets: IOwnerOption[];
32
-
33
- public static $inject = ['serverGroup', 'app', '$uibModal', '$scope', '$state', '$q'];
34
- constructor(
35
- serverGroup: IServerGroupFromStateParams,
36
- public app: Application,
37
- private $uibModal: IModalService,
38
- private $scope: IScope,
39
- private $state: StateService,
40
- private $q: IQService,
41
- ) {
42
- const dataSource = this.app.getDataSource('serverGroups');
43
- dataSource
44
- .ready()
45
- .then(() => {
46
- this.extractServerGroup(serverGroup);
47
- this.$scope.isDisabled = !SETTINGS.kubernetesAdHocInfraWritesEnabled;
48
- dataSource.onRefresh(this.$scope, () => this.extractServerGroup(serverGroup));
49
- })
50
- .catch(() => this.autoClose());
51
- }
52
-
53
- private ownerReferences(): any[] {
54
- const manifest = this.manifest.manifest;
55
- if (
56
- manifest != null &&
57
- manifest.hasOwnProperty('metadata') &&
58
- manifest.metadata.hasOwnProperty('ownerReferences') &&
59
- Array.isArray(manifest.metadata.ownerReferences)
60
- ) {
61
- return manifest.metadata.ownerReferences;
62
- } else {
63
- return [] as any[];
64
- }
65
- }
66
-
67
- private ownerIsController(ownerReference: any): boolean {
68
- return ownerReference.hasOwnProperty('controller') && ownerReference.controller === true;
69
- }
70
-
71
- private lowerCaseFirstLetter(s: string): string {
72
- return s.charAt(0).toLowerCase() + s.slice(1);
73
- }
74
-
75
- public manifestController(): string {
76
- const controller = this.ownerReferences().find(this.ownerIsController);
77
- if (typeof controller === 'undefined') {
78
- return null;
79
- } else {
80
- return this.lowerCaseFirstLetter(controller.kind) + ' ' + controller.name;
81
- }
82
- }
83
-
84
- public canScaleServerGroup(): boolean {
85
- return this.serverGroup.kind !== 'DaemonSet' && this.manifestController() === null;
86
- }
87
-
88
- public scaleServerGroup(): void {
89
- this.$uibModal.open({
90
- templateUrl: require('../../manifest/scale/scale.html'),
91
- controller: 'kubernetesV2ManifestScaleCtrl',
92
- controllerAs: 'ctrl',
93
- resolve: {
94
- coordinates: {
95
- name: this.serverGroup.name,
96
- namespace: this.serverGroup.namespace,
97
- account: this.serverGroup.account,
98
- },
99
- currentReplicas: this.manifest.manifest.spec.replicas,
100
- application: this.app,
101
- },
102
- });
103
- }
104
-
105
- public canEditServerGroup(): boolean {
106
- return this.manifestController() === null;
107
- }
108
-
109
- public editServerGroup(): void {
110
- KubernetesManifestCommandBuilder.buildNewManifestCommand(
111
- this.app,
112
- this.manifest.manifest,
113
- this.serverGroup.moniker,
114
- this.serverGroup.account,
115
- ).then((builtCommand) => {
116
- ManifestWizard.show({ title: 'Edit Manifest', application: this.app, command: builtCommand });
117
- });
118
- }
119
-
120
- public deleteServerGroup(): void {
121
- this.$uibModal.open({
122
- templateUrl: require('../../manifest/delete/delete.html'),
123
- controller: 'kubernetesV2ManifestDeleteCtrl',
124
- controllerAs: 'ctrl',
125
- resolve: {
126
- coordinates: {
127
- name: this.serverGroup.name,
128
- namespace: this.serverGroup.namespace,
129
- account: this.serverGroup.account,
130
- },
131
- manifestController: () => this.manifestController(),
132
- application: this.app,
133
- },
134
- });
135
- }
136
-
137
- public canDisable = () => ManifestTrafficService.canDisableServerGroup(this.serverGroup);
138
-
139
- public disableServerGroup = (): void => {
140
- ConfirmationModalService.confirm({
141
- header: `Really disable ${this.manifest.name}?`,
142
- buttonText: 'Disable',
143
- askForReason: true,
144
- submitJustWithReason: true,
145
- submitMethod: ({ reason }: { reason: string }) => ManifestTrafficService.disable(this.manifest, this.app, reason),
146
- taskMonitorConfig: {
147
- application: this.app,
148
- title: `Disabling ${this.manifest.name}`,
149
- onTaskComplete: () => this.app.getDataSource('serverGroups').refresh(),
150
- },
151
- });
152
- };
153
-
154
- public canEnable = () => ManifestTrafficService.canEnableServerGroup(this.serverGroup);
155
-
156
- public enableServerGroup = (): void => {
157
- ConfirmationModalService.confirm({
158
- header: `Really enable ${this.manifest.name}?`,
159
- buttonText: 'Enable',
160
- askForReason: true,
161
- submitJustWithReason: true,
162
- submitMethod: ({ reason }: { reason: string }) => ManifestTrafficService.enable(this.manifest, this.app, reason),
163
- taskMonitorConfig: {
164
- application: this.app,
165
- title: `Enabling ${this.manifest.name}`,
166
- onTaskComplete: () => this.app.getDataSource('serverGroups').refresh(),
167
- },
168
- });
169
- };
170
-
171
- private autoClose(): void {
172
- if (this.$scope.$$destroyed) {
173
- return;
174
- } else {
175
- this.$state.params.allowModalToStayOpen = true;
176
- this.$state.go('^', null, { location: 'replace' });
177
- }
178
- }
179
-
180
- private extractServerGroup({ accountId, name, region }: IServerGroupFromStateParams): void {
181
- this.$q
182
- .all([
183
- ServerGroupReader.getServerGroup(this.app.name, accountId, region, name),
184
- ManifestReader.getManifest(accountId, region, name),
185
- ])
186
- .then(([serverGroupDetails, manifest]: [IServerGroup, IManifest]) => {
187
- if (!serverGroupDetails) {
188
- return this.autoClose();
189
- }
190
- this.serverGroup = serverGroupDetails as IKubernetesServerGroup;
191
- this.entityTagTargets = this.configureEntityTagTargets();
192
- this.manifest = manifest;
193
- this.state.loading = false;
194
- });
195
- }
196
-
197
- private configureEntityTagTargets(): IOwnerOption[] {
198
- return ClusterTargetBuilder.buildClusterTargets(this.serverGroup);
199
- }
200
- }
201
-
202
- export const KUBERNETES_SERVER_GROUP_DETAILS_CTRL = 'spinnaker.kubernetes.serverGroup.details.controller';
203
-
204
- module(KUBERNETES_SERVER_GROUP_DETAILS_CTRL, [SERVER_GROUP_WRITER]).controller(
205
- 'kubernetesV2ServerGroupDetailsCtrl',
206
- KubernetesServerGroupDetailsController,
207
- );
@@ -1,153 +0,0 @@
1
- <div class="details-panel" ng-class="{disabled: ctrl.serverGroup.isDisabled || ctrl.serverGroup.disabled}">
2
- <div class="header" ng-if="ctrl.state.loading">
3
- <div class="close-button">
4
- <a class="btn btn-link" ui-sref="^">
5
- <span class="glyphicon glyphicon-remove"></span>
6
- </a>
7
- </div>
8
- <h4 class="text-center">
9
- <span us-spinner="{radius:20, width:6, length: 12}"></span>
10
- </h4>
11
- </div>
12
-
13
- <div class="header" ng-if="!ctrl.state.loading">
14
- <div class="close-button">
15
- <a class="btn btn-link" ui-sref="^">
16
- <span class="glyphicon glyphicon-remove"></span>
17
- </a>
18
- </div>
19
- <div class="header-text horizontal middle">
20
- <cloud-provider-logo
21
- provider="ctrl.serverGroup.cloudProvider"
22
- height="'36px'"
23
- width="'36px'"
24
- ></cloud-provider-logo>
25
- <h3 class="horizontal middle space-between flex-1" select-on-dbl-click>
26
- {{ctrl.serverGroup.displayName}}
27
- <render-if-feature feature="entityTags">
28
- <entity-notifications
29
- entity="ctrl.serverGroup"
30
- application="ctrl.app"
31
- placement="bottom"
32
- h-offset-percent="90%"
33
- entity-type="serverGroup"
34
- page-location="details"
35
- on-update="ctrl.app.serverGroups.refresh()"
36
- ></entity-notifications>
37
- </render-if-feature>
38
- </h3>
39
- </div>
40
- <div class="actions">
41
- <div class="dropdown" uib-dropdown dropdown-append-to-body>
42
- <button type="button" class="btn btn-sm btn-primary dropdown-toggle" uib-dropdown-toggle ng-hide="isDisabled">
43
- {{ctrl.serverGroup.kind | robotToHuman}} Actions <span class="caret"></span>
44
- </button>
45
- <ul class="dropdown-menu" uib-dropdown-menu role="menu">
46
- <li ng-if="ctrl.canEditServerGroup()">
47
- <a href ng-click="ctrl.editServerGroup()"> Edit </a>
48
- </li>
49
- <li ng-if="ctrl.canScaleServerGroup()">
50
- <a href ng-click="ctrl.scaleServerGroup()"> Scale </a>
51
- </li>
52
- <li ng-if="ctrl.canEnable()">
53
- <a href ng-click="ctrl.enableServerGroup()"> Enable </a>
54
- </li>
55
- <li ng-if="ctrl.canDisable()">
56
- <a href ng-click="ctrl.disableServerGroup()"> Disable </a>
57
- </li>
58
- <li>
59
- <a href ng-click="ctrl.deleteServerGroup()"> Delete </a>
60
- </li>
61
- <render-if-feature feature="entityTags">
62
- <add-entity-tag-links
63
- component="ctrl.serverGroup"
64
- application="ctrl.app"
65
- entity-type="serverGroup"
66
- owner-options="ctrl.entityTagTargets"
67
- on-update="ctrl.app.serverGroups.refresh"
68
- ></add-entity-tag-links>
69
- </render-if-feature>
70
- </ul>
71
- </div>
72
- </div>
73
- </div>
74
- <div class="content" ng-if="!ctrl.state.loading">
75
- <kubernetes-manifest-status status="ctrl.manifest.status"></kubernetes-manifest-status>
76
- <div class="band band-info" ng-if="ctrl.serverGroup.isDisabled || ctrl.serverGroup.disabled">Disabled</div>
77
- <server-group-running-tasks-details
78
- server-group="ctrl.serverGroup"
79
- application="ctrl.app"
80
- ></server-group-running-tasks-details>
81
- <collapsible-section heading="Information" expanded="true">
82
- <dl class="dl-horizontal dl-narrow">
83
- <dt>Created</dt>
84
- <dd>{{ctrl.serverGroup.createdTime | timestamp}}</dd>
85
- <dt>Account</dt>
86
- <dd><account-tag account="ctrl.serverGroup.account"></account-tag></dd>
87
- <dt>Namespace</dt>
88
- <dd>{{ctrl.serverGroup.namespace}}</dd>
89
- <dt>Kind</dt>
90
- <dd>{{ctrl.serverGroup.kind}}</dd>
91
- <dt ng-if="ctrl.manifestController()">Controller</dt>
92
- <dd>
93
- <a
94
- ui-sref="^.serverGroupManager({
95
- accountId: ctrl.serverGroup.account,
96
- region: ctrl.serverGroup.region,
97
- serverGroupManager: ctrl.manifestController(),
98
- provider: 'kubernetes'})"
99
- >
100
- {{ctrl.manifestController() | robotToHuman }}
101
- </a>
102
- </dd>
103
- </dl>
104
- </collapsible-section>
105
-
106
- <kubernetes-annotation-custom-sections
107
- manifest="ctrl.manifest.manifest"
108
- resource="ctrl.serverGroup"
109
- ></kubernetes-annotation-custom-sections>
110
-
111
- <collapsible-section heading="Images" expanded="true">
112
- <kubernetes-manifest-image-details manifest="ctrl.manifest.manifest"></kubernetes-manifest-image-details>
113
- </collapsible-section>
114
-
115
- <collapsible-section heading="Events" expanded="true">
116
- <kubernetes-manifest-events manifest="ctrl.manifest"></kubernetes-manifest-events>
117
- </collapsible-section>
118
- <collapsible-section heading="Labels" expanded="true">
119
- <kubernetes-manifest-labels manifest="ctrl.manifest.manifest"></kubernetes-manifest-labels>
120
- </collapsible-section>
121
- <collapsible-section heading="Size" expanded="true">
122
- <dl class="dl-horizontal dl-narrow" ng-if="ctrl.serverGroup.capacity.min == null">
123
- <dt>Current</dt>
124
- <dd>{{ctrl.serverGroup.instances.length}}</dd>
125
- </dl>
126
- <dl
127
- class="dl-horizontal dl-narrow"
128
- ng-if="ctrl.serverGroup.capacity.min != null && ctrl.serverGroup.capacity.min === ctrl.serverGroup.capacity.max"
129
- >
130
- <dt>Min/Max</dt>
131
- <dd>{{ctrl.serverGroup.capacity.min}}</dd>
132
- <dt>Current</dt>
133
- <dd>{{ctrl.serverGroup.instances.length}}</dd>
134
- </dl>
135
- <dl class="dl-horizontal dl-narrow" ng-if="ctrl.serverGroup.capacity.min !== ctrl.serverGroup.capacity.max">
136
- <dt>Min</dt>
137
- <dd>{{ctrl.serverGroup.capacity.min}}</dd>
138
- <dt>Max</dt>
139
- <dd>{{ctrl.serverGroup.capacity.max}}</dd>
140
- <dt>Current</dt>
141
- <dd>{{ctrl.serverGroup.instances.length}}</dd>
142
- </dl>
143
- </collapsible-section>
144
- <collapsible-section heading="Health" expanded="true">
145
- <dl class="dl-horizontal dl-narrow" ng-if="ctrl.serverGroup">
146
- <dt>Instances</dt>
147
- <dd>
148
- <health-counts container="ctrl.serverGroup.instanceCounts" class="pull-left"></health-counts>
149
- </dd>
150
- </dl>
151
- </collapsible-section>
152
- </div>
153
- </div>
@@ -1,73 +0,0 @@
1
- import type { IController } from 'angular';
2
- import { copy, equals, module } from 'angular';
3
- import type { IModalServiceInstance } from 'angular-ui-bootstrap';
4
-
5
- import type { Application, ICapacity, ServerGroupWriter } from '@spinnaker/core';
6
- import { SERVER_GROUP_WRITER, TaskMonitor } from '@spinnaker/core';
7
- import type { IKubernetesServerGroup } from '../../../interfaces';
8
-
9
- interface IResizeCommand {
10
- capacity: ICapacity;
11
- reason: string;
12
- }
13
-
14
- class KubernetesServerGroupResizeController implements IController {
15
- public taskMonitor: TaskMonitor;
16
- public command: IResizeCommand;
17
- public current: ICapacity;
18
- public verification = {
19
- verified: false,
20
- };
21
-
22
- public static $inject = ['serverGroup', '$uibModalInstance', 'serverGroupWriter', 'application'];
23
- constructor(
24
- public serverGroup: IKubernetesServerGroup,
25
- private $uibModalInstance: IModalServiceInstance,
26
- private serverGroupWriter: ServerGroupWriter,
27
- private application: Application,
28
- ) {
29
- this.taskMonitor = new TaskMonitor({
30
- title: `Resizing ${this.serverGroup.name}`,
31
- application,
32
- modalInstance: $uibModalInstance,
33
- });
34
-
35
- this.current = this.serverGroup.capacity;
36
- this.command = {
37
- capacity: copy(this.current),
38
- reason: null,
39
- };
40
- }
41
-
42
- public isValid(): boolean {
43
- return (
44
- this.verification.verified && this.command.capacity.desired >= 0 && !equals(this.command.capacity, this.current)
45
- );
46
- }
47
-
48
- public cancel(): void {
49
- this.$uibModalInstance.dismiss();
50
- }
51
-
52
- public resize(): void {
53
- this.taskMonitor.submit(() => {
54
- const payload = {
55
- capacity: this.command.capacity,
56
- serverGroupName: this.serverGroup.name,
57
- account: this.serverGroup.account,
58
- region: this.serverGroup.region,
59
- interestingHealthProviderNames: ['KubernetesPod'],
60
- reason: this.command.reason,
61
- };
62
-
63
- return this.serverGroupWriter.resizeServerGroup(this.serverGroup, this.application, payload);
64
- });
65
- }
66
- }
67
-
68
- export const KUBERNETES_SERVER_GROUP_RESIZE_CTRL = 'spinnaker.kubernetes.serverGroup.details.resize.controller';
69
-
70
- module(KUBERNETES_SERVER_GROUP_RESIZE_CTRL, [SERVER_GROUP_WRITER]).controller(
71
- 'kubernetesV2ServerGroupResizeCtrl',
72
- KubernetesServerGroupResizeController,
73
- );
@@ -1,57 +0,0 @@
1
- <div modal-page class="confirmation-modal">
2
- <task-monitor monitor="ctrl.taskMonitor"></task-monitor>
3
- <form role="form" name="resizeForm">
4
- <modal-close dismiss="$dismiss()"></modal-close>
5
- <div class="modal-header">
6
- <h4 class="modal-title">Resize {{ctrl.serverGroup.kind}} {{ctrl.serverGroup.displayName}}</h4>
7
- </div>
8
- <div class="modal-body confirmation-modal">
9
- <div class="form-horizontal">
10
- <div class="form-group form-inline">
11
- <div class="col-md-3 sm-label-right">Current</div>
12
- <div class="col-md-3">
13
- <div class="input-group">
14
- <input
15
- type="number"
16
- class="form-control input-sm highlight-pristine"
17
- ng-model="ctrl.current.desired"
18
- readonly
19
- />
20
- <span class="input-group-addon">pod<span ng-if="ctrl.current.desired !== 1">s</span></span>
21
- </div>
22
- </div>
23
- </div>
24
- <div class="form-group form-inline">
25
- <div class="col-md-3 sm-label-right">Desired</div>
26
- <div class="col-md-3">
27
- <div class="input-group">
28
- <input
29
- type="number"
30
- class="form-control input-sm highlight-pristine"
31
- ng-model="ctrl.command.capacity.desired"
32
- min="0"
33
- required
34
- />
35
- <span class="input-group-addon">pod<span ng-if="ctrl.command.capacity.desired !== 1">s</span></span>
36
- </div>
37
- </div>
38
- </div>
39
- </div>
40
- <task-reason command="ctrl.command"></task-reason>
41
- </div>
42
- <div class="modal-footer">
43
- <user-verification account="ctrl.serverGroup.account" verification="ctrl.verification"></user-verification>
44
- <button type="submit" ng-click="ctrl.resize()" style="display: none"></button>
45
- <!-- Allows form submission via enter keypress-->
46
- <button class="btn btn-default" ng-click="ctrl.cancel()">Cancel</button>
47
- <button
48
- type="submit"
49
- class="btn btn-primary"
50
- ng-click="ctrl.resize()"
51
- ng-disabled="!ctrl.isValid() || !resizeForm.$valid"
52
- >
53
- Submit
54
- </button>
55
- </div>
56
- </form>
57
- </div>
@@ -1,191 +0,0 @@
1
- import type { StateService } from '@uirouter/angularjs';
2
- import type { IController, IScope } from 'angular';
3
- import { module } from 'angular';
4
- import type { IModalService } from 'angular-ui-bootstrap';
5
- import { orderBy } from 'lodash';
6
-
7
- import type {
8
- Application,
9
- IManifest,
10
- IOwnerOption,
11
- IServerGroupManager,
12
- IServerGroupManagerStateParams,
13
- } from '@spinnaker/core';
14
- import { ClusterTargetBuilder, ManifestReader, NameUtils, SETTINGS } from '@spinnaker/core';
15
-
16
- import type { IKubernetesServerGroupManager } from '../../interfaces';
17
- import { KubernetesManifestCommandBuilder } from '../../manifest/manifestCommandBuilder.service';
18
- import { ManifestWizard } from '../../manifest/wizard/ManifestWizard';
19
-
20
- class KubernetesServerGroupManagerDetailsController implements IController {
21
- public serverGroupManager: IKubernetesServerGroupManager;
22
- public state = { loading: true };
23
- public manifest: IManifest;
24
- public entityTagTargets: IOwnerOption[];
25
-
26
- public static $inject = ['serverGroupManager', '$scope', '$uibModal', 'app', '$state'];
27
- constructor(
28
- serverGroupManager: IServerGroupManagerStateParams,
29
- private $scope: IScope,
30
- private $uibModal: IModalService,
31
- public app: Application,
32
- private $state: StateService,
33
- ) {
34
- const dataSource = this.app.getDataSource('serverGroupManagers');
35
- dataSource
36
- .ready()
37
- .then(() => {
38
- this.extractServerGroupManager(serverGroupManager);
39
- this.$scope.isDisabled = !SETTINGS.kubernetesAdHocInfraWritesEnabled;
40
- dataSource.onRefresh(this.$scope, () => this.extractServerGroupManager(serverGroupManager));
41
- })
42
- .catch(() => this.autoClose());
43
- this.$scope.isDisabled = !SETTINGS.kubernetesAdHocInfraWritesEnabled;
44
- }
45
-
46
- public pauseRolloutServerGroupManager(): void {
47
- this.$uibModal.open({
48
- templateUrl: require('../../manifest/rollout/pause.html'),
49
- controller: 'kubernetesV2ManifestPauseRolloutCtrl',
50
- controllerAs: 'ctrl',
51
- resolve: {
52
- coordinates: {
53
- name: this.serverGroupManager.name,
54
- namespace: this.serverGroupManager.namespace,
55
- account: this.serverGroupManager.account,
56
- },
57
- application: this.app,
58
- },
59
- });
60
- }
61
-
62
- public resumeRolloutServerGroupManager(): void {
63
- this.$uibModal.open({
64
- templateUrl: require('../../manifest/rollout/resume.html'),
65
- controller: 'kubernetesV2ManifestResumeRolloutCtrl',
66
- controllerAs: 'ctrl',
67
- resolve: {
68
- coordinates: {
69
- name: this.serverGroupManager.name,
70
- namespace: this.serverGroupManager.namespace,
71
- account: this.serverGroupManager.account,
72
- },
73
- application: this.app,
74
- },
75
- });
76
- }
77
-
78
- public canUndoRolloutServerGroupManager(): boolean {
79
- return (
80
- this.serverGroupManager && this.serverGroupManager.serverGroups && this.serverGroupManager.serverGroups.length > 0
81
- );
82
- }
83
-
84
- public undoRolloutServerGroupManager(): void {
85
- this.$uibModal.open({
86
- templateUrl: require('../../manifest/rollout/undo.html'),
87
- controller: 'kubernetesV2ManifestUndoRolloutCtrl',
88
- controllerAs: 'ctrl',
89
- resolve: {
90
- coordinates: {
91
- name: this.serverGroupManager.name,
92
- namespace: this.serverGroupManager.namespace,
93
- account: this.serverGroupManager.account,
94
- },
95
- revisions: () => {
96
- const [, ...rest] = orderBy(this.serverGroupManager.serverGroups, ['moniker.sequence'], ['desc']);
97
- return rest.map((serverGroup, index) => ({
98
- label: `${NameUtils.getSequence(serverGroup.moniker.sequence)}${index > 0 ? '' : ' - previous revision'}`,
99
- revision: serverGroup.moniker.sequence,
100
- }));
101
- },
102
- application: this.app,
103
- },
104
- });
105
- }
106
-
107
- public scaleServerGroupManager(): void {
108
- this.$uibModal.open({
109
- templateUrl: require('../../manifest/scale/scale.html'),
110
- controller: 'kubernetesV2ManifestScaleCtrl',
111
- controllerAs: 'ctrl',
112
- resolve: {
113
- coordinates: {
114
- name: this.serverGroupManager.name,
115
- namespace: this.serverGroupManager.namespace,
116
- account: this.serverGroupManager.account,
117
- },
118
- currentReplicas: this.manifest.manifest.spec.replicas,
119
- application: this.app,
120
- },
121
- });
122
- }
123
-
124
- public editServerGroupManager(): void {
125
- KubernetesManifestCommandBuilder.buildNewManifestCommand(
126
- this.app,
127
- this.manifest.manifest,
128
- this.serverGroupManager.moniker,
129
- this.serverGroupManager.account,
130
- ).then((builtCommand) => {
131
- ManifestWizard.show({ title: 'Edit Manifest', application: this.app, command: builtCommand });
132
- });
133
- }
134
-
135
- public deleteServerGroupManager(): void {
136
- this.$uibModal.open({
137
- templateUrl: require('../../manifest/delete/delete.html'),
138
- controller: 'kubernetesV2ManifestDeleteCtrl',
139
- controllerAs: 'ctrl',
140
- resolve: {
141
- coordinates: {
142
- name: this.serverGroupManager.name,
143
- namespace: this.serverGroupManager.namespace,
144
- account: this.serverGroupManager.account,
145
- },
146
- application: this.app,
147
- manifestController: (): string => null,
148
- },
149
- });
150
- }
151
-
152
- private extractServerGroupManager({ accountId, region, serverGroupManager }: IServerGroupManagerStateParams): void {
153
- const serverGroupManagerDetails = this.app
154
- .getDataSource('serverGroupManagers')
155
- .data.find(
156
- (manager: IServerGroupManager) =>
157
- manager.name === serverGroupManager && manager.region === region && manager.account === accountId,
158
- );
159
-
160
- if (!serverGroupManagerDetails) {
161
- return this.autoClose();
162
- }
163
-
164
- ManifestReader.getManifest(accountId, region, serverGroupManager).then((manifest: IManifest) => {
165
- this.manifest = manifest;
166
- this.serverGroupManager = serverGroupManagerDetails;
167
- this.entityTagTargets = this.configureEntityTagTargets();
168
- this.state.loading = false;
169
- });
170
- }
171
-
172
- private configureEntityTagTargets(): IOwnerOption[] {
173
- return ClusterTargetBuilder.buildManagerClusterTargets(this.serverGroupManager);
174
- }
175
-
176
- private autoClose(): void {
177
- if (this.$scope.$$destroyed) {
178
- return;
179
- } else {
180
- this.$state.params.allowModalToStayOpen = true;
181
- this.$state.go('^', null, { location: 'replace' });
182
- }
183
- }
184
- }
185
-
186
- export const KUBERNETES_SERVER_GROUP_MANAGER_DETAILS_CTRL =
187
- 'spinnaker.kubernetes.serverGroupManager.details.controller';
188
- module(KUBERNETES_SERVER_GROUP_MANAGER_DETAILS_CTRL, []).controller(
189
- 'kubernetesV2ServerGroupManagerDetailsCtrl',
190
- KubernetesServerGroupManagerDetailsController,
191
- );