Commit 6263756f authored by Kamil Trzciński's avatar Kamil Trzciński

Support RAW artifacts

parent e3390813
Pipeline #32986336 passed with stages
in 29 minutes and 41 seconds
......@@ -41,6 +41,24 @@ func (c *ArtifactsUploaderCommand) generateGzipStream(w *io.PipeWriter) {
w.CloseWithError(err)
}
func (c *ArtifactsUploaderCommand) generateRawStream(w *io.PipeWriter) {
if len(c.sortedFiles()) > 1 {
w.CloseWithError(errors.New("only single file supported"))
return
}
fileName := c.sortedFiles()[0]
file, err := os.Open(fileName)
if err != nil {
w.CloseWithError(err)
return
}
defer file.Close()
_, err = io.Copy(w, file)
w.CloseWithError(err)
}
func (c *ArtifactsUploaderCommand) createReadStream() (string, io.ReadCloser, error) {
if len(c.files) == 0 {
return "", nil, nil
......@@ -62,6 +80,11 @@ func (c *ArtifactsUploaderCommand) createReadStream() (string, io.ReadCloser, er
go c.generateGzipStream(pw)
return name + ".gz", pr, nil
case common.ArtifactFormatRaw:
pr, pw := io.Pipe()
go c.generateRawStream(pw)
return name, pr, nil
default:
return "", nil, fmt.Errorf("unsupported archive format: %s", c.Format)
}
......
......@@ -207,6 +207,7 @@ const (
ArtifactFormatDefault ArtifactFormat = ""
ArtifactFormatZip ArtifactFormat = "zip"
ArtifactFormatGzip ArtifactFormat = "gzip"
ArtifactFormatRaw ArtifactFormat = "raw"
)
type Artifact struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment