Skip to content

Commit

Permalink
Merge pull request #6 from hanumeshc/OES-1.30.1
Browse files Browse the repository at this point in the history
June30-oct26 custom commits
  • Loading branch information
siddhu-opsmx authored Nov 1, 2023
2 parents 94b8253 + 2ebc9b6 commit 221f1bc
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export class AmazonServerGroupActions extends React.Component<IAmazonServerGroup

return (
<>
{AWSProviderSettings.adHocInfraWritesEnabled && (
{AWSProviderSettings.adHocInfraWritesEnabled && SETTINGS.adHocInfraEditEnabled && (
<Dropdown className="dropdown" id="server-group-actions-dropdown">
<Dropdown.Toggle className="btn btn-sm btn-primary dropdown-toggle">Server Group Actions</Dropdown.Toggle>
<Dropdown.Menu className="dropdown-menu">
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/settings-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
e.g.,
window.spinnakerSettings.defaultInstancePort = 8080;
*/
window.spinnakerSettings.kubernetesAdHocInfraEditEnabled = true;
4 changes: 4 additions & 0 deletions packages/core/src/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export interface ISpinnakerSettings {
triggerTypes: string[];
useClassicFirewallLabels: boolean;
kubernetesAdHocInfraWritesEnabled: boolean;
kubernetesAdHocInfraEditEnabled: boolean;
changelogUrl: string;
adHocInfraEditEnabled: boolean;
}

export const SETTINGS: ISpinnakerSettings = (window as any).spinnakerSettings || {};
Expand All @@ -158,6 +160,8 @@ export const SETTINGS: ISpinnakerSettings = (window as any).spinnakerSettings ||
SETTINGS.feature = SETTINGS.feature || {};
SETTINGS.feature.roscoMode = SETTINGS.feature.roscoMode ?? true;
SETTINGS.kubernetesAdHocInfraWritesEnabled = SETTINGS.kubernetesAdHocInfraWritesEnabled ?? true;
SETTINGS.kubernetesAdHocInfraEditEnabled = SETTINGS.kubernetesAdHocInfraEditEnabled ?? false;
SETTINGS.adHocInfraEditEnabled = SETTINGS.adHocInfraEditEnabled ?? true;
SETTINGS.analytics = SETTINGS.analytics || {};
SETTINGS.providers = SETTINGS.providers || {};
SETTINGS.defaultTimeZone = SETTINGS.defaultTimeZone || 'America/Los_Angeles';
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/help/help.contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ const helpContents: { [key: string]: string } = {
'<p>Configures the cluster upon which this destroy operation will act. The <em>target</em> specifies what server group to resolve for the operation.</p>',
'pipeline.config.jenkins.trigger.propertyFile':
'<p>(Optional) Configures the name to the Jenkins artifact file used to pass in properties to later stages in the Spinnaker pipeline. The contents of this file will now be available as a map under the trigger and accessible via <em>trigger.properties</em>. See <a target="_blank" href="https://www.spinnaker.io/guides/user/pipeline-expressions/">Pipeline Expressions docs</a> for more information.</p>',
'pipeline.config.jenkins.trigger.unstableBuild':
'<p>If Jenkins reports the build status as UNSTABLE, Spinnaker will mark the build as SUCCEEDED and start execution of the pipeline.</p>',
'pipeline.config.jenkins.trigger.payloadConstraints': `<p>(Optional, Requires Property File) When provided, only a build that contains a Property File with correct constraints will trigger this pipeline. For example, you could restrict the trigger to certain branches by placing the branch name in your Property File and adding a constraint with a key like "branch" and value "master".</p>
<p>The constraint values may be supplied as regex.</p>`,
'pipeline.config.jenkins.propertyFile':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BuildServiceType, IgorService } from '../../../../ci/igor.service';
import type { IBuildTrigger } from '../../../../domain';
import { MapEditorInput } from '../../../../forms';
import { HelpField } from '../../../../help';
import { FormikFormField, TextInput, useLatestPromise } from '../../../../presentation';
import { CheckboxInput, FormikFormField, TextInput, useLatestPromise } from '../../../../presentation';

export interface IBaseBuildTriggerConfigProps {
formik: FormikProps<IBuildTrigger>;
Expand Down Expand Up @@ -80,6 +80,17 @@ export function BaseBuildTrigger(buildTriggerProps: IBaseBuildTriggerConfigProps
/>
)}

{type == 'jenkins' && (
<FormikFormField
name="unstableBuild"
label="If build is unstable"
help={<HelpField id={`pipeline.config.${type}.trigger.unstableBuild`} />}
input={(props) => (
<CheckboxInput {...props} inputClassName="enable-trigger-checkbox" text="consider as a successful" />
)}
/>
)}

<FormikFormField
name="payloadConstraints"
label="Payload Constraints"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
SERVER_GROUP_WRITER,
ServerGroupReader,
ServerGroupWarningMessageService,
SETTINGS,
SubnetReader,
} from '@spinnaker/core';

Expand Down Expand Up @@ -362,5 +363,9 @@ angular
serverGroup.accountDetails = details;
});
};

this.isEditEnabled = () => {
return SETTINGS.adHocInfraEditEnabled;
};
},
]);
6 changes: 5 additions & 1 deletion packages/ecs/src/serverGroup/details/serverGroupDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ <h3 class="horizontal middle space-between flex-1" select-on-dbl-click>
</h3>
</div>
<div>
<div class="actions" ng-class="{ insights: ctrl.serverGroup.insightActions.length > 0 }">
<div
class="actions"
ng-class="{ insights: ctrl.serverGroup.insightActions.length > 0 }"
ng-if="ctrl.isEditEnabled()"
>
<div class="dropdown" uib-dropdown dropdown-append-to-body>
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" uib-dropdown-toggle>
Server Group Actions <span class="caret"></span>
Expand Down
17 changes: 17 additions & 0 deletions packages/kubernetes/src/serverGroup/details/details.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { IModalService } from 'angular-ui-bootstrap';

