argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
14.96k stars 3.19k forks source link

Support remote script source in the script template #2980

Open VaibhavPage opened 4 years ago

VaibhavPage commented 4 years ago

Summary

Support an option to fetch the script source in ScriptTemplate from Git, an URL, or S3.

Motivation

Placing the script source directly in the workflow definition makes it difficult to manage and it loses ability to refer to a particular version of the script. With Git or S3 as a source, the developer can test the code in some interactive environment like Jupter notebook, push code to git and then refer it in a workflow. It also facilitates the dev teams to easily share the workflows.

Proposal

Introduce a struct called ScriptSource,

type ScriptSource struct {
    // Inline source - currently supported.
    Inline string
    // GitArtifact from the pkg/workflow_types.go
    Git *GitArtifact
    // S3Artifact from the pkg/workflow_types.go
    S3 *S3Artifact
    // A url like raw.github...
    URL string
}

And change the ScriptTemplate struct to,

// ScriptTemplate is a template subtype to enable scripting through code steps
type ScriptTemplate struct {
    apiv1.Container `json:",inline" protobuf:"bytes,1,opt,name=container"`

    // Source contains the source code of the script to execute
    Source ScriptSource `json:"source" protobuf:"bytes,2,opt,name=source"`
}

Message from the maintainers:

If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.

VaibhavPage commented 4 years ago

@jessesuen @sarabala1979 @simster7 thoughts?

sarabala1979 commented 4 years ago

I think there is workaround to achieve the same functionality using container template with kubectl image.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: resource-delete-with-flags-
spec:
  entrypoint: create-configmap
  templates:
  - name: create-configmap
    inputs:
      artifacts:
      - name: argo-source
        path: /src
        git:
          repo: https://github.com/argoproj/argo.git
          revision: "v2.1.1"  
        container:
         image: bitnami/kubectl
         command: ["create"]
         args: ["-f  /src/argoproj/argo/manifests/install.yaml"]

If we need first class support for this. I would recommend using Input Artifacts instead of introducing new struct.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: resource-delete-with-flags-
spec:
  entrypoint: create-configmap
  templates:
  - name: create-configmap
    inputs:
      artifacts:
      - name: argo-source
        path: /src
        git:
          repo: https://github.com/argoproj/argo.git
          revision: "v2.1.1"  
    resource:
      action: create
      manifestPath: "/src/argoproj/argo/manifests/install.yaml"
andizzle commented 4 years ago

Is manifestPath available? I can't seem to find it in the doc.