api: implement /compose/delete route

This commit is contained in:
Ondřej Budai 2019-12-06 16:56:22 +01:00 committed by Lars Karlitski
parent 6d15833e4e
commit 6bbc89d5f3
4 changed files with 136 additions and 4 deletions

View file

@ -99,10 +99,13 @@ func (job *Job) Run(d distro.Distro) (*store.Image, error, []error) {
for _, t := range job.Targets {
switch options := t.Options.(type) {
case *target.LocalTargetOptions:
cp := exec.Command("cp", "-a", "-L", "/var/cache/osbuild-composer/store/refs/"+result.OutputID+"/.", options.Location)
cp.Stderr = os.Stderr
cp.Stdout = os.Stdout
err = cp.Run()
err = runCommand("cp", "-a", "-L", "/var/cache/osbuild-composer/store/refs/"+result.OutputID+"/.", options.Location)
if err != nil {
r = append(r, err)
continue
}
err = runCommand("chown", "-R", "_osbuild-composer:_osbuild-composer", options.Location)
if err != nil {
r = append(r, err)
continue
@ -158,3 +161,10 @@ func (job *Job) Run(d distro.Distro) (*store.Image, error, []error) {
return &image, nil, r
}
func runCommand(command string, params ...string) error {
cp := exec.Command(command, params...)
cp.Stderr = os.Stderr
cp.Stdout = os.Stdout
return cp.Run()
}