Skip to content

Commit

Permalink
feat: CR-8697 get artifact by manifest (pull request #107)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis <[email protected]>
  • Loading branch information
ATGardner authored and dmaizel committed Dec 10, 2024
1 parent 8036b57 commit 783f54d
Show file tree
Hide file tree
Showing 7 changed files with 1,040 additions and 795 deletions.
1,730 changes: 936 additions & 794 deletions pkg/apis/workflow/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion pkg/apis/workflow/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/apis/workflow/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/apis/workflow/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,10 @@ func (a *Artifact) CleanPath() error {
return nil
}

type ArtifactByManifestRequest struct {
Workflow *Workflow `protobuf:"bytes,1,opt,name=workflow" json:"workflow,omitempty"`
}

// PodGC describes how to delete completed pods as they complete
type PodGC struct {
// Strategy is the strategy to use. One of "OnPodCompletion", "OnPodSuccess", "OnWorkflowCompletion", "OnWorkflowSuccess". If unset, does not delete Pods
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions server/apiserver/argoserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ func (as *argoServer) newHTTPServer(ctx context.Context, port int, artifactServe
mux.HandleFunc("/artifacts-by-uid/", artifactServer.GetOutputArtifactByUID)
mux.HandleFunc("/input-artifacts-by-uid/", artifactServer.GetInputArtifactByUID)
mux.HandleFunc("/artifact-files/", artifactServer.GetArtifactFile)
mux.HandleFunc("/artifacts-by-manifest/", artifactServer.GetOutputArtifactByManifest)
mux.HandleFunc("/input-artifacts-by-manifest/", artifactServer.GetInputArtifactByManifest)
}
mux.Handle("/oauth2/redirect", handlers.ProxyHeaders(http.HandlerFunc(as.oAuth2Service.HandleRedirect)))
mux.Handle("/oauth2/callback", handlers.ProxyHeaders(http.HandlerFunc(as.oAuth2Service.HandleCallback)))
Expand Down
52 changes: 52 additions & 0 deletions server/artifacts/artifact_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package artifacts

import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -280,6 +281,57 @@ func (a *ArtifactServer) getArtifact(w http.ResponseWriter, r *http.Request, isI
}
}

func (a *ArtifactServer) GetOutputArtifactByManifest(w http.ResponseWriter, r *http.Request) {
a.getArtifactByManifest(w, r, false)
}

func (a *ArtifactServer) GetInputArtifactByManifest(w http.ResponseWriter, r *http.Request) {
a.getArtifactByManifest(w, r, true)
}

func (a *ArtifactServer) getArtifactByManifest(w http.ResponseWriter, r *http.Request, isInput bool) {

var req wfv1.ArtifactByManifestRequest
err := json.NewDecoder(r.Body).Decode(&req)
if err != nil {
a.serverInternalError(err, w)
return
}

wf := req.Workflow
if wf == nil {
a.serverInternalError(err, w)
return
}

ctx, err := a.gateKeeping(r, types.NamespaceHolder(wf.GetNamespace()))
if err != nil {
w.WriteHeader(401)
_, _ = w.Write([]byte(err.Error()))
return
}

uid := wf.UID
path := strings.SplitN(r.URL.Path, "/", 6)
nodeId := path[2]
artifactName := path[3]

log.WithFields(log.Fields{"uid": uid, "nodeId": nodeId, "artifactName": artifactName, "isInput": isInput}).Info("Download artifact by manifest")

art, driver, err := a.getArtifactAndDriver(ctx, nodeId, artifactName, isInput, wf, nil)
if err != nil {
a.serverInternalError(err, w)
return
}

err = a.returnArtifact(w, art, driver)

if err != nil {
a.serverInternalError(err, w)
return
}
}

func (a *ArtifactServer) GetOutputArtifactByUID(w http.ResponseWriter, r *http.Request) {
a.getArtifactByUID(w, r, false)
}
Expand Down

0 comments on commit 783f54d

Please sign in to comment.