Skip to content

Commit 931bc9f

Browse files
author
Ramkumar Chinchani
committed
feat!: drop support for '->' artwork
BREAKING CHANGE: '->' artwork syntax is dropped so older "bind:" directives will break, so users need to migrate/fix. stacker syntax uses a strange mix of yaml and artwork such as '->', for example in "bind:" directive. This PR makes it normal declarative yaml. Signed-off-by: Ramkumar Chinchani <[email protected]>
1 parent 479fca8 commit 931bc9f

File tree

2 files changed

+2
-78
lines changed

2 files changed

+2
-78
lines changed

build.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ build:
7979
type: built
8080
tag: build-env
8181
binds:
82-
- . -> /stacker-tree
82+
- source: .
83+
dest: /stacker-tree
8384
run: |
8485
#!/bin/sh
8586
# golang wants somewhere to put its garbage

pkg/types/layer.go

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package types
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"io/fs"
76
"os"
@@ -192,82 +191,6 @@ type Bind struct {
192191

193192
type Binds []Bind
194193

195-
func (bs *Bind) MarshalJSON() ([]byte, error) {
196-
var sb strings.Builder
197-
if bs.Dest == "" {
198-
sb.WriteString(fmt.Sprintf("%q", bs.Source))
199-
} else {
200-
var sbt strings.Builder
201-
sbt.WriteString(fmt.Sprintf("%s -> %s", bs.Source, bs.Dest))
202-
sb.WriteString(fmt.Sprintf("%q", sbt.String()))
203-
}
204-
205-
return []byte(sb.String()), nil
206-
}
207-
208-
func (bs *Binds) UnmarshalJSON(data []byte) error {
209-
var rawBinds []string
210-
211-
if err := json.Unmarshal(data, &rawBinds); err != nil {
212-
return err
213-
}
214-
215-
*bs = Binds{}
216-
for _, bind := range rawBinds {
217-
parts := strings.Split(bind, "->")
218-
if len(parts) != 1 && len(parts) != 2 {
219-
return errors.Errorf("invalid bind mount %s", bind)
220-
}
221-
222-
source := strings.TrimSpace(parts[0])
223-
target := source
224-
225-
if len(parts) == 2 {
226-
target = strings.TrimSpace(parts[1])
227-
}
228-
229-
*bs = append(*bs, Bind{Source: source, Dest: target})
230-
}
231-
232-
return nil
233-
}
234-
235-
func (bs *Binds) UnmarshalYAML(unmarshal func(interface{}) error) error {
236-
var data interface{}
237-
err := unmarshal(&data)
238-
if err != nil {
239-
return errors.WithStack(err)
240-
}
241-
242-
xform := func(s string) ([]string, error) {
243-
return []string{s}, nil
244-
}
245-
246-
rawBinds, err := getStringOrStringSlice(data, xform)
247-
if err != nil {
248-
return err
249-
}
250-
251-
*bs = Binds{}
252-
for _, bind := range rawBinds {
253-
parts := strings.Split(bind, "->")
254-
if len(parts) != 1 && len(parts) != 2 {
255-
return errors.Errorf("invalid bind mount %s", bind)
256-
}
257-
258-
source := strings.TrimSpace(parts[0])
259-
target := source
260-
261-
if len(parts) == 2 {
262-
target = strings.TrimSpace(parts[1])
263-
}
264-
265-
*bs = append(*bs, Bind{Source: source, Dest: target})
266-
}
267-
268-
return nil
269-
}
270-
271194
type Layer struct {
272195
From ImageSource `yaml:"from" json:"from"`
273196
Imports Imports `yaml:"import" json:"import,omitempty"`

0 commit comments

Comments
 (0)