...

Source file src/sigs.k8s.io/kustomize/api/resource/idset.go

Documentation: sigs.k8s.io/kustomize/api/resource

     1  // Copyright 2020 The Kubernetes Authors.
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package resource
     5  
     6  import "sigs.k8s.io/kustomize/kyaml/resid"
     7  
     8  type IdSet struct {
     9  	ids map[resid.ResId]bool
    10  }
    11  
    12  func MakeIdSet(slice []*Resource) *IdSet {
    13  	set := make(map[resid.ResId]bool)
    14  	for _, r := range slice {
    15  		id := r.CurId()
    16  		if _, ok := set[id]; !ok {
    17  			set[id] = true
    18  		}
    19  	}
    20  	return &IdSet{ids: set}
    21  }
    22  
    23  func (s IdSet) Contains(id resid.ResId) bool {
    24  	_, ok := s.ids[id]
    25  	return ok
    26  }
    27  
    28  func (s IdSet) Size() int {
    29  	return len(s.ids)
    30  }
    31  

View as plain text