mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 03:56:37 +00:00
**What** - Add the ability to specify secrets as a csv - Vendor the docker/cli/opts - Update the guide for secrets to use the `faas-cli` **Why** - Allowing the csv specification of secrets gives users more control about how those secrets are mounted into the container. This is good for things like key rotation and for developers that are building on top of OpenFaaS. Signed-off-by: Lucas Roesler <lucas.roesler@gmail.com>
58 lines
1.0 KiB
Go
58 lines
1.0 KiB
Go
package opts
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/docker/go-units"
|
|
)
|
|
|
|
// UlimitOpt defines a map of Ulimits
|
|
type UlimitOpt struct {
|
|
values *map[string]*units.Ulimit
|
|
}
|
|
|
|
// NewUlimitOpt creates a new UlimitOpt
|
|
func NewUlimitOpt(ref *map[string]*units.Ulimit) *UlimitOpt {
|
|
if ref == nil {
|
|
ref = &map[string]*units.Ulimit{}
|
|
}
|
|
return &UlimitOpt{ref}
|
|
}
|
|
|
|
// Set validates a Ulimit and sets its name as a key in UlimitOpt
|
|
func (o *UlimitOpt) Set(val string) error {
|
|
l, err := units.ParseUlimit(val)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
(*o.values)[l.Name] = l
|
|
|
|
return nil
|
|
}
|
|
|
|
// String returns Ulimit values as a string.
|
|
func (o *UlimitOpt) String() string {
|
|
var out []string
|
|
for _, v := range *o.values {
|
|
out = append(out, v.String())
|
|
}
|
|
|
|
return fmt.Sprintf("%v", out)
|
|
}
|
|
|
|
// GetList returns a slice of pointers to Ulimits.
|
|
func (o *UlimitOpt) GetList() []*units.Ulimit {
|
|
var ulimits []*units.Ulimit
|
|
for _, v := range *o.values {
|
|
ulimits = append(ulimits, v)
|
|
}
|
|
|
|
return ulimits
|
|
}
|
|
|
|
// Type returns the option type
|
|
func (o *UlimitOpt) Type() string {
|
|
return "ulimit"
|
|
}
|