Skip to content

Commit

Permalink
Set propagationPolicy to 'Background'; rename constants
Browse files Browse the repository at this point in the history
- Set propagationPolicy for devworkspace model to background
- Rename constants CLOUD_SHELL -> WEB_TERMINAL

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
  • Loading branch information
amisevsk committed Jun 11, 2020
1 parent 8681df6 commit ae9bf77
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
@@ -1,7 +1,7 @@
import {
newCloudShellWorkSpace,
CLOUD_SHELL_LABEL,
CLOUD_SHELL_IMMUTABLE_ANNOTATION,
WEB_TERMINAL_LABEL,
WEB_TERMINAL_RESTRICTED_ACCESS_ANNOTATION,
} from '../cloud-shell-utils';

describe('CloudShell Utils', () => {
Expand All @@ -14,7 +14,7 @@ describe('CloudShell Utils', () => {
expect(newResource.kind).toEqual(kind);
expect(newResource.metadata.name).toEqual(name);
expect(newResource.metadata.namespace).toEqual(namespace);
expect(newResource.metadata.labels[CLOUD_SHELL_LABEL]).toEqual('true');
expect(newResource.metadata.annotations[CLOUD_SHELL_IMMUTABLE_ANNOTATION]).toEqual('true');
expect(newResource.metadata.labels[WEB_TERMINAL_LABEL]).toEqual('true');
expect(newResource.metadata.annotations[WEB_TERMINAL_RESTRICTED_ACCESS_ANNOTATION]).toEqual('true');
});
});
Expand Up @@ -30,9 +30,9 @@ export type CloudShellResource = K8sResourceKind & {

export type TerminalInitData = { pod: string; container: string; cmd: string[] };

export const CLOUD_SHELL_LABEL = 'console.openshift.io/terminal';
export const CLOUD_SHELL_CREATOR_LABEL = 'controller.devfile.io/creator';
export const CLOUD_SHELL_IMMUTABLE_ANNOTATION = 'controller.devfile.io/restricted-access';
export const WEB_TERMINAL_LABEL = 'console.openshift.io/terminal';
export const WEB_TERMINAL_CREATOR_LABEL = 'controller.devfile.io/creator';
export const WEB_TERMINAL_RESTRICTED_ACCESS_ANNOTATION = 'controller.devfile.io/restricted-access';

export const createCloudShellResourceName = () => `terminal-${getRandomChars(6)}`;

Expand All @@ -43,10 +43,10 @@ export const newCloudShellWorkSpace = (name: string, namespace: string): CloudSh
name,
namespace,
labels: {
[CLOUD_SHELL_LABEL]: 'true',
[WEB_TERMINAL_LABEL]: 'true',
},
annotations: {
[CLOUD_SHELL_IMMUTABLE_ANNOTATION]: 'true',
[WEB_TERMINAL_RESTRICTED_ACCESS_ANNOTATION]: 'true',
},
},
spec: {
Expand Down
Expand Up @@ -6,10 +6,10 @@ import {
WatchK8sResult,
} from '@console/internal/components/utils/k8s-watch-hook';
import {
CLOUD_SHELL_LABEL,
CLOUD_SHELL_CREATOR_LABEL,
WEB_TERMINAL_LABEL,
WEB_TERMINAL_CREATOR_LABEL,
CloudShellResource,
CLOUD_SHELL_IMMUTABLE_ANNOTATION,
WEB_TERMINAL_RESTRICTED_ACCESS_ANNOTATION,
startWorkspace,
} from './cloud-shell-utils';
import { useAccessReview2 } from '@console/internal/components/utils';
Expand All @@ -21,7 +21,7 @@ const findWorkspace = (data?: CloudShellResource[]): CloudShellResource | undefi
if (Array.isArray(data)) {
return data.find(
(d) =>
d?.metadata?.annotations?.[CLOUD_SHELL_IMMUTABLE_ANNOTATION] === 'true' &&
d?.metadata?.annotations?.[WEB_TERMINAL_RESTRICTED_ACCESS_ANNOTATION] === 'true' &&
!d?.metadata?.deletionTimestamp,
);
}
Expand Down Expand Up @@ -61,8 +61,8 @@ const useCloudShellWorkspace = (
isList: true,
selector: {
matchLabels: {
[CLOUD_SHELL_LABEL]: 'true',
[CLOUD_SHELL_CREATOR_LABEL]: isKubeAdmin ? '' : uid,
[WEB_TERMINAL_LABEL]: 'true',
[WEB_TERMINAL_CREATOR_LABEL]: isKubeAdmin ? '' : uid,
},
},
};
Expand Down Expand Up @@ -112,8 +112,8 @@ const useCloudShellWorkspace = (
ns: projectName,
labelSelector: {
matchLabels: {
[CLOUD_SHELL_LABEL]: 'true',
[CLOUD_SHELL_CREATOR_LABEL]: isKubeAdmin ? '' : uid,
[WEB_TERMINAL_LABEL]: 'true',
[WEB_TERMINAL_CREATOR_LABEL]: isKubeAdmin ? '' : uid,
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/console-app/src/models/index.ts
Expand Up @@ -10,5 +10,5 @@ export const WorkspaceModel: K8sKind = {
namespaced: true,
crd: true,
plural: 'devworkspaces',
propagationPolicy: 'Foreground',
propagationPolicy: 'Background',
};

0 comments on commit ae9bf77

Please sign in to comment.