Fix naming in state file

This commit is contained in:
katexochen 2022-07-29 08:10:51 +02:00 committed by Paul Meyer
parent 779a73a03d
commit c2faa20d6e
13 changed files with 533 additions and 533 deletions

View File

@ -210,19 +210,19 @@ func (c *Client) GetState() (state.ConstellationState, error) {
if len(c.workerScaleSet) == 0 { if len(c.workerScaleSet) == 0 {
return state.ConstellationState{}, errors.New("client has no worker scale set") return state.ConstellationState{}, errors.New("client has no worker scale set")
} }
stat.AzureWorkersScaleSet = c.workerScaleSet stat.AzureWorkerScaleSet = c.workerScaleSet
if len(c.controlPlaneScaleSet) == 0 { if len(c.controlPlaneScaleSet) == 0 {
return state.ConstellationState{}, errors.New("client has no control plane scale set") return state.ConstellationState{}, errors.New("client has no control plane scale set")
} }
stat.AzureControlPlanesScaleSet = c.controlPlaneScaleSet stat.AzureControlPlaneScaleSet = c.controlPlaneScaleSet
if len(c.workers) == 0 { if len(c.workers) == 0 {
return state.ConstellationState{}, errors.New("client has no workers") return state.ConstellationState{}, errors.New("client has no workers")
} }
stat.AzureWorkers = c.workers stat.AzureWorkerInstances = c.workers
if len(c.controlPlanes) == 0 { if len(c.controlPlanes) == 0 {
return state.ConstellationState{}, errors.New("client has no control planes") return state.ConstellationState{}, errors.New("client has no control planes")
} }
stat.AzureControlPlane = c.controlPlanes stat.AzureControlPlaneInstances = c.controlPlanes
// AD App Object ID does not have to be set at all times // AD App Object ID does not have to be set at all times
stat.AzureADAppObjectID = c.adAppObjectID stat.AzureADAppObjectID = c.adAppObjectID
@ -270,22 +270,22 @@ func (c *Client) SetState(stat state.ConstellationState) error {
return errors.New("state has no subnet") return errors.New("state has no subnet")
} }
c.networkSecurityGroup = stat.AzureNetworkSecurityGroup c.networkSecurityGroup = stat.AzureNetworkSecurityGroup
if len(stat.AzureWorkersScaleSet) == 0 { if len(stat.AzureWorkerScaleSet) == 0 {
return errors.New("state has no worker scale set") return errors.New("state has no worker scale set")
} }
c.workerScaleSet = stat.AzureWorkersScaleSet c.workerScaleSet = stat.AzureWorkerScaleSet
if len(stat.AzureControlPlanesScaleSet) == 0 { if len(stat.AzureControlPlaneScaleSet) == 0 {
return errors.New("state has no worker scale set") return errors.New("state has no worker scale set")
} }
c.controlPlaneScaleSet = stat.AzureControlPlanesScaleSet c.controlPlaneScaleSet = stat.AzureControlPlaneScaleSet
if len(stat.AzureWorkers) == 0 { if len(stat.AzureWorkerInstances) == 0 {
return errors.New("state has no workers") return errors.New("state has no workers")
} }
c.workers = stat.AzureWorkers c.workers = stat.AzureWorkerInstances
if len(stat.AzureControlPlane) == 0 { if len(stat.AzureControlPlaneInstances) == 0 {
return errors.New("state has no control planes") return errors.New("state has no control planes")
} }
c.controlPlanes = stat.AzureControlPlane c.controlPlanes = stat.AzureControlPlaneInstances
// AD App Object ID does not have to be set at all times // AD App Object ID does not have to be set at all times
c.adAppObjectID = stat.AzureADAppObjectID c.adAppObjectID = stat.AzureADAppObjectID

View File

