change.go 944 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2014 go-dockerclient authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package docker
  5. import "fmt"
  6. // ChangeType is a type for constants indicating the type of change
  7. // in a container
  8. type ChangeType int
  9. const (
  10. // ChangeModify is the ChangeType for container modifications
  11. ChangeModify ChangeType = iota
  12. // ChangeAdd is the ChangeType for additions to a container
  13. ChangeAdd
  14. // ChangeDelete is the ChangeType for deletions from a container
  15. ChangeDelete
  16. )
  17. // Change represents a change in a container.
  18. //
  19. // See https://goo.gl/9GsTIF for more details.
  20. type Change struct {
  21. Path string
  22. Kind ChangeType
  23. }
  24. func (change *Change) String() string {
  25. var kind string
  26. switch change.Kind {
  27. case ChangeModify:
  28. kind = "C"
  29. case ChangeAdd:
  30. kind = "A"
  31. case ChangeDelete:
  32. kind = "D"
  33. }
  34. return fmt.Sprintf("%s %s", kind, change.Path)
  35. }