@@ -39,24 +39,26 @@ type (
3939
4040 // Build defines Docker build parameters.
4141 Build struct {
42- Remote string // Git remote URL
43- Name string // Docker build using default named tag
44- Dockerfile string // Docker build Dockerfile
45- Context string // Docker build context
46- Tags []string // Docker build tags
47- Args []string // Docker build args
48- ArgsEnv []string // Docker build args from env
49- Target string // Docker build target
50- Squash bool // Docker build squash
51- Pull bool // Docker build pull
52- CacheFrom []string // Docker build cache-from
53- Compress bool // Docker build compress
54- Repo string // Docker build repository
55- LabelSchema []string // label-schema Label map
56- Labels []string // Label map
57- NoCache bool // Docker build no-cache
58- AddHost []string // Docker build add-host
59- Quiet bool // Docker build quiet
42+ Remote string // Git remote URL
43+ Name string // Docker build using default named tag
44+ Dockerfile string // Docker build Dockerfile
45+ Context string // Docker build context
46+ Tags []string // Docker build tags
47+ Args []string // Docker build args
48+ ArgsEnv []string // Docker build args from env
49+ Target string // Docker build target
50+ Squash bool // Docker build squash
51+ Pull bool // Docker build pull
52+ CacheFrom []string // Docker build cache-from
53+ Compress bool // Docker build compress
54+ Repo string // Docker build repository
55+ LabelSchema []string // label-schema Label map
56+ AutoLabel bool // auto-label bool
57+ Labels []string // Label map
58+ Link string // Git repo link
59+ NoCache bool // Docker build no-cache
60+ AddHost []string // Docker build add-host
61+ Quiet bool // Docker build quiet
6062 }
6163
6264 // Plugin defines the Docker plugin parameters.
@@ -252,19 +254,22 @@ func commandBuild(build Build) *exec.Cmd {
252254 args = append (args , "--quiet" )
253255 }
254256
255- labelSchema := []string {
256- "schema-version=1.0" ,
257- fmt .Sprintf ("build-date=%s" , time .Now ().Format (time .RFC3339 )),
258- fmt .Sprintf ("vcs-ref=%s" , build .Name ),
259- fmt .Sprintf ("vcs-url=%s" , build .Remote ),
260- }
257+ if build .AutoLabel {
258+ labelSchema := []string {
259+ fmt .Sprintf ("created=%s" , time .Now ().Format (time .RFC3339 )),
260+ fmt .Sprintf ("revision=%s" , build .Name ),
261+ fmt .Sprintf ("source=%s" , build .Remote ),
262+ fmt .Sprintf ("url=%s" , build .Link ),
263+ }
264+ labelPrefix := "org.opencontainers.image"
261265
262- if len (build .LabelSchema ) > 0 {
263- labelSchema = append (labelSchema , build .LabelSchema ... )
264- }
266+ if len (build .LabelSchema ) > 0 {
267+ labelSchema = append (labelSchema , build .LabelSchema ... )
268+ }
265269
266- for _ , label := range labelSchema {
267- args = append (args , "--label" , fmt .Sprintf ("org.label-schema.%s" , label ))
270+ for _ , label := range labelSchema {
271+ args = append (args , "--label" , fmt .Sprintf ("%s.%s" , labelPrefix , label ))
272+ }
268273 }
269274
270275 if len (build .Labels ) > 0 {
0 commit comments