Add copy field

Initial implementation that just works with standard docker image
references

Related: #190
This commit is contained in:
Ettore Di Giacinto
2021-05-07 22:10:52 +02:00
parent 77b49d9c4a
commit 1e617b0c67

View File

@@ -16,6 +16,7 @@
package compilerspec package compilerspec
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"path/filepath" "path/filepath"
@@ -85,6 +86,13 @@ func (specs *LuetCompilationspecs) Unique() *LuetCompilationspecs {
return &newSpecs return &newSpecs
} }
type CopyField struct {
Package *pkg.DefaultPackage `json:"package"`
Image string `json:"image"`
Source string `json:"src"`
Destination string `json:"dst"`
}
type LuetCompilationSpec struct { type LuetCompilationSpec struct {
Steps []string `json:"steps"` // Are run inside a container and the result layer diff is saved Steps []string `json:"steps"` // Are run inside a container and the result layer diff is saved
Env []string `json:"env"` Env []string `json:"env"`
@@ -103,6 +111,8 @@ type LuetCompilationSpec struct {
Excludes []string `json:"excludes"` Excludes []string `json:"excludes"`
BuildOptions *options.Compiler `json:"build_options"` BuildOptions *options.Compiler `json:"build_options"`
Copy []CopyField `json:"copy"`
} }
func NewLuetCompilationSpec(b []byte, p pkg.Package) (*LuetCompilationSpec, error) { func NewLuetCompilationSpec(b []byte, p pkg.Package) (*LuetCompilationSpec, error) {
@@ -256,6 +266,12 @@ ADD ` + s + ` /luetbuild/`
} }
} }
for _, c := range cs.Copy {
if c.Image != "" {
spec = spec + fmt.Sprintf("\nCOPY --from=%s %s %s\n", c.Image, c.Source, c.Destination)
}
}
for _, s := range cs.Env { for _, s := range cs.Env {
spec = spec + ` spec = spec + `
ENV ` + s ENV ` + s