Skip to content

Commit

Permalink
feat(artifacts) Implement S3 artifacts (#5099)
Browse files Browse the repository at this point in the history
* Implement S3 pipeline artifact

* Add corresponding help text

* remove copyright
  • Loading branch information
benjaminws authored and Scott Bloch-Wehba-Seaward committed Apr 2, 2018
1 parent c7d9711 commit c119e9d
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/scripts/modules/core/src/help/help.contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ module(HELP_CONTENTS, [])
<p>The GCS object name, in the form <code>gs://bucket/path/to/file.yml</code>.</p>`,
'pipeline.config.expectedArtifact.defaultGcs.reference': `
<p>The GCS object name, <i>optionally</i> appending the version. An example: <code>gs://bucket/file.yml#123948581</code></p>`,
'pipeline.config.expectedArtifact.s3.name': `
<p>The S3 object name, in the form <code>s3://bucket/path/to/file.yml</code>.</p>`,
'pipeline.config.expectedArtifact.defaultS3.reference': `
<p>The S3 object name, <i>optionally</i> appending the version. An example: <code>s3://bucket/file.yml#123948581</code></p>`,
'pipeline.config.expectedArtifact.docker.name': `
<p>The Docker image name you want to trigger on changes to. By default, this does <i>not</i> include the image tag or digest, only the registry and image repository.</p>`,
'pipeline.config.expectedArtifact.defaultDocker.reference': `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { ARTIFACT } from './artifact.component';
import { GITHUB_ARTIFACT } from 'core/pipeline/config/triggers/artifacts/github/github.artifact';
import { BASE64_ARTIFACT } from 'core/pipeline/config/triggers/artifacts/base64/base64.artifact';
import { DEFAULT_BASE64_ARTIFACT } from 'core/pipeline/config/triggers/artifacts/base64/defaultBase64.artifact';
import { S3_ARTIFACT } from 'core/pipeline/config/triggers/artifacts/s3/s3.artifact';
import { DEFAULT_S3_ARTIFACT } from 'core/pipeline/config/triggers/artifacts/s3/defaultS3.artifact';

export const ARTIFACT_MODULE = 'spinnaker.core.pipeline.config.trigger.artifacts';

Expand All @@ -21,6 +23,8 @@ module(ARTIFACT_MODULE, [
GITHUB_ARTIFACT,
DOCKER_ARTIFACT,
BASE64_ARTIFACT,
S3_ARTIFACT,
DEFAULT_S3_ARTIFACT,
DEFAULT_DOCKER_ARTIFACT,
DEFAULT_GCS_ARTIFACT,
DEFAULT_GITHUB_ARTIFACT,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { module } from 'angular';

import { PIPELINE_CONFIG_PROVIDER } from 'core/pipeline/config/pipelineConfigProvider';
import { IArtifact } from 'core/domain/IArtifact';
import { PipelineConfigProvider } from 'core/pipeline';
import { isNil } from 'lodash';

export const DEFAULT_S3_ARTIFACT = 'spinnaker.core.pipeline.trigger.artifact.defaultS3';
module(DEFAULT_S3_ARTIFACT, [
PIPELINE_CONFIG_PROVIDER,
]).config((pipelineConfigProvider: PipelineConfigProvider) => {
pipelineConfigProvider.registerArtifactKind({
label: 'S3',
description: 'A S3 object.',
key: 'default.s3',
isDefault: true,
isMatch: false,
controller(artifact: IArtifact) {
'ngInject';
this.artifact = artifact;
this.artifact.type = 's3/object';

this.onReferenceChange = () => {
const ref = this.artifact.reference;
if (isNil(ref)) {
return;
}

if (ref.indexOf('#') >= 0) {
const split = ref.split('#');
this.artifact.name = split[0];
this.artifact.version = split[1];
} else {
this.artifact.name = ref;
}
};
},
controllerAs: 'ctrl',
template: `
<div class="col-md-12">
<div class="form-group row">
<label class="col-md-2 sm-label-right">
Object path
<help-field key="pipeline.config.expectedArtifact.defaultS3.reference"></help-field>
</label>
<div class="col-md-8">
<input type="text"
placeholder="s3://bucket/path/to/file"
class="form-control input-sm"
ng-change="ctrl.onReferenceChange()"
ng-model="ctrl.artifact.reference"/>
</div>
</div>
</div>
`,
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { module } from 'angular';

import { PIPELINE_CONFIG_PROVIDER } from 'core/pipeline/config/pipelineConfigProvider';
import { IArtifact } from 'core/domain/IArtifact';
import { PipelineConfigProvider } from 'core/pipeline';

export const S3_ARTIFACT = 'spinnaker.core.pipeline.trigger.s3.artifact';
module(S3_ARTIFACT, [
PIPELINE_CONFIG_PROVIDER,
]).config((pipelineConfigProvider: PipelineConfigProvider) => {
pipelineConfigProvider.registerArtifactKind({
label: 'S3',
description: 'An S3 object.',
key: 's3',
isDefault: false,
isMatch: true,
controller(artifact: IArtifact) {
'ngInject';
this.artifact = artifact;
this.artifact.type = 's3/object';
},
controllerAs: 'ctrl',
template: `
<div class="col-md-12">
<div class="form-group row">
<label class="col-md-2 sm-label-right">
Object path
<help-field key="pipeline.config.expectedArtifact.s3.name"></help-field>
</label>
<div class="col-md-8">
<input type="text"
placeholder="s3://bucket/path/to/file"
class="form-control input-sm"
ng-model="ctrl.artifact.name"/>
</div>
</div>
</div>
`,
});
});

0 comments on commit c119e9d

Please sign in to comment.