import type { Application, IManifest, IOwnerOption, IServerGroup } from '@spinnaker/core';
import {
AuthenticationService,
ClusterTargetBuilder,
ConfirmationModalService,
ManifestReader,
Expand Down Expand Up @@ -64,6 +65,22 @@ class KubernetesServerGroupDetailsController implements IController {
}
}

public isEditEnabled(): boolean {
const authenticatedUser = AuthenticationService.getAuthenticatedUser();
const applicationAttr = this.app.attributes;
const isExist = (arr1: string[], arr2: string[]) => {
return arr1?.some((v) => arr2?.includes(v));
};
const isWriteEnabled = () => {
if (authenticatedUser.name !== applicationAttr.user && applicationAttr.permissions) {
return isExist(applicationAttr.permissions?.WRITE, authenticatedUser.roles);
} else {
return true;
}
};
return SETTINGS.kubernetesAdHocInfraEditEnabled ? isWriteEnabled() : true;
}

private ownerIsController(ownerReference: any): boolean {
return ownerReference.hasOwnProperty('controller') && ownerReference.controller === true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kubernetes/src/serverGroup/details/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h3 class="horizontal middle space-between flex-1" select-on-dbl-click>
</render-if-feature>
</h3>
</div>
<div class="actions">
<div class="actions" ng-if="ctrl.isEditEnabled()">
<div class="dropdown" uib-dropdown dropdown-append-to-body>
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" uib-dropdown-toggle ng-hide="isDisabled">
{{ctrl.serverGroup.kind | robotToHuman}} Actions <span class="caret"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
IServerGroupManager,
IServerGroupManagerStateParams,
} from '@spinnaker/core';
import { ClusterTargetBuilder, ManifestReader, NameUtils, SETTINGS } from '@spinnaker/core';
import { AuthenticationService, ClusterTargetBuilder, ManifestReader, NameUtils, SETTINGS } from '@spinnaker/core';

import type { IKubernetesServerGroupManager } from '../../interfaces';
import { KubernetesManifestCommandBuilder } from '../../manifest/manifestCommandBuilder.service';
Expand Down Expand Up @@ -43,6 +43,22 @@ class KubernetesServerGroupManagerDetailsController implements IController {
this.$scope.isDisabled = !SETTINGS.kubernetesAdHocInfraWritesEnabled;
}

public isEditEnabled(): boolean {
const authenticatedUser = AuthenticationService.getAuthenticatedUser();
const applicationAttr = this.app.attributes;
const isExist = (arr1: string[], arr2: string[]) => {
return arr1?.some((v) => arr2?.includes(v));
};
const isWriteEnabled = () => {
if (authenticatedUser.name !== applicationAttr.user && applicationAttr.permissions) {
return isExist(applicationAttr.permissions?.WRITE, authenticatedUser.roles);
} else {
return true;
}
};
return SETTINGS.kubernetesAdHocInfraEditEnabled ? isWriteEnabled() : true;
}

public pauseRolloutServerGroupManager(): void {
this.$uibModal.open({
templateUrl: require('../../manifest/rollout/pause.html'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h3 class="horizontal middle space-between flex-1" select-on-dbl-click>
</render-if-feature>
</h3>
</div>
<div class="actions">
<div class="actions" ng-if="ctrl.isEditEnabled()">
<div class="dropdown" uib-dropdown dropdown-append-to-body>
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" uib-dropdown-toggle ng-hide="isDisabled">
{{ctrl.serverGroupManager.kind | robotToHuman}} Actions <span class="caret"></span>
Expand Down
15 changes: 0 additions & 15 deletions test/functional/cypress/integration/ecs/clusters_list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ describe('Amazon ECS: aws-prod-ecsdemo cluster', () => {
cy.get('.sub-group:contains("aws-prod-ecsdemo")')
.find('.server-group:contains("v000")')
.click({ force: true });

cy.get('.btn:contains("Server Group Actions")')
.click()
.get('.dropdown-menu')
.get('.ng-scope')
.should('contain.text', 'Rollback');

cy.get('a:contains("Rollback")').click({ force: true });

cy.get('.modal-title').should('contain.text', 'Rollback aws-prod-ecsdemo');
});

it('shows stored details view and ECS server group actions', () => {
Expand All @@ -47,11 +37,6 @@ describe('Amazon ECS: aws-prod-ecsdemo cluster', () => {
cy.get('.sub-group:contains("aws-prod-ecsdemo")')
.find('.server-group:contains("v000")')
.click({ force: true });

cy.get('.btn:contains("Server Group Actions")')
.click()
.get('a:contains("Rollback")')
.click();
});

it('shows stored instance details view action', () => {
Expand Down

0 comments on commit 221f1bc

Please sign in to comment.