@@ -108,6 +108,9 @@ type UserArtifactsClient interface {
108
108
// Upload artifact into the artifacts repository.
109
109
// Artifacts are identified by their SHA256 checksum in the artifacts repository
110
110
UploadArtifact (filename string ) error
111
+ // Extract artifact into the artifacts repository.
112
+ // Artifacts are identified by their SHA256 checksum in the artifacts repository
113
+ ExtractArtifact (filename string ) error
111
114
// Creates a directory in the host where user artifacts can be uploaded to.
112
115
CreateUploadDir () (string , error )
113
116
// Uploads file into the given directory.
@@ -590,6 +593,24 @@ func (c *HostOrchestratorClientImpl) ExtractFile(uploadDir string, filename stri
590
593
return result , nil
591
594
}
592
595
596
+ func (c * HostOrchestratorClientImpl ) ExtractArtifact (filename string ) (* hoapi.Operation , error ) {
597
+ checksum , err := sha256Checksum (filename )
598
+ if err != nil {
599
+ return err
600
+ }
601
+ path := "/v1/userartifacts/" + checksum + "_extracted"
602
+ res := & hoapi.StatArtifactResponse {}
603
+ // Early return if the artifact already exist.
604
+ if err := c .HTTPHelper .NewGetRequest (path ).JSONResDo (res ); err == nil {
605
+ return nil
606
+ }
607
+ rb := c .HTTPHelper .NewPostRequest ("/v1/userartifacts/" + checksum + "/:extract" , nil )
608
+ if err := rb .JSONResDo (result ); err != nil {
609
+ return nil , err
610
+ }
611
+ return result , nil
612
+ }
613
+
593
614
func (c * HostOrchestratorClientImpl ) CreateBugReport (group string , opts CreateBugReportOpts , dst io.Writer ) error {
594
615
op := & hoapi.Operation {}
595
616
path := "/cvds/" + group + "/:bugreport"
0 commit comments