Skip to content

Commit d1bdeca

Browse files
committed
refactor!: 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 d1bdeca

File tree

1 file changed

+0
-77
lines changed

1 file changed

+0
-77
lines changed

pkg/types/layer.go

-77
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)