Skip to content

Commit

Permalink
Fix: UI to reflect Template.ArchiveLocation when showing Artifact's b…
Browse files Browse the repository at this point in the history
…ucket in URN (#9351)

* fix: use ArchiveLocation from template in UI

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: use ArchiveLocation from template in UI

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: template archive location on UI

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: S3 location shown in UI needs to reflect Template.ArchiveLocation

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: remove comment

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: artifact visualization reflects correct bucket

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: artifact visualization reflects correct bucket

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: artifact visualization reflects correct bucket

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: formatting

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

* fix: empty commit

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>

Signed-off-by: Julie Vogelman <julie_vogelman@intuit.com>
  • Loading branch information
juliev0 committed Aug 22, 2022
1 parent b7904c4 commit 7d9319b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 5 deletions.
18 changes: 18 additions & 0 deletions ui/src/app/shared/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ export const artifactURN = <A extends Artifact>(a: A, ar: ArtifactRepository) =>
return 'artifact:unknown';
};

export const artifactRepoHasLocation = (ar: ArtifactRepository) => {
if (ar.gcs) {
return ar.gcs.bucket !== '' && ar.gcs.key !== '';
} else if (ar.git) {
return ar.git.repo !== '';
} else if (ar.http) {
return ar.http.url !== '';
} else if (ar.s3) {
return ar.s3.endpoint !== '' && ar.s3.bucket !== '' && ar.s3.key !== '';
} else if (ar.oss) {
return ar.oss.bucket !== '' && ar.oss.endpoint !== '' && ar.oss.key !== '';
} else if (ar.raw) {
return true;
} else if (ar.azure) {
return ar.azure.container !== '' && ar.azure.blob !== '';
}
};

export const artifactKey = <A extends Artifact>(a: A) => {
if (a.gcs) {
return a.gcs.key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as classNames from 'classnames';
import * as React from 'react';
import {useContext, useEffect, useRef, useState} from 'react';
import {RouteComponentProps} from 'react-router';
import {execSpec, Link, NodeStatus, Parameter, Workflow} from '../../../../models';
import {ArtifactRepository, execSpec, Link, NodeStatus, Parameter, Workflow} from '../../../../models';
import {ANNOTATION_KEY_POD_NAME_VERSION} from '../../../shared/annotations';
import {findArtifact} from '../../../shared/artifacts';
import {artifactRepoHasLocation, findArtifact} from '../../../shared/artifacts';
import {uiUrl} from '../../../shared/base';
import {CostOptimisationNudge} from '../../../shared/components/cost-optimisation-nudge';
import {ErrorNotice} from '../../../shared/components/error-notice';
Expand All @@ -18,6 +18,7 @@ import {historyUrl} from '../../../shared/history';
import {getPodName, getTemplateNameFromNode} from '../../../shared/pod-name';
import {RetryWatch} from '../../../shared/retry-watch';
import {services} from '../../../shared/services';
import {getResolvedTemplates} from '../../../shared/template-resolution';
import {useQueryParams} from '../../../shared/use-query-params';
import {useResizableWidth} from '../../../shared/use-resizable-width';
import {useTransition} from '../../../shared/use-transition';
Expand Down Expand Up @@ -68,6 +69,7 @@ export const WorkflowDetails = ({history, location, match}: RouteComponentProps<
const [error, setError] = useState<Error>();
const selectedNode = workflow && workflow.status && workflow.status.nodes && workflow.status.nodes[nodeId];
const selectedArtifact = workflow && workflow.status && findArtifact(workflow.status, nodeId);
const [selectedTemplateArtifactRepo, setSelectedTemplateArtifactRepo] = useState<ArtifactRepository>();
const isSidePanelExpanded = !!(selectedNode || selectedArtifact);
const isSidePanelAnimating = useTransition(isSidePanelExpanded, ANIMATION_MS + ANIMATION_BUFFER_MS);
const {width: sidePanelWidth, dragHandleProps: sidePanelDragHandleProps} = useResizableWidth({
Expand Down Expand Up @@ -101,6 +103,22 @@ export const WorkflowDetails = ({history, location, match}: RouteComponentProps<
);
};

useEffect(() => {
// update the default Artifact Repository for the Template that corresponds to the selectedArtifact
// if there's an ArtifactLocation configured for the Template we use that
// otherwise we use the central one for the Workflow configured in workflow.status.artifactRepositoryRef.artifactRepository
// (Note that individual Artifacts may also override whatever this gets set to)
if (workflow && workflow.status && workflow.status.nodes && selectedArtifact) {
const template = getResolvedTemplates(workflow, workflow.status.nodes[selectedArtifact.nodeId]);
const artifactRepo = template.archiveLocation;
if (artifactRepo && artifactRepoHasLocation(artifactRepo)) {
setSelectedTemplateArtifactRepo(artifactRepo);
} else {
setSelectedTemplateArtifactRepo(workflow.status.artifactRepositoryRef.artifactRepository);
}
}
}, [workflow, selectedArtifact]);

useEffect(() => {
history.push(historyUrl('workflows/{namespace}/{name}', {namespace, name, tab, nodeId, nodePanelView, sidePanel}));
}, [namespace, name, tab, nodeId, nodePanelView, sidePanel]);
Expand Down Expand Up @@ -450,9 +468,7 @@ export const WorkflowDetails = ({history, location, match}: RouteComponentProps<
onResume={() => renderResumePopup()}
/>
)}
{selectedArtifact && (
<ArtifactPanel workflow={workflow} artifact={selectedArtifact} artifactRepository={workflow.status.artifactRepositoryRef.artifactRepository} />
)}
{selectedArtifact && <ArtifactPanel workflow={workflow} artifact={selectedArtifact} artifactRepository={selectedTemplateArtifactRepo} />}
</div>
</div>
))}
Expand Down
26 changes: 26 additions & 0 deletions ui/src/models/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,47 @@ export interface Arguments {
export interface AzureArtifactRepository {
endpoint: string;
container: string;
blob: string;
}
export interface GCSArtifactRepository {
endpoint: string;
bucket: string;
key: string;
}
export interface S3ArtifactRepository {
endpoint: string;
bucket: string;
key: string;
}

export interface OSSArtifactRepository {
endpoint: string;
bucket: string;
key: string;
}

export interface GitArtifactRepository {
repo?: string;
endpoint?: string;
bucket?: string;
}

export interface HTTPArtifactRepository {
url: string;
}

export interface RawArtifactRepository {
data: string;
}

export interface ArtifactRepository {
gcs?: GCSArtifactRepository;
s3?: S3ArtifactRepository;
oss?: OSSArtifactRepository;
azure?: AzureArtifactRepository;
git?: GitArtifactRepository;
http?: HTTPArtifactRepository;
raw?: RawArtifactRepository;
}
export interface ArtifactRepositoryRefStatus {
artifactRepository: ArtifactRepository;
Expand Down Expand Up @@ -440,6 +461,11 @@ export interface Template {
* Sidecars is a list of containers which run alongside the main container Sidecars are automatically killed when the main container completes
*/
sidecars?: UserContainer[];
/**
* archiveLocation is the location in which all files related to the step will be stored (logs, artifacts, etc...).
* Can be overridden by individual items in outputs. If omitted, will use the default
*/
archiveLocation?: ArtifactRepository;
/**
* InitContainers is a list of containers which run before the main container.
*/
Expand Down

0 comments on commit 7d9319b

Please sign in to comment.