Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(artifacts): better default artifact behavior (#4817)
- Loading branch information
Showing
13 changed files
with
227 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ipts/modules/core/src/pipeline/config/triggers/artifacts/docker/defaultDocker.artifact.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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_DOCKER_ARTIFACT = 'spinnaker.core.pipeline.trigger.artifact.defaultDocker'; | ||
module(DEFAULT_DOCKER_ARTIFACT, [ | ||
PIPELINE_CONFIG_PROVIDER, | ||
]).config((pipelineConfigProvider: PipelineConfigProvider) => { | ||
pipelineConfigProvider.registerArtifactKind({ | ||
label: 'Docker', | ||
isDefault: true, | ||
isMatch: false, | ||
description: 'A Docker image to be deployed.', | ||
key: 'default.docker', | ||
controller(artifact: IArtifact) { | ||
'ngInject'; | ||
this.artifact = artifact; | ||
this.artifact.type = 'docker/image'; | ||
|
||
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 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"> | ||
Docker image | ||
<help-field key="pipeline.config.expectedArtifact.defaultDocker.reference"></help-field> | ||
</label> | ||
<div class="col-md-8"> | ||
<input type="text" | ||
placeholder="gcr.io/project/image@sha256:9efcc2818c9..." | ||
class="form-control input-sm" | ||
ng-change="ctrl.onReferenceChange()" | ||
ng-model="ctrl.artifact.reference"/> | ||
</div> | ||
</div> | ||
</div> | ||
`, | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
app/scripts/modules/core/src/pipeline/config/triggers/artifacts/gcs/defaultGcs.artifact.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_GCS_ARTIFACT = 'spinnaker.core.pipeline.trigger.artifact.defaultGcs'; | ||
module(DEFAULT_GCS_ARTIFACT, [ | ||
PIPELINE_CONFIG_PROVIDER, | ||
]).config((pipelineConfigProvider: PipelineConfigProvider) => { | ||
pipelineConfigProvider.registerArtifactKind({ | ||
label: 'GCS', | ||
description: 'A GCS object.', | ||
key: 'default.gcs', | ||
isDefault: true, | ||
isMatch: false, | ||
controller(artifact: IArtifact) { | ||
'ngInject'; | ||
this.artifact = artifact; | ||
this.artifact.type = 'gcs/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.defaultGcs.reference"></help-field> | ||
</label> | ||
<div class="col-md-8"> | ||
<input type="text" | ||
placeholder="gs://bucket/path/to/file" | ||
class="form-control input-sm" | ||
ng-change="ctrl.onReferenceChange()" | ||
ng-model="ctrl.artifact.reference"/> | ||
</div> | ||
</div> | ||
</div> | ||
`, | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ipts/modules/core/src/pipeline/config/triggers/artifacts/github/defaultGithub.artifact.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
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 DEFAULT_GITHUB_ARTIFACT = 'spinnaker.core.pipeline.trigger.artifact.defaultGithub'; | ||
module(DEFAULT_GITHUB_ARTIFACT, [ | ||
PIPELINE_CONFIG_PROVIDER, | ||
]).config((pipelineConfigProvider: PipelineConfigProvider) => { | ||
pipelineConfigProvider.registerArtifactKind({ | ||
label: 'GitHub', | ||
description: 'A file stored in git, hosted by GitHub.', | ||
key: 'default.github', | ||
isDefault: true, | ||
isMatch: false, | ||
controller(artifact: IArtifact) { | ||
'ngInject'; | ||
this.artifact = artifact; | ||
this.artifact.type = 'github/file'; | ||
}, | ||
controllerAs: 'ctrl', | ||
template: ` | ||
<div class="col-md-12"> | ||
<div class="form-group row"> | ||
<label class="col-md-3 sm-label-right"> | ||
Content URL | ||
<help-field key="pipeline.config.expectedArtifact.defaultGithub.reference"></help-field> | ||
</label> | ||
<div class="col-md-8"> | ||
<input type="text" | ||
placeholder="https://api.github.com/repos/$ORG/$REPO/contents/$FILEPATH" | ||
class="form-control input-sm" | ||
ng-model="ctrl.artifact.reference"/> | ||
</div> | ||
</div> | ||
<div class="form-group row"> | ||
<label class="col-md-3 sm-label-right"> | ||
Commit/Branch | ||
<help-field key="pipeline.config.expectedArtifact.defaultGithub.version"></help-field> | ||
</label> | ||
<div class="col-md-3"> | ||
<input type="text" | ||
placeholder="master" | ||
class="form-control input-sm" | ||
ng-model="ctrl.artifact.version"/> | ||
</div> | ||
</div> | ||
</div> | ||
`, | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters