ns.go 532 B

1234567891011121314151617181920212223242526
  1. package configuration
  2. import (
  3. "fmt"
  4. "github.com/dotcloud/docker/pkg/libcontainer"
  5. "strings"
  6. )
  7. func parseNsOpt(container *libcontainer.Container, opts []string) error {
  8. var (
  9. value = strings.TrimSpace(opts[0])
  10. ns = container.Namespaces.Get(value[1:])
  11. )
  12. if ns == nil {
  13. return fmt.Errorf("%s is not a valid namespace", value[1:])
  14. }
  15. switch value[0] {
  16. case '-':
  17. ns.Enabled = false
  18. case '+':
  19. ns.Enabled = true
  20. default:
  21. return fmt.Errorf("%c is not a valid modifier for namespaces", value[0])
  22. }
  23. return nil
  24. }