Skip to content

Commit

Permalink
Introduce s3, git, http artifact sources in inputs.artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesuen committed Oct 25, 2017
1 parent a68001d commit 1037209
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 18 deletions.
67 changes: 49 additions & 18 deletions api/workflow/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ type Workflow struct {
Status WorkflowStatus `json:"status"`
}

type WorkflowList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Workflow `json:"items"`
}

type WorkflowSpec struct {
Templates []Template `json:"templates"`
Entrypoint string `json:"entrypoint"`
Expand All @@ -62,12 +68,6 @@ type Template struct {
*corev1.Container
}

type WorkflowList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Workflow `json:"items"`
}

// Inputs are the mechanism for passing parameters, artifacts, volumes from one template to another
type Inputs struct {
Parameters map[string]*InputParameter `json:"parameters,omitempty"`
Expand All @@ -76,26 +76,33 @@ type Inputs struct {

// InputParameter indicate a passed string parameter to a service template with an optional default value
type InputParameter struct {
Default *string `json:"default,omitempty"`
Options []interface{} `json:"options,omitempty"` // TODO: implement validation
Regex string `json:"regex,omitempty"` // TODO: implement validation
Default *string `json:"default,omitempty"`
}

// InputArtifact indicates a passed string parameter to a service template with an optional default value
// InputArtifact indicates an artifact to place at a specified path
type InputArtifact struct {
From string `json:"from,omitempty"`
Path string `json:"path,omitempty"`
Path string `json:"path,omitempty"`
S3 *S3ArtifactSource `json:"s3,omitempty"`
Git *GitArtifactSource `json:"git,omitempty"`
HTTP *HTTPArtifactSource `json:"http,omitempty"`
}

type Outputs struct {
Artifacts OutputArtifacts `json:"artifacts,omitempty"`
Artifacts OutputArtifacts `json:"artifacts,omitempty"`
Parameters OutputParameters `json:"parameters,omitempty"`
}

type OutputArtifacts map[string]OutputArtifact

type OutputArtifact struct {
Path string `json:"path,omitempty"`
Destination *ArtifactDestination `json:"destination,omitempty"`
}

type OutputParameters map[string]OutputParameter

type OutputParameter struct {
Path string `json:"path,omitempty"`
From string `json:"from,omitempty"`
}

// WorkflowStep is either a template ref, an inlined container, with added flags
Expand All @@ -120,10 +127,10 @@ type NodeTree struct {
}

type NodeStatus struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Outputs map[string]interface{} `json:"outputs"`
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Outputs Outputs `json:"outputs"`
//ReturnCode *int `json:"returnCode"`
}

Expand All @@ -146,3 +153,27 @@ func (n NodeStatus) Completed() bool {
func (n NodeStatus) Successful() bool {
return n.Status == NodeStatusSucceeded
}

type S3ArtifactSource struct {
Endpoint string `json:"endpoint"`
Bucket string `json:"bucket"`
Key string `json:"key"`
AccessKeySecret corev1.SecretKeySelector `json:"accessKeySecret"`
SecretKey corev1.SecretKeySelector `json:"secretKeySecret"`
}

type GitArtifactSource struct {
URL string `json:"url"`
UsernameSecret *corev1.SecretKeySelector `json:"usernameSecret"`
PasswordSecret *corev1.SecretKeySelector `json:"passwordSecret"`
}

type HTTPArtifactSource struct {
URL string `json:"url"`
}

type ArtifactDestination struct {
S3 *S3ArtifactDestination `json:"s3,omitempty"`
}

type S3ArtifactDestination S3ArtifactSource
18 changes: 18 additions & 0 deletions examples/git-artifact.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: argoproj.io/v1
kind: Workflow
metadata:
generateName: argo-wf-
spec:
entrypoint: git-clone
templates:
- name: git-clone
type: container
inputs:
artifacts:
CODE:
path: /src
git:
url: https://github.com/argoproj/argo
image: golang:1.8
command: [sh, -c]
args: ["cd /src; git status"]
26 changes: 26 additions & 0 deletions examples/s3-artifact.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: argoproj.io/v1
kind: Workflow
metadata:
generateName: argo-wf-
spec:
entrypoint: git-clone
templates:
- name: git-clone
type: container
inputs:
artifacts:
CODE:
path: /src
s3:
endpoint: https://storage.googleapis.com
bucket: my-bucket-name
key: path/in/bucket
accessKeySecret:
name: my-s3-credentials
key: accessKey
secretKeySecret:
name: my-s3-credentials
key: secretKey
image: golang:1.8
command: [sh, -c]
args: ["cd /src; git status"]
2 changes: 2 additions & 0 deletions examples/workflow-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
template: cowsay
- PRINT:
template: print-message
arguments:
artifacts.MESSAGE: "{{steps.COWSAY.outputs.artifacts.MESSAGE}}"
- name: cowsay
type: container
image: docker/whalesay:latest
Expand Down

0 comments on commit 1037209

Please sign in to comment.