Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(KONFLUX-5721): change workspace to namespace for release and do not append suffix to namespace #53

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const ReleasePlanForm: React.FC<Props> = ({
/>
<ApplicationDropdown
name="application"
helpText="The application you want to release to the environments in your target workspace."
helpText="The application you want to release to the environments in your target namespace."
required
/>
<RunReleasePipelineSection />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const GitOptions: React.FC<{ required?: boolean }> = ({ required = false }) => {
export const RunReleasePipelineSection: React.FC = () => {
const [{ value: pipelineLocation }] =
useField<ReleasePipelineLocation>('releasePipelineLocation');
const { workspace } = useWorkspaceInfo();
const { namespace } = useWorkspaceInfo();

return (
<>
Expand All @@ -58,9 +58,9 @@ export const RunReleasePipelineSection: React.FC = () => {
options={[
{
value: ReleasePipelineLocation.current,
label: `In this workspace: ${workspace}`,
label: `In this namespace: ${namespace}`,
},
{ value: ReleasePipelineLocation.target, label: 'In a target workspace' },
{ value: ReleasePipelineLocation.target, label: 'In a target namespace' },
]}
required
/>
Expand Down Expand Up @@ -110,12 +110,12 @@ export const RunReleasePipelineSection: React.FC = () => {
<>
<InputField
name="target"
label="Target workspace"
helperText="Type the workspace name that you would like the selected application to be released to"
label="Target namespace"
helperText="Type the namespace name that you would like the selected application to be released to."
labelIcon={
<HelpPopover
headerContent="Target workspace"
bodyContent="Your application will be released to the environments in this workspace."
headerContent="Target namespace"
bodyContent="Your application will be released to the environments in this namespace."
/>
}
required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('ReleasePlanForm', () => {
expect(result.getByRole('heading', { name: 'Create release plan' })).toBeVisible();
expect(result.getByRole('button', { name: 'Create' })).toBeVisible();
expect(result.getByRole('button', { name: 'Create' })).toBeVisible();
expect(result.getByRole('radio', { name: 'In this workspace: test-ws' })).toBeVisible();
expect(result.getByRole('radio', { name: 'In a target workspace' })).toBeVisible();
expect(result.getByRole('radio', { name: 'In this namespace: test-ns' })).toBeVisible();
expect(result.getByRole('radio', { name: 'In a target namespace' })).toBeVisible();
expect(result.getByRole('checkbox', { name: 'Auto release' })).toBeVisible();
expect(result.getByRole('checkbox', { name: 'Standing attribution' })).toBeVisible();
expect(result.getByRole('textbox', { name: 'Release plan name' })).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('RunReleasePipelineSection', () => {
expect(
result.getByRole('region', { name: 'Git options for the release pipeline' }),
).toBeVisible();
expect(result.getByRole('textbox', { name: 'Target workspace' })).toBeVisible();
expect(result.getByRole('textbox', { name: 'Target namespace' })).toBeVisible();
expect(result.getByRole('textbox', { name: 'Data' })).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('createReleasePlan', () => {
k8sUpdateMock.mockImplementation((obj) => obj.resource);
});

it('should use active workspace for current release pipeline location', async () => {
it('should use active namespace for current release pipeline location', async () => {
const result = await createReleasePlan(
{
name: 'test-plan',
Expand All @@ -32,8 +32,8 @@ describe('createReleasePlan', () => {
path: '/',
},
},
'test-ns',
'test-ws',
'test-ns-tenant',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reasoning for renaming this?

'test-ws-tenant',
);
expect(result).toEqual(
expect.objectContaining({
Expand All @@ -43,7 +43,7 @@ describe('createReleasePlan', () => {
'release.appstudio.openshift.io/standing-attribution': 'false',
},
name: 'test-plan',
namespace: 'test-ns',
namespace: 'test-ns-tenant',
},
spec: {
application: 'test-app',
Expand All @@ -64,7 +64,7 @@ describe('createReleasePlan', () => {
],
resolver: 'git',
},
target: 'test-ws-tenant',
target: 'test-ns-tenant',
},
}),
);
Expand All @@ -75,7 +75,7 @@ describe('createReleasePlan', () => {
{
name: 'test-plan',
application: 'test-app',
target: 'target-ws',
target: 'target-ws-tenant',
releasePipelineLocation: ReleasePipelineLocation.target,
labels: [],
params: [],
Expand All @@ -85,8 +85,8 @@ describe('createReleasePlan', () => {
path: '/',
},
},
'test-ns',
'test-ws',
'test-ns-tenant',
'test-ws-tenant',
);
expect(result).toEqual(
expect.objectContaining({
Expand Down Expand Up @@ -131,8 +131,8 @@ describe('createReleasePlan', () => {
path: '/',
},
},
'test-ns',
'test-ws',
'test-ns-tenant',
'test-ws-tenant',
);
expect(result.metadata.labels).toEqual({
'release.appstudio.openshift.io/auto-release': 'true',
Expand All @@ -154,8 +154,8 @@ describe('createReleasePlan', () => {
path: '/',
},
},
'test-ns',
'test-ws',
'test-ns-tenant',
'test-ws-tenant',
);
expect(result.metadata.labels).toEqual({
'release.appstudio.openshift.io/auto-release': 'true',
Expand All @@ -182,7 +182,7 @@ describe('editReleasePlan', () => {
path: '/',
},
},
'my-ws',
'my-ws-tenant',
);

expect(result.spec.target).toBe('my-ws-tenant');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export enum ReleasePipelineLocation {
target,
}

const WORKSPACE_SUFFIX = 'tenant';

export type ReleasePlanFormValues = {
name: string;
application: string;
Expand Down Expand Up @@ -88,7 +86,7 @@ export const createReleasePlan = async (
autoRelease,
standingAttribution,
} = values;
const targetWs = releasePipelineLocation === ReleasePipelineLocation.current ? workspace : target;
const targetNs = releasePipelineLocation === ReleasePipelineLocation.current ? namespace : target;
const labels = labelPairs
.filter((l) => !!l.key)
.reduce((acc, o) => ({ ...acc, [o.key]: o.value }), {} as Record<string, string>);
Expand All @@ -110,7 +108,7 @@ export const createReleasePlan = async (
application,
...(data ? { data } : {}),
serviceAccount,
target: `${targetWs}-${WORKSPACE_SUFFIX}`,
target: `${targetNs}`,
pipelineRef: {
resolver: ResolverType.GIT,
params: [
Expand Down Expand Up @@ -152,7 +150,7 @@ export const editReleasePlan = async (
autoRelease,
standingAttribution,
} = values;
const targetWs = releasePipelineLocation === ReleasePipelineLocation.current ? workspace : target;
const targetNs = releasePipelineLocation === ReleasePipelineLocation.current ? workspace : target;
const labels = labelPairs
.filter((l) => !!l.key)
.reduce((acc, o) => ({ ...acc, [o.key]: o.value }), {} as Record<string, string>);
Expand All @@ -175,7 +173,7 @@ export const editReleasePlan = async (
application,
...(data ? { data } : {}),
serviceAccount,
target: `${targetWs}-${WORKSPACE_SUFFIX}`,
target: `${targetNs}`,
pipelineRef: {
resolver: ResolverType.GIT,
params: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ReleasePlanListHeader = () => {
props: { className: releasesPlanTableColumnClasses.application },
},
{
title: 'Target Workspace',
title: 'Target Namespace',
props: { className: releasesPlanTableColumnClasses.target },
},
{
Expand Down
Loading