sigs.k8s.io/cluster-api-provider-aws@v1.5.5/pkg/eks/addons/types.go (about)

     1  /*
     2  Copyright 2021 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package addons
    18  
    19  import (
    20  	"github.com/google/go-cmp/cmp"
    21  
    22  	infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1"
    23  )
    24  
    25  // EKSAddon represents an EKS addon.
    26  type EKSAddon struct {
    27  	Name                  *string
    28  	Version               *string
    29  	ServiceAccountRoleARN *string
    30  	Tags                  infrav1.Tags
    31  	ResolveConflict       *string
    32  	ARN                   *string
    33  	Status                *string
    34  }
    35  
    36  // IsEqual determines if 2 EKSAddon are equal.
    37  func (e *EKSAddon) IsEqual(other *EKSAddon, includeTags bool) bool {
    38  	//NOTE: we don't compare the ARN as thats only for existing addons
    39  	if e == other {
    40  		return true
    41  	}
    42  	if !cmp.Equal(e.Version, other.Version) {
    43  		return false
    44  	}
    45  	if !cmp.Equal(e.ServiceAccountRoleARN, other.ServiceAccountRoleARN) {
    46  		return false
    47  	}
    48  
    49  	if includeTags {
    50  		diffTags := e.Tags.Difference(other.Tags)
    51  		if len(diffTags) > 0 {
    52  			return false
    53  		}
    54  	}
    55  
    56  	return true
    57  }