@ -18,16 +18,16 @@ package kube // import "helm.sh/helm/pkg/kube"
import "k8s.io/cli-runtime/pkg/resource"
import "k8s.io/cli-runtime/pkg/resource"
// Res ul t provides convenience methods for comparing collections of Infos.
// Res ourceLis t provides convenience methods for comparing collections of Infos.
type Res ul t [ ] * resource . Info
type Res ourceLis t [ ] * resource . Info
// Append adds an Info to the Result.
// Append adds an Info to the Result.
func ( r * Res ul t) Append ( val * resource . Info ) {
func ( r * Res ourceLis t) Append ( val * resource . Info ) {
* r = append ( * r , val )
* r = append ( * r , val )
}
}
// Visit implements resource.Visitor.
// Visit implements resource.Visitor.
func ( r Res ul t) Visit ( fn resource . VisitorFunc ) error {
func ( r Res ourceLis t) Visit ( fn resource . VisitorFunc ) error {
for _ , i := range r {
for _ , i := range r {
if err := fn ( i , nil ) ; err != nil {
if err := fn ( i , nil ) ; err != nil {
return err
return err
@ -37,8 +37,8 @@ func (r Result) Visit(fn resource.VisitorFunc) error {
}
}
// Filter returns a new Result with Infos that satisfy the predicate fn.
// Filter returns a new Result with Infos that satisfy the predicate fn.
func ( r Res ul t) Filter ( fn func ( * resource . Info ) bool ) Res ul t {
func ( r Res ourceLis t) Filter ( fn func ( * resource . Info ) bool ) Res ourceLis t {
var result Res ul t
var result Res ourceLis t
for _ , i := range r {
for _ , i := range r {
if fn ( i ) {
if fn ( i ) {
result . Append ( i )
result . Append ( i )
@ -48,7 +48,7 @@ func (r Result) Filter(fn func(*resource.Info) bool) Result {
}
}
// Get returns the Info from the result that matches the name and kind.
// Get returns the Info from the result that matches the name and kind.
func ( r Res ul t) Get ( info * resource . Info ) * resource . Info {
func ( r Res ourceLis t) Get ( info * resource . Info ) * resource . Info {
for _ , i := range r {
for _ , i := range r {
if isMatchingInfo ( i , info ) {
if isMatchingInfo ( i , info ) {
return i
return i
@ -58,7 +58,7 @@ func (r Result) Get(info *resource.Info) *resource.Info {
}
}
// Contains checks to see if an object exists.
// Contains checks to see if an object exists.
func ( r Res ul t) Contains ( info * resource . Info ) bool {
func ( r Res ourceLis t) Contains ( info * resource . Info ) bool {
for _ , i := range r {
for _ , i := range r {
if isMatchingInfo ( i , info ) {
if isMatchingInfo ( i , info ) {
return true
return true
@ -68,14 +68,14 @@ func (r Result) Contains(info *resource.Info) bool {
}
}
// Difference will return a new Result with objects not contained in rs.
// Difference will return a new Result with objects not contained in rs.
func ( r Res ult) Difference ( rs Result ) Resul t {
func ( r Res ourceList) Difference ( rs ResourceList ) ResourceLis t {
return r . Filter ( func ( info * resource . Info ) bool {
return r . Filter ( func ( info * resource . Info ) bool {
return ! rs . Contains ( info )
return ! rs . Contains ( info )
} )
} )
}
}
// Intersect will return a new Result with objects contained in both Results.
// Intersect will return a new Result with objects contained in both Results.
func ( r Res ult) Intersect ( rs Result ) Resul t {
func ( r Res ourceList) Intersect ( rs ResourceList ) ResourceLis t {
return r . Filter ( rs . Contains )
return r . Filter ( rs . Contains )
}
}