From 9091f97aed9301e36d76311bcd7e44c04bbc3fa3 Mon Sep 17 00:00:00 2001 From: Shruti Ramesh Date: Wed, 25 Jul 2018 15:50:46 -0700 Subject: [PATCH] removing rbac error checking from merge fn (#3530) --- pkg/api/agentPoolOnlyApi/v20180331/merge.go | 13 --- .../agentPoolOnlyApi/v20180331/merge_test.go | 102 ------------------ 2 files changed, 115 deletions(-) diff --git a/pkg/api/agentPoolOnlyApi/v20180331/merge.go b/pkg/api/agentPoolOnlyApi/v20180331/merge.go index ab75e3b4b3..f467119e33 100644 --- a/pkg/api/agentPoolOnlyApi/v20180331/merge.go +++ b/pkg/api/agentPoolOnlyApi/v20180331/merge.go @@ -42,19 +42,6 @@ func (mc *ManagedCluster) Merge(emc *ManagedCluster) error { mc.Properties.KubernetesVersion = emc.Properties.KubernetesVersion } - // Merge properties.enableRBAC - if emc.Properties.EnableRBAC == nil { - return errors.New("existing ManagedCluster expect properties.enableRBAC not to be nil") - } - - if mc.Properties.EnableRBAC == nil { - // For update scenario, the default behavior is to use existing behavior - mc.Properties.EnableRBAC = emc.Properties.EnableRBAC - } else if *mc.Properties.EnableRBAC != *emc.Properties.EnableRBAC { - return errors.Errorf("existing ManagedCluster has properties.enableRBAC %v. update to %v is not supported", - *emc.Properties.EnableRBAC, - *mc.Properties.EnableRBAC) - } if mc.Properties.NetworkProfile == nil { // For update scenario, the default behavior is to use existing behavior mc.Properties.NetworkProfile = emc.Properties.NetworkProfile diff --git a/pkg/api/agentPoolOnlyApi/v20180331/merge_test.go b/pkg/api/agentPoolOnlyApi/v20180331/merge_test.go index c81b9a7e05..fb9e3941c1 100644 --- a/pkg/api/agentPoolOnlyApi/v20180331/merge_test.go +++ b/pkg/api/agentPoolOnlyApi/v20180331/merge_test.go @@ -62,108 +62,6 @@ func TestMerge_DNSPrefix(t *testing.T) { } } -func TestMerge_EnableRBAC(t *testing.T) { - newMC := &ManagedCluster{ - Properties: &Properties{ - EnableRBAC: nil, - }, - } - - existingMC := &ManagedCluster{ - Properties: &Properties{ - DNSPrefix: "something", - EnableRBAC: helpers.PointerToBool(false), - }, - } - - e := newMC.Merge(existingMC) - if e != nil { - t.Error("expect error to be nil") - } - if newMC.Properties.EnableRBAC == nil || *newMC.Properties.EnableRBAC != false { - t.Error("expect EnableRBAC to be same with existing when omit in updating") - } - - newMC = &ManagedCluster{ - Properties: &Properties{ - EnableRBAC: nil, - }, - } - - existingMC = &ManagedCluster{ - Properties: &Properties{ - DNSPrefix: "something", - EnableRBAC: helpers.PointerToBool(true), - }, - } - - e = newMC.Merge(existingMC) - if e != nil { - t.Error("expect error to be nil") - } - if newMC.Properties.EnableRBAC == nil || *newMC.Properties.EnableRBAC != true { - t.Error("expect EnableRBAC to be same with existing when omit in updating") - } - - newMC = &ManagedCluster{ - Properties: &Properties{ - EnableRBAC: nil, - }, - } - - existingMC = &ManagedCluster{ - Properties: &Properties{ - DNSPrefix: "something", - EnableRBAC: nil, - }, - } - - e = newMC.Merge(existingMC) - if e == nil { - t.Error("expect error not to be nil") - } - - newMC = &ManagedCluster{ - Properties: &Properties{ - EnableRBAC: helpers.PointerToBool(true), - }, - } - - existingMC = &ManagedCluster{ - Properties: &Properties{ - DNSPrefix: "something", - EnableRBAC: helpers.PointerToBool(true), - }, - } - - e = newMC.Merge(existingMC) - if e != nil { - t.Error("expect error to be nil") - } - if newMC.Properties.EnableRBAC == nil || *newMC.Properties.EnableRBAC != true { - t.Error("expect EnableRBAC to be true") - } - - newMC = &ManagedCluster{ - Properties: &Properties{ - EnableRBAC: helpers.PointerToBool(false), - }, - } - - existingMC = &ManagedCluster{ - Properties: &Properties{ - DNSPrefix: "something", - EnableRBAC: helpers.PointerToBool(true), - }, - } - - e = newMC.Merge(existingMC) - if e == nil { - t.Error("expect error to be nil") - } - -} - func TestMerge_AAD(t *testing.T) { // Partial AAD profile was passed during update newMC := &ManagedCluster{