diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-03-23 09:04:31 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-03-24 16:06:01 -0700 |
commit | 1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f (patch) | |
tree | a9ce6c3b2e91a797cf8174d7a4e9d62eccb4d1e8 /pkg/domain/entities/set.go | |
parent | 0c084d9719772a9b68d5eb67114cf5bf001958b2 (diff) | |
download | podman-1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f.tar.gz podman-1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f.tar.bz2 podman-1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f.zip |
V2 podman images/image list
* Updated entities to support flags/options
* Updated bindings caused by entities changes
* Removed handlers.ImageSummary in favor of entities.ImageSummary
* Introduced StringSet() container object to simply error checking
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/domain/entities/set.go')
-rw-r--r-- | pkg/domain/entities/set.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/pkg/domain/entities/set.go b/pkg/domain/entities/set.go new file mode 100644 index 000000000..c8d6cb1a9 --- /dev/null +++ b/pkg/domain/entities/set.go @@ -0,0 +1,45 @@ +package entities + +import ( + "strings" +) + +type stringSet struct { + m map[string]struct{} +} + +func NewStringSet(elem ...string) *stringSet { + s := &stringSet{} + s.m = make(map[string]struct{}, len(elem)) + for _, e := range elem { + s.Add(e) + } + return s +} + +func (s *stringSet) Add(elem string) { + s.m[elem] = struct{}{} +} + +func (s *stringSet) Remove(elem string) { + delete(s.m, elem) +} + +func (s *stringSet) Contains(elem string) bool { + _, ok := s.m[elem] + return ok +} + +func (s *stringSet) Elements() []string { + keys := make([]string, len(s.m)) + i := 0 + for k := range s.m { + keys[i] = k + i++ + } + return keys +} + +func (s *stringSet) String() string { + return strings.Join(s.Elements(), ", ") +} |