github.com/databricks/cli@v0.203.0/bundle/artifacts/all.go (about) 1 package artifacts 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/databricks/cli/bundle" 8 "golang.org/x/exp/maps" 9 "golang.org/x/exp/slices" 10 ) 11 12 // all is an internal proxy for producing a list of mutators for all artifacts. 13 // It is used to produce the [BuildAll] and [UploadAll] mutators. 14 type all struct { 15 name string 16 fn func(name string) (bundle.Mutator, error) 17 } 18 19 func (m *all) Name() string { 20 return fmt.Sprintf("artifacts.%sAll", m.name) 21 } 22 23 func (m *all) Apply(ctx context.Context, b *bundle.Bundle) error { 24 var out []bundle.Mutator 25 26 // Iterate with stable ordering. 27 keys := maps.Keys(b.Config.Artifacts) 28 slices.Sort(keys) 29 30 for _, name := range keys { 31 m, err := m.fn(name) 32 if err != nil { 33 return err 34 } 35 if m != nil { 36 out = append(out, m) 37 } 38 } 39 40 return bundle.Apply(ctx, b, bundle.Seq(out...)) 41 }