Skip to content

Commit 783f54d

Browse files
ATGardnerdmaizel
authored andcommitted
feat: CR-8697 get artifact by manifest (pull request #107)
Signed-off-by: Denis <[email protected]>
1 parent 8036b57 commit 783f54d

File tree

7 files changed

+1040
-795
lines changed

7 files changed

+1040
-795
lines changed

pkg/apis/workflow/v1alpha1/generated.pb.go

Lines changed: 936 additions & 794 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/workflow/v1alpha1/generated.proto

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/workflow/v1alpha1/openapi_generated.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/workflow/v1alpha1/workflow_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,10 @@ func (a *Artifact) CleanPath() error {
10241024
return nil
10251025
}
10261026

1027+
type ArtifactByManifestRequest struct {
1028+
Workflow *Workflow `protobuf:"bytes,1,opt,name=workflow" json:"workflow,omitempty"`
1029+
}
1030+
10271031
// PodGC describes how to delete completed pods as they complete
10281032
type PodGC struct {
10291033
// Strategy is the strategy to use. One of "OnPodCompletion", "OnPodSuccess", "OnWorkflowCompletion", "OnWorkflowSuccess". If unset, does not delete Pods

pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/apiserver/argoserver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ func (as *argoServer) newHTTPServer(ctx context.Context, port int, artifactServe
401401
mux.HandleFunc("/artifacts-by-uid/", artifactServer.GetOutputArtifactByUID)
402402
mux.HandleFunc("/input-artifacts-by-uid/", artifactServer.GetInputArtifactByUID)
403403
mux.HandleFunc("/artifact-files/", artifactServer.GetArtifactFile)
404+
mux.HandleFunc("/artifacts-by-manifest/", artifactServer.GetOutputArtifactByManifest)
405+
mux.HandleFunc("/input-artifacts-by-manifest/", artifactServer.GetInputArtifactByManifest)
404406
}
405407
mux.Handle("/oauth2/redirect", handlers.ProxyHeaders(http.HandlerFunc(as.oAuth2Service.HandleRedirect)))
406408
mux.Handle("/oauth2/callback", handlers.ProxyHeaders(http.HandlerFunc(as.oAuth2Service.HandleCallback)))

server/artifacts/artifact_server.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package artifacts
22

33
import (
44
"context"
5+
"encoding/json"
56
"errors"
67
"fmt"
78
"io"
@@ -280,6 +281,57 @@ func (a *ArtifactServer) getArtifact(w http.ResponseWriter, r *http.Request, isI
280281
}
281282
}
282283

284+
func (a *ArtifactServer) GetOutputArtifactByManifest(w http.ResponseWriter, r *http.Request) {
285+
a.getArtifactByManifest(w, r, false)
286+
}
287+
288+
func (a *ArtifactServer) GetInputArtifactByManifest(w http.ResponseWriter, r *http.Request) {
289+
a.getArtifactByManifest(w, r, true)
290+
}
291+
292+
func (a *ArtifactServer) getArtifactByManifest(w http.ResponseWriter, r *http.Request, isInput bool) {
293+
294+
var req wfv1.ArtifactByManifestRequest
295+
err := json.NewDecoder(r.Body).Decode(&req)
296+
if err != nil {
297+
a.serverInternalError(err, w)
298+
return
299+
}
300+
301+
wf := req.Workflow
302+
if wf == nil {
303+
a.serverInternalError(err, w)
304+
return
305+
}
306+
307+
ctx, err := a.gateKeeping(r, types.NamespaceHolder(wf.GetNamespace()))
308+
if err != nil {
309+
w.WriteHeader(401)
310+
_, _ = w.Write([]byte(err.Error()))
311+
return
312+
}
313+
314+
uid := wf.UID
315+
path := strings.SplitN(r.URL.Path, "/", 6)
316+
nodeId := path[2]
317+
artifactName := path[3]
318+
319+
log.WithFields(log.Fields{"uid": uid, "nodeId": nodeId, "artifactName": artifactName, "isInput": isInput}).Info("Download artifact by manifest")
320+
321+
art, driver, err := a.getArtifactAndDriver(ctx, nodeId, artifactName, isInput, wf, nil)
322+
if err != nil {
323+
a.serverInternalError(err, w)
324+
return
325+
}
326+
327+
err = a.returnArtifact(w, art, driver)
328+
329+
if err != nil {
330+
a.serverInternalError(err, w)
331+
return
332+
}
333+
}
334+
283335
func (a *ArtifactServer) GetOutputArtifactByUID(w http.ResponseWriter, r *http.Request) {
284336
a.getArtifactByUID(w, r, false)
285337
}

0 commit comments

Comments
 (0)