mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-17 15:05:10 +00:00
Rackspace for cloud-controller-manager
This implements the NodeAddressesByProviderID and InstanceTypeByProviderID methods used by the cloud-controller-manager to the RackSpace provider. The instance type returned is the flavor name, for consistency InstanceType has been implemented too returning the same value. This is part of #47257 cc @wlan0
This commit is contained in:
@@ -162,3 +162,46 @@ func TestZones(t *testing.T) {
|
||||
t.Fatalf("GetZone() returned wrong region (%s)", zone.Region)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstanceIDFromProviderID(t *testing.T) {
|
||||
testCases := []struct {
|
||||
providerID string
|
||||
instanceID string
|
||||
fail bool
|
||||
}{
|
||||
{
|
||||
providerID: ProviderName + "://7b9cf879-7146-417c-abfd-cb4272f0c935",
|
||||
instanceID: "7b9cf879-7146-417c-abfd-cb4272f0c935",
|
||||
fail: false,
|
||||
},
|
||||
{
|
||||
providerID: "7b9cf879-7146-417c-abfd-cb4272f0c935",
|
||||
instanceID: "",
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
providerID: "other-provider://7b9cf879-7146-417c-abfd-cb4272f0c935",
|
||||
instanceID: "",
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
providerID: "",
|
||||
instanceID: "",
|
||||
fail: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
instanceID, err := instanceIDFromProviderID(test.providerID)
|
||||
if (err != nil) != test.fail {
|
||||
t.Errorf("%s yielded `err != nil` as %t. expected %t", test.providerID, (err != nil), test.fail)
|
||||
}
|
||||
|
||||
if test.fail {
|
||||
continue
|
||||
}
|
||||
if instanceID != test.instanceID {
|
||||
t.Errorf("%s yielded %s. expected %s", test.providerID, instanceID, test.instanceID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user