Skip to content

Commit

Permalink
Rename ClusterName to ClusterID
Browse files Browse the repository at this point in the history
  • Loading branch information
spangenberg committed Oct 24, 2018
1 parent a57c11d commit 76ed570
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

// Annotation constants
const (
// ClusterNameLabel is the label that a machineset must have to identify the
// ClusterIDLabel is the label that a machineset must have to identify the
// cluster to which it belongs.
ClusterNameLabel = "sigs.k8s.io/cluster-api-cluster"
ClusterIDLabel = "sigs.k8s.io/cluster-api-cluster"
MachineRoleLabel = "sigs.k8s.io/cluster-api-machine-role"
MachineTypeLabel = "sigs.k8s.io/cluster-api-machine-type"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/aws/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,6 @@ func (a *Actuator) updateStatus(machine *clusterv1.Machine, instance *ec2.Instan
}

func getClusterID(machine *clusterv1.Machine) (string, bool) {
clusterID, ok := machine.Labels[providerconfigv1.ClusterNameLabel]
clusterID, ok := machine.Labels[providerconfigv1.ClusterIDLabel]
return clusterID, ok
}
13 changes: 4 additions & 9 deletions pkg/cloud/aws/actuators/machine/actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const (
awsCredentialsSecretName = "aws-credentials-secret"
userDataSecretName = "aws-actuator-user-data-secret"

keyName = "aws-actuator-key-name"
clusterName = "aws-actuator-cluster"
keyName = "aws-actuator-key-name"
clusterID = "aws-actuator-cluster"
)

const userDataBlob = `#cloud-config
Expand Down Expand Up @@ -129,7 +129,7 @@ func testMachineAPIResources(clusterID string) (*clusterv1.Machine, *clusterv1.C
Name: "aws-actuator-testing-machine",
Namespace: defaultNamespace,
Labels: map[string]string{
providerconfigv1.ClusterNameLabel: clusterID,
providerconfigv1.ClusterIDLabel: clusterID,
providerconfigv1.MachineRoleLabel: "infra",
providerconfigv1.MachineTypeLabel: "master",
},
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestCreateAndDeleteMachine(t *testing.T) {
// - kubeClient.CoreV1().Secrets(namespace).Get(secretName, metav1.GetOptions{})
// cluster client for updating machine statues
// - clusterClient.ClusterV1alpha1().Machines(machineCopy.Namespace).UpdateStatus(machineCopy)
machine, cluster, awsCredentialsSecret, userDataSecret, err := testMachineAPIResources(clusterName)
machine, cluster, awsCredentialsSecret, userDataSecret, err := testMachineAPIResources(clusterID)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -338,25 +338,20 @@ func TestRemoveDuplicatedTags(t *testing.T) {
// no duplicate tags
tagList: []*ec2.Tag{
{Key: aws.String("clusterID"), Value: aws.String("test-ClusterIDValue")},
{Key: aws.String("clusterName"), Value: aws.String("test-ClusterNameValue")},
},
expected: []*ec2.Tag{
{Key: aws.String("clusterID"), Value: aws.String("test-ClusterIDValue")},
{Key: aws.String("clusterName"), Value: aws.String("test-ClusterNameValue")},
},
},
{
// multiple duplicate tags
tagList: []*ec2.Tag{
{Key: aws.String("clusterID"), Value: aws.String("test-ClusterIDValue")},
{Key: aws.String("clusterName"), Value: aws.String("test-ClusterNameValue")},
{Key: aws.String("clusterSize"), Value: aws.String("test-ClusterSizeValue")},
{Key: aws.String("clusterName"), Value: aws.String("test-ClusterNameDuplicatedValue")},
{Key: aws.String("clusterSize"), Value: aws.String("test-ClusterSizeDuplicatedValue")},
},
expected: []*ec2.Tag{
{Key: aws.String("clusterID"), Value: aws.String("test-ClusterIDValue")},
{Key: aws.String("clusterName"), Value: aws.String("test-ClusterNameValue")},
{Key: aws.String("clusterSize"), Value: aws.String("test-ClusterSizeValue")},
},
},
Expand Down
4 changes: 2 additions & 2 deletions test/integration/create_update_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const (
awsCredentialsSecretName = "aws-credentials-secret"
userDataSecretName = "aws-actuator-user-data-secret"

clusterName = "tb-asg-35"
clusterID = "tb-asg-35"
)

const userDataBlob = `#cloud-config
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestCreateAndDeleteMachine(t *testing.T) {
t.Fatalf("GOPATH not set")
}

machine, cluster, awsCredentialsSecret, userDataSecret, err := testMachineAPIResources(clusterName)
machine, cluster, awsCredentialsSecret, userDataSecret, err := testMachineAPIResources(clusterID)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 76ed570

Please sign in to comment.