Skip to content

Commit 9a43ee3

Browse files
ATGardnerdenis-codefresh
authored andcommitted
feat: CR-8697 get artifact by manifest (pull request #107)
Signed-off-by: Denis <[email protected]>
1 parent 9c1a63c commit 9a43ee3

File tree

7 files changed

+1089
-810
lines changed

7 files changed

+1089
-810
lines changed

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

Lines changed: 986 additions & 810 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: 4 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/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"

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
@@ -375,6 +375,8 @@ func (as *argoServer) newHTTPServer(ctx context.Context, port int, artifactServe
375375
mux.HandleFunc("/artifacts-by-uid/", artifactServer.GetOutputArtifactByUID)
376376
mux.HandleFunc("/input-artifacts-by-uid/", artifactServer.GetInputArtifactByUID)
377377
mux.HandleFunc("/artifact-files/", artifactServer.GetArtifactFile)
378+
mux.HandleFunc("/artifacts-by-manifest/", artifactServer.GetOutputArtifactByManifest)
379+
mux.HandleFunc("/input-artifacts-by-manifest/", artifactServer.GetInputArtifactByManifest)
378380
}
379381
mux.Handle("/oauth2/redirect", handlers.ProxyHeaders(http.HandlerFunc(as.oAuth2Service.HandleRedirect)))
380382
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"
@@ -268,6 +269,57 @@ func (a *ArtifactServer) getArtifact(w http.ResponseWriter, r *http.Request, isI
268269
}
269270
}
270271

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

0 commit comments

Comments
 (0)