Carry #14813 on linting package opts and trust
| ... | ... |
@@ -70,10 +70,10 @@ func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) strin |
| 70 | 70 |
cmd.StringVar(&config.Bridge.Iface, []string{"b", "-bridge"}, "", usageFn("Attach containers to a network bridge"))
|
| 71 | 71 |
cmd.StringVar(&config.Bridge.FixedCIDR, []string{"-fixed-cidr"}, "", usageFn("IPv4 subnet for fixed IPs"))
|
| 72 | 72 |
cmd.StringVar(&config.Bridge.FixedCIDRv6, []string{"-fixed-cidr-v6"}, "", usageFn("IPv6 subnet for fixed IPs"))
|
| 73 |
- cmd.Var(opts.NewIpOpt(&config.Bridge.DefaultGatewayIPv4, ""), []string{"-default-gateway"}, usageFn("Container default gateway IPv4 address"))
|
|
| 74 |
- cmd.Var(opts.NewIpOpt(&config.Bridge.DefaultGatewayIPv6, ""), []string{"-default-gateway-v6"}, usageFn("Container default gateway IPv6 address"))
|
|
| 73 |
+ cmd.Var(opts.NewIPOpt(&config.Bridge.DefaultGatewayIPv4, ""), []string{"-default-gateway"}, usageFn("Container default gateway IPv4 address"))
|
|
| 74 |
+ cmd.Var(opts.NewIPOpt(&config.Bridge.DefaultGatewayIPv6, ""), []string{"-default-gateway-v6"}, usageFn("Container default gateway IPv6 address"))
|
|
| 75 | 75 |
cmd.BoolVar(&config.Bridge.InterContainerCommunication, []string{"#icc", "-icc"}, true, usageFn("Enable inter-container communication"))
|
| 76 |
- cmd.Var(opts.NewIpOpt(&config.Bridge.DefaultIP, "0.0.0.0"), []string{"#ip", "-ip"}, usageFn("Default IP when binding container ports"))
|
|
| 76 |
+ cmd.Var(opts.NewIPOpt(&config.Bridge.DefaultIP, "0.0.0.0"), []string{"#ip", "-ip"}, usageFn("Default IP when binding container ports"))
|
|
| 77 | 77 |
cmd.BoolVar(&config.Bridge.EnableUserlandProxy, []string{"-userland-proxy"}, true, usageFn("Use userland proxy for loopback traffic"))
|
| 78 | 78 |
cmd.BoolVar(&config.EnableCors, []string{"#api-enable-cors", "#-api-enable-cors"}, false, usageFn("Enable CORS headers in the remote API, this is deprecated by --api-cors-header"))
|
| 79 | 79 |
cmd.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", usageFn("Set CORS headers in the remote API"))
|
| ... | ... |
@@ -669,7 +669,7 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo |
| 669 | 669 |
if err := system.MkdirAll(trustDir, 0700); err != nil {
|
| 670 | 670 |
return nil, err |
| 671 | 671 |
} |
| 672 |
- trustService, err := trust.NewTrustStore(trustDir) |
|
| 672 |
+ trustService, err := trust.NewStore(trustDir) |
|
| 673 | 673 |
if err != nil {
|
| 674 | 674 |
return nil, fmt.Errorf("could not create trust store: %s", err)
|
| 675 | 675 |
} |
| ... | ... |
@@ -40,7 +40,7 @@ type TagStore struct {
|
| 40 | 40 |
pushingPool map[string]chan struct{}
|
| 41 | 41 |
registryService *registry.Service |
| 42 | 42 |
eventsService *events.Events |
| 43 |
- trustService *trust.TrustStore |
|
| 43 |
+ trustService *trust.Store |
|
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 | 46 |
// Repository maps tags to image IDs. |
| ... | ... |
@@ -77,7 +77,7 @@ type TagStoreConfig struct {
|
| 77 | 77 |
// Events is the events service to use for logging. |
| 78 | 78 |
Events *events.Events |
| 79 | 79 |
// Trust is the trust service to use for push and pull operations. |
| 80 |
- Trust *trust.TrustStore |
|
| 80 |
+ Trust *trust.Store |
|
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
// NewTagStore creates a new TagStore at specified path, using the parameters |
| ... | ... |
@@ -44,6 +44,7 @@ packages=( |
| 44 | 44 |
graph/tags |
| 45 | 45 |
image |
| 46 | 46 |
integration-cli |
| 47 |
+ opts |
|
| 47 | 48 |
pkg/archive |
| 48 | 49 |
pkg/broadcastwriter |
| 49 | 50 |
pkg/chrootarchive |
| ... | ... |
@@ -97,6 +98,7 @@ packages=( |
| 97 | 97 |
pkg/version |
| 98 | 98 |
registry |
| 99 | 99 |
runconfig |
| 100 |
+ trust |
|
| 100 | 101 |
utils |
| 101 | 102 |
volume |
| 102 | 103 |
volume/local |
| ... | ... |
@@ -9,13 +9,13 @@ import ( |
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
var ( |
| 12 |
- // EnvironmentVariableRegexp A regexp to validate correct environment variables |
|
| 12 |
+ // EnvironmentVariableRegexp is a regexp to validate correct environment variables |
|
| 13 | 13 |
// Environment variables set by the user must have a name consisting solely of |
| 14 | 14 |
// alphabetics, numerics, and underscores - the first of which must not be numeric. |
| 15 | 15 |
EnvironmentVariableRegexp = regexp.MustCompile("^[[:alpha:]_][[:alpha:][:digit:]_]*$")
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 |
-// ParseEnvFile Read in a line delimited file with environment variables enumerated |
|
| 18 |
+// ParseEnvFile reads a file with environment variables enumerated by lines |
|
| 19 | 19 |
func ParseEnvFile(filename string) ([]string, error) {
|
| 20 | 20 |
fh, err := os.Open(filename) |
| 21 | 21 |
if err != nil {
|
| ... | ... |
@@ -5,20 +5,25 @@ import ( |
| 5 | 5 |
"net" |
| 6 | 6 |
) |
| 7 | 7 |
|
| 8 |
-// IpOpt type that hold an IP |
|
| 9 |
-type IpOpt struct {
|
|
| 8 |
+// IPOpt holds an IP. It is used to store values from CLI flags. |
|
| 9 |
+type IPOpt struct {
|
|
| 10 | 10 |
*net.IP |
| 11 | 11 |
} |
| 12 | 12 |
|
| 13 |
-func NewIpOpt(ref *net.IP, defaultVal string) *IpOpt {
|
|
| 14 |
- o := &IpOpt{
|
|
| 13 |
+// NewIPOpt creates a new IPOpt from a reference net.IP and a |
|
| 14 |
+// string representation of an IP. If the string is not a valid |
|
| 15 |
+// IP it will fallback to the specified reference. |
|
| 16 |
+func NewIPOpt(ref *net.IP, defaultVal string) *IPOpt {
|
|
| 17 |
+ o := &IPOpt{
|
|
| 15 | 18 |
IP: ref, |
| 16 | 19 |
} |
| 17 | 20 |
o.Set(defaultVal) |
| 18 | 21 |
return o |
| 19 | 22 |
} |
| 20 | 23 |
|
| 21 |
-func (o *IpOpt) Set(val string) error {
|
|
| 24 |
+// Set sets an IPv4 or IPv6 address from a given string. If the given |
|
| 25 |
+// string is not parsable as an IP address it returns an error. |
|
| 26 |
+func (o *IPOpt) Set(val string) error {
|
|
| 22 | 27 |
ip := net.ParseIP(val) |
| 23 | 28 |
if ip == nil {
|
| 24 | 29 |
return fmt.Errorf("%s is not an ip address", val)
|
| ... | ... |
@@ -27,7 +32,9 @@ func (o *IpOpt) Set(val string) error {
|
| 27 | 27 |
return nil |
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-func (o *IpOpt) String() string {
|
|
| 30 |
+// String returns the IP address stored in the IPOpt. If stored IP is a |
|
| 31 |
+// nil pointer, it returns an empty string. |
|
| 32 |
+func (o *IPOpt) String() string {
|
|
| 31 | 33 |
if *o.IP == nil {
|
| 32 | 34 |
return "" |
| 33 | 35 |
} |
| ... | ... |
@@ -10,7 +10,7 @@ func TestIpOptString(t *testing.T) {
|
| 10 | 10 |
var ip net.IP |
| 11 | 11 |
|
| 12 | 12 |
for _, address := range addresses {
|
| 13 |
- stringAddress := NewIpOpt(&ip, address).String() |
|
| 13 |
+ stringAddress := NewIPOpt(&ip, address).String() |
|
| 14 | 14 |
if stringAddress != address {
|
| 15 | 15 |
t.Fatalf("IpOpt string should be `%s`, not `%s`", address, stringAddress)
|
| 16 | 16 |
} |
| ... | ... |
@@ -21,7 +21,7 @@ func TestNewIpOptInvalidDefaultVal(t *testing.T) {
|
| 21 | 21 |
ip := net.IPv4(127, 0, 0, 1) |
| 22 | 22 |
defaultVal := "Not an ip" |
| 23 | 23 |
|
| 24 |
- ipOpt := NewIpOpt(&ip, defaultVal) |
|
| 24 |
+ ipOpt := NewIPOpt(&ip, defaultVal) |
|
| 25 | 25 |
|
| 26 | 26 |
expected := "127.0.0.1" |
| 27 | 27 |
if ipOpt.String() != expected {
|
| ... | ... |
@@ -33,7 +33,7 @@ func TestNewIpOptValidDefaultVal(t *testing.T) {
|
| 33 | 33 |
ip := net.IPv4(127, 0, 0, 1) |
| 34 | 34 |
defaultVal := "192.168.1.1" |
| 35 | 35 |
|
| 36 |
- ipOpt := NewIpOpt(&ip, defaultVal) |
|
| 36 |
+ ipOpt := NewIPOpt(&ip, defaultVal) |
|
| 37 | 37 |
|
| 38 | 38 |
expected := "192.168.1.1" |
| 39 | 39 |
if ipOpt.String() != expected {
|
| ... | ... |
@@ -43,11 +43,11 @@ func TestNewIpOptValidDefaultVal(t *testing.T) {
|
| 43 | 43 |
|
| 44 | 44 |
func TestIpOptSetInvalidVal(t *testing.T) {
|
| 45 | 45 |
ip := net.IPv4(127, 0, 0, 1) |
| 46 |
- ipOpt := &IpOpt{IP: &ip}
|
|
| 46 |
+ ipOpt := &IPOpt{IP: &ip}
|
|
| 47 | 47 |
|
| 48 |
- invalidIp := "invalid ip" |
|
| 48 |
+ invalidIP := "invalid ip" |
|
| 49 | 49 |
expectedError := "invalid ip is not an ip address" |
| 50 |
- err := ipOpt.Set(invalidIp) |
|
| 50 |
+ err := ipOpt.Set(invalidIP) |
|
| 51 | 51 |
if err == nil || err.Error() != expectedError {
|
| 52 | 52 |
t.Fatalf("Expected an Error with [%v], got [%v]", expectedError, err.Error())
|
| 53 | 53 |
} |
| ... | ... |
@@ -27,18 +27,19 @@ var ( |
| 27 | 27 |
DefaultUnixSocket = "/var/run/docker.sock" |
| 28 | 28 |
) |
| 29 | 29 |
|
| 30 |
-// ListOpts type that hold a list of values and a validation function. |
|
| 30 |
+// ListOpts holds a list of values and a validation function. |
|
| 31 | 31 |
type ListOpts struct {
|
| 32 | 32 |
values *[]string |
| 33 | 33 |
validator ValidatorFctType |
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 |
-// NewListOpts Create a new ListOpts with the specified validator. |
|
| 36 |
+// NewListOpts creates a new ListOpts with the specified validator. |
|
| 37 | 37 |
func NewListOpts(validator ValidatorFctType) ListOpts {
|
| 38 | 38 |
var values []string |
| 39 | 39 |
return *NewListOptsRef(&values, validator) |
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 |
+// NewListOptsRef creates a new ListOpts with the specified values and validator. |
|
| 42 | 43 |
func NewListOptsRef(values *[]string, validator ValidatorFctType) *ListOpts {
|
| 43 | 44 |
return &ListOpts{
|
| 44 | 45 |
values: values, |
| ... | ... |
@@ -64,7 +65,7 @@ func (opts *ListOpts) Set(value string) error {
|
| 64 | 64 |
return nil |
| 65 | 65 |
} |
| 66 | 66 |
|
| 67 |
-// Delete remove the given element from the slice. |
|
| 67 |
+// Delete removes the specified element from the slice. |
|
| 68 | 68 |
func (opts *ListOpts) Delete(key string) {
|
| 69 | 69 |
for i, k := range *opts.values {
|
| 70 | 70 |
if k == key {
|
| ... | ... |
@@ -85,13 +86,13 @@ func (opts *ListOpts) GetMap() map[string]struct{} {
|
| 85 | 85 |
return ret |
| 86 | 86 |
} |
| 87 | 87 |
|
| 88 |
-// GetAll returns the values' slice. |
|
| 88 |
+// GetAll returns the values of slice. |
|
| 89 | 89 |
// FIXME: Can we remove this? |
| 90 | 90 |
func (opts *ListOpts) GetAll() []string {
|
| 91 | 91 |
return (*opts.values) |
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 |
-// Get checks the existence of the given key. |
|
| 94 |
+// Get checks the existence of the specified key. |
|
| 95 | 95 |
func (opts *ListOpts) Get(key string) bool {
|
| 96 | 96 |
for _, k := range *opts.values {
|
| 97 | 97 |
if k == key {
|
| ... | ... |
@@ -106,7 +107,7 @@ func (opts *ListOpts) Len() int {
|
| 106 | 106 |
return len((*opts.values)) |
| 107 | 107 |
} |
| 108 | 108 |
|
| 109 |
-//MapOpts type that holds a map of values and a validation function. |
|
| 109 |
+//MapOpts holds a map of values and a validation function. |
|
| 110 | 110 |
type MapOpts struct {
|
| 111 | 111 |
values map[string]string |
| 112 | 112 |
validator ValidatorFctType |
| ... | ... |
@@ -131,6 +132,7 @@ func (opts *MapOpts) Set(value string) error {
|
| 131 | 131 |
return nil |
| 132 | 132 |
} |
| 133 | 133 |
|
| 134 |
+// GetAll returns the values of MapOpts as a map. |
|
| 134 | 135 |
func (opts *MapOpts) GetAll() map[string]string {
|
| 135 | 136 |
return opts.values |
| 136 | 137 |
} |
| ... | ... |
@@ -139,6 +141,7 @@ func (opts *MapOpts) String() string {
|
| 139 | 139 |
return fmt.Sprintf("%v", map[string]string((opts.values)))
|
| 140 | 140 |
} |
| 141 | 141 |
|
| 142 |
+// NewMapOpts creates a new MapOpts with the specified map of values and a validator. |
|
| 142 | 143 |
func NewMapOpts(values map[string]string, validator ValidatorFctType) *MapOpts {
|
| 143 | 144 |
if values == nil {
|
| 144 | 145 |
values = make(map[string]string) |
| ... | ... |
@@ -149,13 +152,13 @@ func NewMapOpts(values map[string]string, validator ValidatorFctType) *MapOpts {
|
| 149 | 149 |
} |
| 150 | 150 |
} |
| 151 | 151 |
|
| 152 |
-// ValidatorFctType validator that return a validate string and/or an error |
|
| 152 |
+// ValidatorFctType defines a validator function that returns a validated string and/or an error. |
|
| 153 | 153 |
type ValidatorFctType func(val string) (string, error) |
| 154 | 154 |
|
| 155 |
-// ValidatorFctListType validator that return a validate list of string and/or an error |
|
| 155 |
+// ValidatorFctListType defines a validator function that returns a validated list of string and/or an error |
|
| 156 | 156 |
type ValidatorFctListType func(val string) ([]string, error) |
| 157 | 157 |
|
| 158 |
-// ValidateAttach Validates that the specified string is a valid attach option. |
|
| 158 |
+// ValidateAttach validates that the specified string is a valid attach option. |
|
| 159 | 159 |
func ValidateAttach(val string) (string, error) {
|
| 160 | 160 |
s := strings.ToLower(val) |
| 161 | 161 |
for _, str := range []string{"stdin", "stdout", "stderr"} {
|
| ... | ... |
@@ -166,7 +169,7 @@ func ValidateAttach(val string) (string, error) {
|
| 166 | 166 |
return val, fmt.Errorf("valid streams are STDIN, STDOUT and STDERR")
|
| 167 | 167 |
} |
| 168 | 168 |
|
| 169 |
-// ValidateLink Validates that the specified string has a valid link format (containerName:alias). |
|
| 169 |
+// ValidateLink validates that the specified string has a valid link format (containerName:alias). |
|
| 170 | 170 |
func ValidateLink(val string) (string, error) {
|
| 171 | 171 |
if _, _, err := parsers.ParseLink(val); err != nil {
|
| 172 | 172 |
return val, err |
| ... | ... |
@@ -194,18 +197,18 @@ func ValidDeviceMode(mode string) bool {
|
| 194 | 194 |
return true |
| 195 | 195 |
} |
| 196 | 196 |
|
| 197 |
-// ValidateDevice Validate a path for devices |
|
| 197 |
+// ValidateDevice validates a path for devices |
|
| 198 | 198 |
// It will make sure 'val' is in the form: |
| 199 | 199 |
// [host-dir:]container-path[:mode] |
| 200 |
-// It will also validate the device mode. |
|
| 200 |
+// It also validates the device mode. |
|
| 201 | 201 |
func ValidateDevice(val string) (string, error) {
|
| 202 | 202 |
return validatePath(val, ValidDeviceMode) |
| 203 | 203 |
} |
| 204 | 204 |
|
| 205 |
-// ValidatePath Validate a path for volumes |
|
| 205 |
+// ValidatePath validates a path for volumes |
|
| 206 | 206 |
// It will make sure 'val' is in the form: |
| 207 | 207 |
// [host-dir:]container-path[:rw|ro] |
| 208 |
-// It will also validate the mount mode. |
|
| 208 |
+// It also validates the mount mode. |
|
| 209 | 209 |
func ValidatePath(val string) (string, error) {
|
| 210 | 210 |
return validatePath(val, volume.ValidMountMode) |
| 211 | 211 |
} |
| ... | ... |
@@ -250,8 +253,8 @@ func validatePath(val string, validator func(string) bool) (string, error) {
|
| 250 | 250 |
return val, nil |
| 251 | 251 |
} |
| 252 | 252 |
|
| 253 |
-// ValidateEnv Validate an environment variable and returns it |
|
| 254 |
-// It will use EnvironmentVariableRegexp to ensure the name of the environment variable is valid. |
|
| 253 |
+// ValidateEnv validates an environment variable and returns it. |
|
| 254 |
+// It uses EnvironmentVariableRegexp to ensure the name of the environment variable is valid. |
|
| 255 | 255 |
// If no value is specified, it returns the current value using os.Getenv. |
| 256 | 256 |
func ValidateEnv(val string) (string, error) {
|
| 257 | 257 |
arr := strings.Split(val, "=") |
| ... | ... |
@@ -267,7 +270,7 @@ func ValidateEnv(val string) (string, error) {
|
| 267 | 267 |
return fmt.Sprintf("%s=%s", val, os.Getenv(val)), nil
|
| 268 | 268 |
} |
| 269 | 269 |
|
| 270 |
-// ValidateIPAddress Validates an Ip address |
|
| 270 |
+// ValidateIPAddress validates an Ip address. |
|
| 271 | 271 |
func ValidateIPAddress(val string) (string, error) {
|
| 272 | 272 |
var ip = net.ParseIP(strings.TrimSpace(val)) |
| 273 | 273 |
if ip != nil {
|
| ... | ... |
@@ -276,7 +279,7 @@ func ValidateIPAddress(val string) (string, error) {
|
| 276 | 276 |
return "", fmt.Errorf("%s is not an ip address", val)
|
| 277 | 277 |
} |
| 278 | 278 |
|
| 279 |
-// ValidateMACAddress Validates a MAC address |
|
| 279 |
+// ValidateMACAddress validates a MAC address. |
|
| 280 | 280 |
func ValidateMACAddress(val string) (string, error) {
|
| 281 | 281 |
_, err := net.ParseMAC(strings.TrimSpace(val)) |
| 282 | 282 |
if err != nil {
|
| ... | ... |
@@ -285,8 +288,8 @@ func ValidateMACAddress(val string) (string, error) {
|
| 285 | 285 |
return val, nil |
| 286 | 286 |
} |
| 287 | 287 |
|
| 288 |
-// ValidateDNSSearch Validates domain for resolvconf search configuration. |
|
| 289 |
-// A zero length domain is represented by . |
|
| 288 |
+// ValidateDNSSearch validates domain for resolvconf search configuration. |
|
| 289 |
+// A zero length domain is represented by a dot (.). |
|
| 290 | 290 |
func ValidateDNSSearch(val string) (string, error) {
|
| 291 | 291 |
if val = strings.Trim(val, " "); val == "." {
|
| 292 | 292 |
return val, nil |
| ... | ... |
@@ -305,8 +308,8 @@ func validateDomain(val string) (string, error) {
|
| 305 | 305 |
return "", fmt.Errorf("%s is not a valid domain", val)
|
| 306 | 306 |
} |
| 307 | 307 |
|
| 308 |
-// ValidateExtraHost Validate that the given string is a valid extrahost and returns it |
|
| 309 |
-// ExtraHost are in the form of name:ip where the ip has to be a valid ip (ipv4 or ipv6) |
|
| 308 |
+// ValidateExtraHost validates that the specified string is a valid extrahost and returns it. |
|
| 309 |
+// ExtraHost are in the form of name:ip where the ip has to be a valid ip (ipv4 or ipv6). |
|
| 310 | 310 |
func ValidateExtraHost(val string) (string, error) {
|
| 311 | 311 |
// allow for IPv6 addresses in extra hosts by only splitting on first ":" |
| 312 | 312 |
arr := strings.SplitN(val, ":", 2) |
| ... | ... |
@@ -319,8 +322,8 @@ func ValidateExtraHost(val string) (string, error) {
|
| 319 | 319 |
return val, nil |
| 320 | 320 |
} |
| 321 | 321 |
|
| 322 |
-// ValidateLabel Validate that the given string is a valid label, and returns it |
|
| 323 |
-// Labels are in the form on key=value |
|
| 322 |
+// ValidateLabel validates that the specified string is a valid label, and returns it. |
|
| 323 |
+// Labels are in the form on key=value. |
|
| 324 | 324 |
func ValidateLabel(val string) (string, error) {
|
| 325 | 325 |
if strings.Count(val, "=") < 1 {
|
| 326 | 326 |
return "", fmt.Errorf("bad attribute format: %s", val)
|
| ... | ... |
@@ -328,7 +331,7 @@ func ValidateLabel(val string) (string, error) {
|
| 328 | 328 |
return val, nil |
| 329 | 329 |
} |
| 330 | 330 |
|
| 331 |
-// ValidateHost Validate that the given string is a valid host and returns it |
|
| 331 |
+// ValidateHost validates that the specified string is a valid host and returns it. |
|
| 332 | 332 |
func ValidateHost(val string) (string, error) {
|
| 333 | 333 |
host, err := parsers.ParseHost(DefaultHTTPHost, DefaultUnixSocket, val) |
| 334 | 334 |
if err != nil {
|
| ... | ... |
@@ -6,10 +6,12 @@ import ( |
| 6 | 6 |
"github.com/docker/docker/pkg/ulimit" |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 |
+// UlimitOpt defines a map of Ulimits |
|
| 9 | 10 |
type UlimitOpt struct {
|
| 10 | 11 |
values *map[string]*ulimit.Ulimit |
| 11 | 12 |
} |
| 12 | 13 |
|
| 14 |
+// NewUlimitOpt creates a new UlimitOpt |
|
| 13 | 15 |
func NewUlimitOpt(ref *map[string]*ulimit.Ulimit) *UlimitOpt {
|
| 14 | 16 |
if ref == nil {
|
| 15 | 17 |
ref = &map[string]*ulimit.Ulimit{}
|
| ... | ... |
@@ -17,6 +19,7 @@ func NewUlimitOpt(ref *map[string]*ulimit.Ulimit) *UlimitOpt {
|
| 17 | 17 |
return &UlimitOpt{ref}
|
| 18 | 18 |
} |
| 19 | 19 |
|
| 20 |
+// Set validates a Ulimit and sets its name as a key in UlimitOpt |
|
| 20 | 21 |
func (o *UlimitOpt) Set(val string) error {
|
| 21 | 22 |
l, err := ulimit.Parse(val) |
| 22 | 23 |
if err != nil {
|
| ... | ... |
@@ -28,6 +31,7 @@ func (o *UlimitOpt) Set(val string) error {
|
| 28 | 28 |
return nil |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
+// String returns Ulimit values as a string. |
|
| 31 | 32 |
func (o *UlimitOpt) String() string {
|
| 32 | 33 |
var out []string |
| 33 | 34 |
for _, v := range *o.values {
|
| ... | ... |
@@ -37,6 +41,7 @@ func (o *UlimitOpt) String() string {
|
| 37 | 37 |
return fmt.Sprintf("%v", out)
|
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 |
+// GetList returns a slice of pointers to Ulimits. |
|
| 40 | 41 |
func (o *UlimitOpt) GetList() []*ulimit.Ulimit {
|
| 41 | 42 |
var ulimits []*ulimit.Ulimit |
| 42 | 43 |
for _, v := range *o.values {
|
| ... | ... |
@@ -8,13 +8,17 @@ import ( |
| 8 | 8 |
"github.com/docker/libtrust" |
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 |
+// NotVerifiedError reports a error when doing the key check. |
|
| 12 |
+// For example if the graph is not verified or the key has expired. |
|
| 11 | 13 |
type NotVerifiedError string |
| 12 | 14 |
|
| 13 | 15 |
func (e NotVerifiedError) Error() string {
|
| 14 | 16 |
return string(e) |
| 15 | 17 |
} |
| 16 | 18 |
|
| 17 |
-func (t *TrustStore) CheckKey(ns string, key []byte, perm uint16) (bool, error) {
|
|
| 19 |
+// CheckKey verifies that the given public key is allowed to perform |
|
| 20 |
+// the given action on the given node according to the trust graph. |
|
| 21 |
+func (t *Store) CheckKey(ns string, key []byte, perm uint16) (bool, error) {
|
|
| 18 | 22 |
if len(key) == 0 {
|
| 19 | 23 |
return false, fmt.Errorf("Missing PublicKey")
|
| 20 | 24 |
} |
| ... | ... |
@@ -48,6 +52,8 @@ func (t *TrustStore) CheckKey(ns string, key []byte, perm uint16) (bool, error) |
| 48 | 48 |
return true, nil |
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 |
-func (t *TrustStore) UpdateBase() {
|
|
| 51 |
+// UpdateBase retrieves updated base graphs. This function cannot error, it |
|
| 52 |
+// should only log errors. |
|
| 53 |
+func (t *Store) UpdateBase() {
|
|
| 52 | 54 |
t.fetch() |
| 53 | 55 |
} |
| ... | ... |
@@ -17,7 +17,10 @@ import ( |
| 17 | 17 |
"github.com/docker/libtrust/trustgraph" |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 |
-type TrustStore struct {
|
|
| 20 |
+// Store defines a TrustStore : stores trusted certificates and permissions |
|
| 21 |
+// which are used to verify the signature keys on manifests. |
|
| 22 |
+// Note: This is being deprecated by the notary work. |
|
| 23 |
+type Store struct {
|
|
| 21 | 24 |
path string |
| 22 | 25 |
caPool *x509.CertPool |
| 23 | 26 |
graph trustgraph.TrustGraph |
| ... | ... |
@@ -38,7 +41,9 @@ const defaultFetchtime = 45 * time.Second |
| 38 | 38 |
|
| 39 | 39 |
var baseEndpoints = map[string]string{"official": "https://dvjy3tqbc323p.cloudfront.net/trust/official.json"}
|
| 40 | 40 |
|
| 41 |
-func NewTrustStore(path string) (*TrustStore, error) {
|
|
| 41 |
+// NewStore creates a TrustStore from a given path, if the path is not |
|
| 42 |
+// relative, it will be joined with the working directory. |
|
| 43 |
+func NewStore(path string) (*Store, error) {
|
|
| 42 | 44 |
abspath, err := filepath.Abs(path) |
| 43 | 45 |
if err != nil {
|
| 44 | 46 |
return nil, err |
| ... | ... |
@@ -55,7 +60,7 @@ func NewTrustStore(path string) (*TrustStore, error) {
|
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 | 57 |
// Load grant files |
| 58 |
- t := &TrustStore{
|
|
| 58 |
+ t := &Store{
|
|
| 59 | 59 |
path: abspath, |
| 60 | 60 |
caPool: nil, |
| 61 | 61 |
httpClient: &http.Client{},
|
| ... | ... |
@@ -70,7 +75,7 @@ func NewTrustStore(path string) (*TrustStore, error) {
|
| 70 | 70 |
return t, nil |
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 |
-func (t *TrustStore) reload() error {
|
|
| 73 |
+func (t *Store) reload() error {
|
|
| 74 | 74 |
t.Lock() |
| 75 | 75 |
defer t.Unlock() |
| 76 | 76 |
|
| ... | ... |
@@ -121,7 +126,7 @@ func (t *TrustStore) reload() error {
|
| 121 | 121 |
return nil |
| 122 | 122 |
} |
| 123 | 123 |
|
| 124 |
-func (t *TrustStore) fetchBaseGraph(u *url.URL) (*trustgraph.Statement, error) {
|
|
| 124 |
+func (t *Store) fetchBaseGraph(u *url.URL) (*trustgraph.Statement, error) {
|
|
| 125 | 125 |
req := &http.Request{
|
| 126 | 126 |
Method: "GET", |
| 127 | 127 |
URL: u, |
| ... | ... |
@@ -146,9 +151,9 @@ func (t *TrustStore) fetchBaseGraph(u *url.URL) (*trustgraph.Statement, error) {
|
| 146 | 146 |
return trustgraph.LoadStatement(resp.Body, t.caPool) |
| 147 | 147 |
} |
| 148 | 148 |
|
| 149 |
-// fetch retrieves updated base graphs. This function cannot error, it |
|
| 149 |
+// fetch retrieves updated base graphs. This function cannot error, it |
|
| 150 | 150 |
// should only log errors |
| 151 |
-func (t *TrustStore) fetch() {
|
|
| 151 |
+func (t *Store) fetch() {
|
|
| 152 | 152 |
t.Lock() |
| 153 | 153 |
defer t.Unlock() |
| 154 | 154 |
|