@ -23,367 +23,13 @@ func TestSetGetState(t *testing.T) {
"valid state": { "valid state": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(), CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{ AzureWorkerInstances: cloudtypes.Instances{
"0": { "0": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
AzureControlPlane: cloudtypes.Instances{ AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
},
"missing workers": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing controlplane": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing name": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing uid": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing bootstrapper host": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing resource group": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing location": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing subscription": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureTenant: "tenant",
AzureLocation: "location",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing tenant": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureSubscription: "subscription",
AzureLocation: "location",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing subnet": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing network security group": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureWorkersScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing worker scale set": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureControlPlanesScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing controlplane scale set": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlane: cloudtypes.Instances{
"0": { "0": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -398,7 +44,361 @@ func TestSetGetState(t *testing.T) {
AzureTenant: "tenant", AzureTenant: "tenant",
AzureSubnet: "azure-subnet", AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group", AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set", AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
},
"missing workers": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing controlplane": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing name": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing uid": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing bootstrapper host": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing resource group": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing location": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing subscription": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureTenant: "tenant",
AzureLocation: "location",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing tenant": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureSubscription: "subscription",
AzureLocation: "location",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing subnet": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing network security group": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing worker scale set": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureControlPlaneScaleSet: "controlplane-scale-set",
},
wantErr: true,
},
"missing controlplane scale set": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureWorkerInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureControlPlaneInstances: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
},
},
Name: "name",
UID: "uid",
BootstrapperHost: "bootstrapper-host",
AzureResourceGroup: "resource-group",
AzureLocation: "location",
AzureSubscription: "subscription",
AzureTenant: "tenant",
AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group",
AzureWorkerScaleSet: "worker-scale-set",
}, },
wantErr: true, wantErr: true,
}, },
@ -414,8 +414,8 @@ func TestSetGetState(t *testing.T) {
assert.Error(client.SetState(tc.state)) assert.Error(client.SetState(tc.state))
} else { } else {
assert.NoError(client.SetState(tc.state)) assert.NoError(client.SetState(tc.state))
assert.Equal(tc.state.AzureWorkers, client.workers) assert.Equal(tc.state.AzureWorkerInstances, client.workers)
assert.Equal(tc.state.AzureControlPlane, client.controlPlanes) assert.Equal(tc.state.AzureControlPlaneInstances, client.controlPlanes)
assert.Equal(tc.state.Name, client.name) assert.Equal(tc.state.Name, client.name)
assert.Equal(tc.state.UID, client.uid) assert.Equal(tc.state.UID, client.uid)
assert.Equal(tc.state.AzureResourceGroup, client.resourceGroup) assert.Equal(tc.state.AzureResourceGroup, client.resourceGroup)
@ -424,8 +424,8 @@ func TestSetGetState(t *testing.T) {
assert.Equal(tc.state.AzureTenant, client.tenantID) assert.Equal(tc.state.AzureTenant, client.tenantID)
assert.Equal(tc.state.AzureSubnet, client.subnetID) assert.Equal(tc.state.AzureSubnet, client.subnetID)
assert.Equal(tc.state.AzureNetworkSecurityGroup, client.networkSecurityGroup) assert.Equal(tc.state.AzureNetworkSecurityGroup, client.networkSecurityGroup)
assert.Equal(tc.state.AzureWorkersScaleSet, client.workerScaleSet) assert.Equal(tc.state.AzureWorkerScaleSet, client.workerScaleSet)
assert.Equal(tc.state.AzureControlPlanesScaleSet, client.controlPlaneScaleSet) assert.Equal(tc.state.AzureControlPlaneScaleSet, client.controlPlaneScaleSet)
} }
}) })
} }
@ -437,8 +437,8 @@ func TestSetGetState(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
client := Client{ client := Client{
workers: tc.state.AzureWorkers, workers: tc.state.AzureWorkerInstances,
controlPlanes: tc.state.AzureControlPlane, controlPlanes: tc.state.AzureControlPlaneInstances,
name: tc.state.Name, name: tc.state.Name,
uid: tc.state.UID, uid: tc.state.UID,
loadBalancerPubIP: tc.state.BootstrapperHost, loadBalancerPubIP: tc.state.BootstrapperHost,
@ -448,8 +448,8 @@ func TestSetGetState(t *testing.T) {
tenantID: tc.state.AzureTenant, tenantID: tc.state.AzureTenant,
subnetID: tc.state.AzureSubnet, subnetID: tc.state.AzureSubnet,
networkSecurityGroup: tc.state.AzureNetworkSecurityGroup, networkSecurityGroup: tc.state.AzureNetworkSecurityGroup,
workerScaleSet: tc.state.AzureWorkersScaleSet, workerScaleSet: tc.state.AzureWorkerScaleSet,
controlPlaneScaleSet: tc.state.AzureControlPlanesScaleSet, controlPlaneScaleSet: tc.state.AzureControlPlaneScaleSet,
} }
if tc.wantErr { if tc.wantErr {
_, err := client.GetState() _, err := client.GetState()
@ -469,52 +469,52 @@ func TestSetStateCloudProvider(t *testing.T) {
client := Client{} client := Client{}
stateMissingCloudProvider := state.ConstellationState{ stateMissingCloudProvider := state.ConstellationState{
AzureWorkers: cloudtypes.Instances{ AzureWorkerInstances: cloudtypes.Instances{
"0": { "0": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
AzureControlPlane: cloudtypes.Instances{ AzureControlPlaneInstances: cloudtypes.Instances{
"0": { "0": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
}, },
}, },
Name: "name", Name: "name",
UID: "uid", UID: "uid",
AzureResourceGroup: "resource-group", AzureResourceGroup: "resource-group",
AzureLocation: "location", AzureLocation: "location",
AzureSubscription: "subscription", AzureSubscription: "subscription",
AzureSubnet: "azure-subnet", AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group", AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set", AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set", AzureControlPlaneScaleSet: "controlplane-scale-set",
} }
assert.Error(client.SetState(stateMissingCloudProvider)) assert.Error(client.SetState(stateMissingCloudProvider))
stateIncorrectCloudProvider := state.ConstellationState{ stateIncorrectCloudProvider := state.ConstellationState{
CloudProvider: "incorrect", CloudProvider: "incorrect",
AzureWorkers: cloudtypes.Instances{ AzureWorkerInstances: cloudtypes.Instances{
"0": { "0": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
AzureControlPlane: cloudtypes.Instances{ AzureControlPlaneInstances: cloudtypes.Instances{
"0": { "0": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
}, },
}, },
Name: "name", Name: "name",
UID: "uid", UID: "uid",
AzureResourceGroup: "resource-group", AzureResourceGroup: "resource-group",
AzureLocation: "location", AzureLocation: "location",
AzureSubscription: "subscription", AzureSubscription: "subscription",
AzureSubnet: "azure-subnet", AzureSubnet: "azure-subnet",
AzureNetworkSecurityGroup: "network-security-group", AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "worker-scale-set", AzureWorkerScaleSet: "worker-scale-set",
AzureControlPlanesScaleSet: "controlplane-scale-set", AzureControlPlaneScaleSet: "controlplane-scale-set",
} }
assert.Error(client.SetState(stateIncorrectCloudProvider)) assert.Error(client.SetState(stateIncorrectCloudProvider))
} }

View File

@ -44,8 +44,8 @@ type fakeAzureClient struct {
func (c *fakeAzureClient) GetState() (state.ConstellationState, error) { func (c *fakeAzureClient) GetState() (state.ConstellationState, error) {
stat := state.ConstellationState{ stat := state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(), CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: c.workers, AzureWorkerInstances: c.workers,
AzureControlPlane: c.controlPlanes, AzureControlPlaneInstances: c.controlPlanes,
Name: c.name, Name: c.name,
UID: c.uid, UID: c.uid,
AzureResourceGroup: c.resourceGroup, AzureResourceGroup: c.resourceGroup,
@ -54,16 +54,16 @@ func (c *fakeAzureClient) GetState() (state.ConstellationState, error) {
AzureTenant: c.tenantID, AzureTenant: c.tenantID,
AzureSubnet: c.subnetID, AzureSubnet: c.subnetID,
AzureNetworkSecurityGroup: c.networkSecurityGroup, AzureNetworkSecurityGroup: c.networkSecurityGroup,
AzureWorkersScaleSet: c.workerScaleSet, AzureWorkerScaleSet: c.workerScaleSet,
AzureControlPlanesScaleSet: c.controlPlaneScaleSet, AzureControlPlaneScaleSet: c.controlPlaneScaleSet,
AzureADAppObjectID: c.adAppObjectID, AzureADAppObjectID: c.adAppObjectID,
} }
return stat, nil return stat, nil
} }
func (c *fakeAzureClient) SetState(stat state.ConstellationState) error { func (c *fakeAzureClient) SetState(stat state.ConstellationState) error {
c.workers = stat.AzureWorkers c.workers = stat.AzureWorkerInstances
c.controlPlanes = stat.AzureControlPlane c.controlPlanes = stat.AzureControlPlaneInstances
c.name = stat.Name c.name = stat.Name
c.uid = stat.UID c.uid = stat.UID
c.resourceGroup = stat.AzureResourceGroup c.resourceGroup = stat.AzureResourceGroup
@ -72,8 +72,8 @@ func (c *fakeAzureClient) SetState(stat state.ConstellationState) error {
c.tenantID = stat.AzureTenant c.tenantID = stat.AzureTenant
c.subnetID = stat.AzureSubnet c.subnetID = stat.AzureSubnet
c.networkSecurityGroup = stat.AzureNetworkSecurityGroup c.networkSecurityGroup = stat.AzureNetworkSecurityGroup
c.workerScaleSet = stat.AzureWorkersScaleSet c.workerScaleSet = stat.AzureWorkerScaleSet
c.controlPlaneScaleSet = stat.AzureControlPlanesScaleSet c.controlPlaneScaleSet = stat.AzureControlPlaneScaleSet
c.adAppObjectID = stat.AzureADAppObjectID c.adAppObjectID = stat.AzureADAppObjectID
return nil return nil
} }
@ -260,8 +260,8 @@ type fakeGcpClient struct {
func (c *fakeGcpClient) GetState() (state.ConstellationState, error) { func (c *fakeGcpClient) GetState() (state.ConstellationState, error) {
stat := state.ConstellationState{ stat := state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: c.workers, GCPWorkerInstances: c.workers,
GCPControlPlanes: c.controlPlanes, GCPControlPlaneInstances: c.controlPlanes,
GCPWorkerInstanceGroup: c.workerInstanceGroup, GCPWorkerInstanceGroup: c.workerInstanceGroup,
GCPControlPlaneInstanceGroup: c.controlPlaneInstanceGroup, GCPControlPlaneInstanceGroup: c.controlPlaneInstanceGroup,
GCPWorkerInstanceTemplate: c.workerTemplate, GCPWorkerInstanceTemplate: c.workerTemplate,
@ -282,8 +282,8 @@ func (c *fakeGcpClient) GetState() (state.ConstellationState, error) {
} }
func (c *fakeGcpClient) SetState(stat state.ConstellationState) error { func (c *fakeGcpClient) SetState(stat state.ConstellationState) error {
c.workers = stat.GCPWorkers c.workers = stat.GCPWorkerInstances
c.controlPlanes = stat.GCPControlPlanes c.controlPlanes = stat.GCPControlPlaneInstances
c.workerInstanceGroup = stat.GCPWorkerInstanceGroup c.workerInstanceGroup = stat.GCPWorkerInstanceGroup
c.controlPlaneInstanceGroup = stat.GCPControlPlaneInstanceGroup c.controlPlaneInstanceGroup = stat.GCPControlPlaneInstanceGroup
c.workerTemplate = stat.GCPWorkerInstanceTemplate c.workerTemplate = stat.GCPWorkerInstanceTemplate

View File

@ -17,11 +17,11 @@ func TestCreator(t *testing.T) {
wantGCPState := state.ConstellationState{ wantGCPState := state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPProject: "project", GCPProject: "project",
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-2": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-2": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
@ -44,20 +44,20 @@ func TestCreator(t *testing.T) {
wantAzureState := state.ConstellationState{ wantAzureState := state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(), CloudProvider: cloudprovider.Azure.String(),
AzureControlPlane: cloudtypes.Instances{ AzureControlPlaneInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
AzureWorkers: cloudtypes.Instances{ AzureWorkerInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-2": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-2": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
AzureResourceGroup: "resource-group", AzureResourceGroup: "resource-group",
AzureSubnet: "subnet", AzureSubnet: "subnet",
AzureNetworkSecurityGroup: "network-security-group", AzureNetworkSecurityGroup: "network-security-group",
AzureWorkersScaleSet: "workers-scale-set", AzureWorkerScaleSet: "workers-scale-set",
AzureControlPlanesScaleSet: "controlplanes-scale-set", AzureControlPlaneScaleSet: "controlplanes-scale-set",
} }
someErr := errors.New("failed") someErr := errors.New("failed")

View File

@ -17,8 +17,8 @@ func TestServiceAccountCreator(t *testing.T) {
return state.ConstellationState{ return state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPProject: "project", GCPProject: "project",
GCPWorkers: cloudtypes.Instances{}, GCPWorkerInstances: cloudtypes.Instances{},
GCPControlPlanes: cloudtypes.Instances{}, GCPControlPlaneInstances: cloudtypes.Instances{},
GCPWorkerInstanceGroup: "workers-group", GCPWorkerInstanceGroup: "workers-group",
GCPControlPlaneInstanceGroup: "controlplane-group", GCPControlPlaneInstanceGroup: "controlplane-group",
GCPWorkerInstanceTemplate: "template", GCPWorkerInstanceTemplate: "template",

View File

@ -16,11 +16,11 @@ func TestTerminator(t *testing.T) {
return state.ConstellationState{ return state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPProject: "project", GCPProject: "project",
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
GCPWorkerInstanceGroup: "worker-group", GCPWorkerInstanceGroup: "worker-group",
@ -35,11 +35,11 @@ func TestTerminator(t *testing.T) {
someAzureState := func() state.ConstellationState { someAzureState := func() state.ConstellationState {
return state.ConstellationState{ return state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(), CloudProvider: cloudprovider.Azure.String(),
AzureWorkers: cloudtypes.Instances{ AzureWorkerInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
AzureControlPlane: cloudtypes.Instances{ AzureControlPlaneInstances: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
AzureResourceGroup: "group", AzureResourceGroup: "group",

View File

@ -325,11 +325,11 @@ func readOrGenerateMasterSecret(writer io.Writer, fileHandler file.Handler, file
func getScalingGroupsFromState(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) { func getScalingGroupsFromState(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
switch { switch {
case len(stat.GCPControlPlanes) != 0: case len(stat.GCPControlPlaneInstances) != 0:
return getGCPInstances(stat, config) return getGCPInstances(stat, config)
case len(stat.AzureControlPlane) != 0: case len(stat.AzureControlPlaneInstances) != 0:
return getAzureInstances(stat, config) return getAzureInstances(stat, config)
case len(stat.QEMUControlPlane) != 0: case len(stat.QEMUControlPlaneInstances) != 0:
return getQEMUInstances(stat, config) return getQEMUInstances(stat, config)
default: default:
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no instances to initialize") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no instances to initialize")
@ -337,23 +337,23 @@ func getScalingGroupsFromState(stat state.ConstellationState, config *config.Con
} }
func getGCPInstances(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) { func getGCPInstances(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
if len(stat.GCPControlPlanes) == 0 { if len(stat.GCPControlPlaneInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation without any instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation without any instance")
} }
// GroupID of controlPlanes is empty, since they currently do not scale. // GroupID of controlPlanes is empty, since they currently do not scale.
controlPlanes = cloudtypes.ScalingGroup{ controlPlanes = cloudtypes.ScalingGroup{
Instances: stat.GCPControlPlanes, Instances: stat.GCPControlPlaneInstances,
GroupID: "", GroupID: "",
} }
if len(stat.GCPWorkers) == 0 { if len(stat.GCPWorkerInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no worker workers available, can't create Constellation with one instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no worker workers available, can't create Constellation with one instance")
} }
// TODO: make min / max configurable and abstract autoscaling for different cloud providers // TODO: make min / max configurable and abstract autoscaling for different cloud providers
workers = cloudtypes.ScalingGroup{ workers = cloudtypes.ScalingGroup{
Instances: stat.GCPWorkers, Instances: stat.GCPWorkerInstances,
GroupID: gcp.AutoscalingNodeGroup(stat.GCPProject, stat.GCPZone, stat.GCPWorkerInstanceGroup, config.AutoscalingNodeGroupMin, config.AutoscalingNodeGroupMax), GroupID: gcp.AutoscalingNodeGroup(stat.GCPProject, stat.GCPZone, stat.GCPWorkerInstanceGroup, config.AutoscalingNodeGroupMin, config.AutoscalingNodeGroupMax),
} }
@ -361,47 +361,47 @@ func getGCPInstances(stat state.ConstellationState, config *config.Config) (cont
} }
func getAzureInstances(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) { func getAzureInstances(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
if len(stat.AzureControlPlane) == 0 { if len(stat.AzureControlPlaneInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation cluster without any instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation cluster without any instance")
} }
// GroupID of controlPlanes is empty, since they currently do not scale. // GroupID of controlPlanes is empty, since they currently do not scale.
controlPlanes = cloudtypes.ScalingGroup{ controlPlanes = cloudtypes.ScalingGroup{
Instances: stat.AzureControlPlane, Instances: stat.AzureControlPlaneInstances,
GroupID: "", GroupID: "",
} }
if len(stat.AzureWorkers) == 0 { if len(stat.AzureWorkerInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no worker workers available, can't create Constellation cluster with one instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no worker workers available, can't create Constellation cluster with one instance")
} }
// TODO: make min / max configurable and abstract autoscaling for different cloud providers // TODO: make min / max configurable and abstract autoscaling for different cloud providers
workers = cloudtypes.ScalingGroup{ workers = cloudtypes.ScalingGroup{
Instances: stat.AzureWorkers, Instances: stat.AzureWorkerInstances,
GroupID: azure.AutoscalingNodeGroup(stat.AzureWorkersScaleSet, config.AutoscalingNodeGroupMin, config.AutoscalingNodeGroupMax), GroupID: azure.AutoscalingNodeGroup(stat.AzureWorkerScaleSet, config.AutoscalingNodeGroupMin, config.AutoscalingNodeGroupMax),
} }
return return
} }
func getQEMUInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) { func getQEMUInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
controlPlanesMap := stat.QEMUControlPlane controlPlanesMap := stat.QEMUControlPlaneInstances
if len(controlPlanesMap) == 0 { if len(controlPlanesMap) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no controlPlanes available, can't create Constellation without any instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no controlPlanes available, can't create Constellation without any instance")
} }
// QEMU does not support autoscaling // QEMU does not support autoscaling
controlPlanes = cloudtypes.ScalingGroup{ controlPlanes = cloudtypes.ScalingGroup{
Instances: stat.QEMUControlPlane, Instances: stat.QEMUControlPlaneInstances,
GroupID: "", GroupID: "",
} }
if len(stat.QEMUWorkers) == 0 { if len(stat.QEMUWorkerInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no workers available, can't create Constellation with one instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no workers available, can't create Constellation with one instance")
} }
// QEMU does not support autoscaling // QEMU does not support autoscaling
workers = cloudtypes.ScalingGroup{ workers = cloudtypes.ScalingGroup{
Instances: stat.QEMUWorkers, Instances: stat.QEMUWorkerInstances,
GroupID: "", GroupID: "",
} }
return return

View File

@ -46,22 +46,22 @@ func TestInitialize(t *testing.T) {
testGcpState := state.ConstellationState{ testGcpState := state.ConstellationState{
CloudProvider: "GCP", CloudProvider: "GCP",
BootstrapperHost: "192.0.2.1", BootstrapperHost: "192.0.2.1",
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
} }
testAzureState := state.ConstellationState{ testAzureState := state.ConstellationState{
CloudProvider: "Azure", CloudProvider: "Azure",
BootstrapperHost: "192.0.2.1", BootstrapperHost: "192.0.2.1",
AzureWorkers: cloudtypes.Instances{ AzureWorkerInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
AzureControlPlane: cloudtypes.Instances{ AzureControlPlaneInstances: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
AzureResourceGroup: "test", AzureResourceGroup: "test",
@ -69,11 +69,11 @@ func TestInitialize(t *testing.T) {
testQemuState := state.ConstellationState{ testQemuState := state.ConstellationState{
CloudProvider: "QEMU", CloudProvider: "QEMU",
BootstrapperHost: "192.0.2.1", BootstrapperHost: "192.0.2.1",
QEMUWorkers: cloudtypes.Instances{ QEMUWorkerInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
QEMUControlPlane: cloudtypes.Instances{ QEMUControlPlaneInstances: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
} }
@ -394,11 +394,11 @@ func TestAttestation(t *testing.T) {
existingState := state.ConstellationState{ existingState := state.ConstellationState{
CloudProvider: "QEMU", CloudProvider: "QEMU",
BootstrapperHost: "192.0.2.1", BootstrapperHost: "192.0.2.1",
QEMUWorkers: cloudtypes.Instances{ QEMUWorkerInstances: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
QEMUControlPlane: cloudtypes.Instances{ QEMUControlPlaneInstances: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"}, "id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
}, },
} }

View File

@ -245,12 +245,12 @@ func (c *Client) GetState() (state.ConstellationState, error) {
if len(c.workers) == 0 { if len(c.workers) == 0 {
return state.ConstellationState{}, errors.New("client has no workers") return state.ConstellationState{}, errors.New("client has no workers")
} }
stat.GCPWorkers = c.workers stat.GCPWorkerInstances = c.workers
if len(c.controlPlanes) == 0 { if len(c.controlPlanes) == 0 {
return state.ConstellationState{}, errors.New("client has no controlPlanes") return state.ConstellationState{}, errors.New("client has no controlPlanes")
} }
stat.GCPControlPlanes = c.controlPlanes stat.GCPControlPlaneInstances = c.controlPlanes
publicIPs := c.controlPlanes.PublicIPs() publicIPs := c.controlPlanes.PublicIPs()
if len(publicIPs) == 0 { if len(publicIPs) == 0 {
return state.ConstellationState{}, errors.New("client has no bootstrapper endpoint") return state.ConstellationState{}, errors.New("client has no bootstrapper endpoint")
@ -343,15 +343,15 @@ func (c *Client) SetState(stat state.ConstellationState) error {
if stat.CloudProvider != cloudprovider.GCP.String() { if stat.CloudProvider != cloudprovider.GCP.String() {
return errors.New("state is not gcp state") return errors.New("state is not gcp state")
} }
if len(stat.GCPWorkers) == 0 { if len(stat.GCPWorkerInstances) == 0 {
return errors.New("state has no workers") return errors.New("state has no workers")
} }
c.workers = stat.GCPWorkers c.workers = stat.GCPWorkerInstances
if len(stat.GCPControlPlanes) == 0 { if len(stat.GCPControlPlaneInstances) == 0 {
return errors.New("state has no controlPlane") return errors.New("state has no controlPlane")
} }
c.controlPlanes = stat.GCPControlPlanes c.controlPlanes = stat.GCPControlPlaneInstances
if stat.GCPWorkerInstanceGroup == "" { if stat.GCPWorkerInstanceGroup == "" {
return errors.New("state has no workerInstanceGroup") return errors.New("state has no workerInstanceGroup")

View File

@ -27,13 +27,13 @@ func TestSetGetState(t *testing.T) {
"valid state": { "valid state": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -61,7 +61,7 @@ func TestSetGetState(t *testing.T) {
"missing workers": { "missing workers": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -89,7 +89,7 @@ func TestSetGetState(t *testing.T) {
"missing control plane": { "missing control plane": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
@ -117,13 +117,13 @@ func TestSetGetState(t *testing.T) {
"missing worker group": { "missing worker group": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -150,13 +150,13 @@ func TestSetGetState(t *testing.T) {
"missing control plane group": { "missing control plane group": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -183,13 +183,13 @@ func TestSetGetState(t *testing.T) {
"missing project id": { "missing project id": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -216,13 +216,13 @@ func TestSetGetState(t *testing.T) {
"missing zone": { "missing zone": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -249,13 +249,13 @@ func TestSetGetState(t *testing.T) {
"missing region": { "missing region": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -282,13 +282,13 @@ func TestSetGetState(t *testing.T) {
"missing name": { "missing name": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -314,13 +314,13 @@ func TestSetGetState(t *testing.T) {
"missing uid": { "missing uid": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -347,13 +347,13 @@ func TestSetGetState(t *testing.T) {
"missing firewalls": { "missing firewalls": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -380,13 +380,13 @@ func TestSetGetState(t *testing.T) {
"missing network": { "missing network": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -412,13 +412,13 @@ func TestSetGetState(t *testing.T) {
"missing external network": { "missing external network": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -445,13 +445,13 @@ func TestSetGetState(t *testing.T) {
"missing subnetwork": { "missing subnetwork": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -478,13 +478,13 @@ func TestSetGetState(t *testing.T) {
"missing external subnetwork": { "missing external subnetwork": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -511,13 +511,13 @@ func TestSetGetState(t *testing.T) {
"missing worker template": { "missing worker template": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -544,13 +544,13 @@ func TestSetGetState(t *testing.T) {
"missing control plane template": { "missing control plane template": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -577,13 +577,13 @@ func TestSetGetState(t *testing.T) {
"missing backend service": { "missing backend service": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -610,13 +610,13 @@ func TestSetGetState(t *testing.T) {
"missing health check": { "missing health check": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -643,13 +643,13 @@ func TestSetGetState(t *testing.T) {
"missing forwarding rule": { "missing forwarding rule": {
state: state.ConstellationState{ state: state.ConstellationState{
CloudProvider: cloudprovider.GCP.String(), CloudProvider: cloudprovider.GCP.String(),
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -685,8 +685,8 @@ func TestSetGetState(t *testing.T) {
assert.Error(client.SetState(tc.state)) assert.Error(client.SetState(tc.state))
} else { } else {
assert.NoError(client.SetState(tc.state)) assert.NoError(client.SetState(tc.state))
assert.Equal(tc.state.GCPWorkers, client.workers) assert.Equal(tc.state.GCPWorkerInstances, client.workers)
assert.Equal(tc.state.GCPControlPlanes, client.controlPlanes) assert.Equal(tc.state.GCPControlPlaneInstances, client.controlPlanes)
assert.Equal(tc.state.GCPWorkerInstanceGroup, client.workerInstanceGroup) assert.Equal(tc.state.GCPWorkerInstanceGroup, client.workerInstanceGroup)
assert.Equal(tc.state.GCPControlPlaneInstanceGroup, client.controlPlaneInstanceGroup) assert.Equal(tc.state.GCPControlPlaneInstanceGroup, client.controlPlaneInstanceGroup)
assert.Equal(tc.state.GCPProject, client.project) assert.Equal(tc.state.GCPProject, client.project)
@ -709,8 +709,8 @@ func TestSetGetState(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
client := Client{ client := Client{
workers: tc.state.GCPWorkers, workers: tc.state.GCPWorkerInstances,
controlPlanes: tc.state.GCPControlPlanes, controlPlanes: tc.state.GCPControlPlaneInstances,
workerInstanceGroup: tc.state.GCPWorkerInstanceGroup, workerInstanceGroup: tc.state.GCPWorkerInstanceGroup,
controlPlaneInstanceGroup: tc.state.GCPControlPlaneInstanceGroup, controlPlaneInstanceGroup: tc.state.GCPControlPlaneInstanceGroup,
project: tc.state.GCPProject, project: tc.state.GCPProject,
@ -746,13 +746,13 @@ func TestSetStateCloudProvider(t *testing.T) {
client := Client{} client := Client{}
stateMissingCloudProvider := state.ConstellationState{ stateMissingCloudProvider := state.ConstellationState{
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",
@ -778,13 +778,13 @@ func TestSetStateCloudProvider(t *testing.T) {
assert.Error(client.SetState(stateMissingCloudProvider)) assert.Error(client.SetState(stateMissingCloudProvider))
stateIncorrectCloudProvider := state.ConstellationState{ stateIncorrectCloudProvider := state.ConstellationState{
CloudProvider: "incorrect", CloudProvider: "incorrect",
GCPWorkers: cloudtypes.Instances{ GCPWorkerInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip1", PublicIP: "ip1",
PrivateIP: "ip2", PrivateIP: "ip2",
}, },
}, },
GCPControlPlanes: cloudtypes.Instances{ GCPControlPlaneInstances: cloudtypes.Instances{
"id-1": { "id-1": {
PublicIP: "ip3", PublicIP: "ip3",
PrivateIP: "ip4", PrivateIP: "ip4",

View File

@ -13,11 +13,11 @@ import (
func GetScalingGroupsFromConfig(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) { func GetScalingGroupsFromConfig(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
switch { switch {
case len(stat.GCPControlPlanes) != 0: case len(stat.GCPControlPlaneInstances) != 0:
return getGCPInstances(stat, config) return getGCPInstances(stat, config)
case len(stat.AzureControlPlane) != 0: case len(stat.AzureControlPlaneInstances) != 0:
return getAzureInstances(stat, config) return getAzureInstances(stat, config)
case len(stat.QEMUControlPlane) != 0: case len(stat.QEMUControlPlaneInstances) != 0:
return getQEMUInstances(stat, config) return getQEMUInstances(stat, config)
default: default:
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no instances to init") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no instances to init")
@ -25,54 +25,54 @@ func GetScalingGroupsFromConfig(stat state.ConstellationState, config *config.Co
} }
func getGCPInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) { func getGCPInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
if len(stat.GCPControlPlanes) == 0 { if len(stat.GCPControlPlaneInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation without any instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation without any instance")
} }
// GroupID of controlPlanes is empty, since they currently do not scale. // GroupID of controlPlanes is empty, since they currently do not scale.
controlPlanes = cloudtypes.ScalingGroup{Instances: stat.GCPControlPlanes} controlPlanes = cloudtypes.ScalingGroup{Instances: stat.GCPControlPlaneInstances}
if len(stat.GCPWorkers) == 0 { if len(stat.GCPWorkerInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no worker workers available, can't create Constellation with one instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no worker workers available, can't create Constellation with one instance")
} }
// TODO: make min / max configurable and abstract autoscaling for different cloud providers // TODO: make min / max configurable and abstract autoscaling for different cloud providers
workers = cloudtypes.ScalingGroup{Instances: stat.GCPWorkers} workers = cloudtypes.ScalingGroup{Instances: stat.GCPWorkerInstances}
return return
} }
func getAzureInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) { func getAzureInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
if len(stat.AzureControlPlane) == 0 { if len(stat.AzureControlPlaneInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation cluster without any instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation cluster without any instance")
} }
// GroupID of controlPlanes is empty, since they currently do not scale. // GroupID of controlPlanes is empty, since they currently do not scale.
controlPlanes = cloudtypes.ScalingGroup{Instances: stat.AzureControlPlane} controlPlanes = cloudtypes.ScalingGroup{Instances: stat.AzureControlPlaneInstances}
if len(stat.AzureWorkers) == 0 { if len(stat.AzureWorkerInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no worker workers available, can't create Constellation cluster with one instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no worker workers available, can't create Constellation cluster with one instance")
} }
// TODO: make min / max configurable and abstract autoscaling for different cloud providers // TODO: make min / max configurable and abstract autoscaling for different cloud providers
workers = cloudtypes.ScalingGroup{Instances: stat.AzureWorkers} workers = cloudtypes.ScalingGroup{Instances: stat.AzureWorkerInstances}
return return
} }
func getQEMUInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) { func getQEMUInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
controlPlaneMap := stat.QEMUControlPlane controlPlaneMap := stat.QEMUControlPlaneInstances
if len(controlPlaneMap) == 0 { if len(controlPlaneMap) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no controlPlanes available, can't create Constellation without any instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no controlPlanes available, can't create Constellation without any instance")
} }
// QEMU does not support autoscaling // QEMU does not support autoscaling
controlPlanes = cloudtypes.ScalingGroup{Instances: stat.QEMUControlPlane} controlPlanes = cloudtypes.ScalingGroup{Instances: stat.QEMUControlPlaneInstances}
if len(stat.QEMUWorkers) == 0 { if len(stat.QEMUWorkerInstances) == 0 {
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no workers available, can't create Constellation with one instance") return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no workers available, can't create Constellation with one instance")
} }
// QEMU does not support autoscaling // QEMU does not support autoscaling
workers = cloudtypes.ScalingGroup{Instances: stat.QEMUWorkers} workers = cloudtypes.ScalingGroup{Instances: stat.QEMUWorkerInstances}
return return
} }

View File

@ -39,21 +39,21 @@ func terraformOut(workspaceDir string) (terraformOutput, error) {
func transformState(tfOut terraformOutput) state.ConstellationState { func transformState(tfOut terraformOutput) state.ConstellationState {
conState := state.ConstellationState{ conState := state.ConstellationState{
Name: "qemu", Name: "qemu",
UID: "debug", UID: "debug",
CloudProvider: cloudprovider.QEMU.String(), CloudProvider: cloudprovider.QEMU.String(),
BootstrapperHost: tfOut.ControlPlaneIPs.Value[0], BootstrapperHost: tfOut.ControlPlaneIPs.Value[0],
QEMUWorkers: cloudtypes.Instances{}, QEMUWorkerInstances: cloudtypes.Instances{},
QEMUControlPlane: cloudtypes.Instances{}, QEMUControlPlaneInstances: cloudtypes.Instances{},
} }
for i, ip := range tfOut.ControlPlaneIPs.Value { for i, ip := range tfOut.ControlPlaneIPs.Value {
conState.QEMUControlPlane[fmt.Sprintf("control-plane-%d", i)] = cloudtypes.Instance{ conState.QEMUControlPlaneInstances[fmt.Sprintf("control-plane-%d", i)] = cloudtypes.Instance{
PublicIP: ip, PublicIP: ip,
PrivateIP: ip, PrivateIP: ip,
} }
} }
for i, ip := range tfOut.WorkerIPs.Value { for i, ip := range tfOut.WorkerIPs.Value {
conState.QEMUWorkers[fmt.Sprintf("worker-%d", i)] = cloudtypes.Instance{ conState.QEMUWorkerInstances[fmt.Sprintf("worker-%d", i)] = cloudtypes.Instance{
PublicIP: ip, PublicIP: ip,
PrivateIP: ip, PrivateIP: ip,
} }

View File

@ -11,8 +11,8 @@ type ConstellationState struct {
CloudProvider string `json:"cloudprovider,omitempty"` CloudProvider string `json:"cloudprovider,omitempty"`
BootstrapperHost string `json:"bootstrapperhost,omitempty"` BootstrapperHost string `json:"bootstrapperhost,omitempty"`
GCPWorkers cloudtypes.Instances `json:"gcpworkers,omitempty"` GCPWorkerInstances cloudtypes.Instances `json:"gcpworkers,omitempty"`
GCPControlPlanes cloudtypes.Instances `json:"gcpcontrolplanes,omitempty"` GCPControlPlaneInstances cloudtypes.Instances `json:"gcpcontrolplanes,omitempty"`
GCPWorkerInstanceGroup string `json:"gcpworkerinstancegroup,omitempty"` GCPWorkerInstanceGroup string `json:"gcpworkerinstancegroup,omitempty"`
GCPControlPlaneInstanceGroup string `json:"gcpcontrolplaneinstancegroup,omitempty"` GCPControlPlaneInstanceGroup string `json:"gcpcontrolplaneinstancegroup,omitempty"`
GCPWorkerInstanceTemplate string `json:"gcpworkerinstancetemplate,omitempty"` GCPWorkerInstanceTemplate string `json:"gcpworkerinstancetemplate,omitempty"`
@ -28,18 +28,18 @@ type ConstellationState struct {
GCPRegion string `json:"gcpregion,omitempty"` GCPRegion string `json:"gcpregion,omitempty"`
GCPServiceAccount string `json:"gcpserviceaccount,omitempty"` GCPServiceAccount string `json:"gcpserviceaccount,omitempty"`
AzureWorkers cloudtypes.Instances `json:"azureworkers,omitempty"` AzureWorkerInstances cloudtypes.Instances `json:"azureworkers,omitempty"`
AzureControlPlane cloudtypes.Instances `json:"azurecontrolplanes,omitempty"` AzureControlPlaneInstances cloudtypes.Instances `json:"azurecontrolplanes,omitempty"`
AzureResourceGroup string `json:"azureresourcegroup,omitempty"` AzureResourceGroup string `json:"azureresourcegroup,omitempty"`
AzureLocation string `json:"azurelocation,omitempty"` AzureLocation string `json:"azurelocation,omitempty"`
AzureSubscription string `json:"azuresubscription,omitempty"` AzureSubscription string `json:"azuresubscription,omitempty"`
AzureTenant string `json:"azuretenant,omitempty"` AzureTenant string `json:"azuretenant,omitempty"`
AzureSubnet string `json:"azuresubnet,omitempty"` AzureSubnet string `json:"azuresubnet,omitempty"`
AzureNetworkSecurityGroup string `json:"azurenetworksecuritygroup,omitempty"` AzureNetworkSecurityGroup string `json:"azurenetworksecuritygroup,omitempty"`
AzureWorkersScaleSet string `json:"azureworkersscaleset,omitempty"` AzureWorkerScaleSet string `json:"azureworkersscaleset,omitempty"`
AzureControlPlanesScaleSet string `json:"azurecontrolplanesscaleset,omitempty"` AzureControlPlaneScaleSet string `json:"azurecontrolplanesscaleset,omitempty"`
AzureADAppObjectID string `json:"azureadappobjectid,omitempty"` AzureADAppObjectID string `json:"azureadappobjectid,omitempty"`
QEMUWorkers cloudtypes.Instances `json:"qemuworkers,omitempty"` QEMUWorkerInstances cloudtypes.Instances `json:"qemuworkers,omitempty"`
QEMUControlPlane cloudtypes.Instances `json:"qemucontrolplanes,omitempty"` QEMUControlPlaneInstances cloudtypes.Instances `json:"qemucontrolplanes,omitempty"`
} }