package layer import ( wh "edge-infra.dev/pkg/f8n/warehouse" "edge-infra.dev/pkg/f8n/warehouse/capability" ) // Option is a Layer constructor option. type Option func(*options) type options struct { annos map[string]string cap capability.Capability } func makeOptions(opts ...Option) *options { o := &options{} for _, opt := range opts { opt(o) } // if runtime capability is set, add the appropriate annotation if o.cap != "" { if o.annos == nil { o.annos = make(map[string]string) } o.annos[wh.AnnotationLayerRuntimeCapability] = string(o.cap) } return o } // WithAnnotations sets annotations on the result Layer. Additional calls are // all appended to the same annotation map. func WithAnnotations(a map[string]string) Option { return func(o *options) { if o.annos == nil { o.annos = make(map[string]string) } for k, v := range a { o.annos[k] = v } } } // ForCapability creates a Layer for a specific runtime capability. func ForCapability(c capability.Capability) Option { return func(o *options) { o.cap = c } }