summaryrefslogtreecommitdiff
path: root/actions/pack_action.go
blob: b8f28a79095f1ecce4578d8be8249ba0a15160a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
Pack Action

Create tarball with filesystem.

Yaml syntax:
 - action: pack
   file: filename.ext
   compression: gz

Mandatory properties:

- file -- name of the output tarball, relative to the artifact directory.

- compression -- compression type to use. Only 'gz' is supported at the moment.

*/
package actions

import (
	"log"
	"path"

	"github.com/go-debos/debos"
)

type PackAction struct {
	debos.BaseAction `yaml:",inline"`
	Compression      string
	File             string
}

func (pf *PackAction) Run(context *debos.DebosContext) error {
	pf.LogStart()
	outfile := path.Join(context.Artifactdir, pf.File)

	log.Printf("Compressing to %s\n", outfile)
	return debos.Command{}.Run("Packing", "tar", "czf", outfile,
		"--xattrs", "--xattrs-include=*.*",
		"-C", context.Rootdir, ".")
}