mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-27 07:47:02 -05:00
aws: name instances for CCM
This commit is contained in:
parent
0d0191ba4d
commit
1f9a788c21
@ -96,17 +96,13 @@ func (m *Metadata) Self(ctx context.Context) (metadata.InstanceMetadata, error)
|
|||||||
return metadata.InstanceMetadata{}, fmt.Errorf("retrieving instance identity: %w", err)
|
return metadata.InstanceMetadata{}, fmt.Errorf("retrieving instance identity: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
name, err := readInstanceTag(ctx, m.imds, tagName)
|
|
||||||
if err != nil {
|
|
||||||
return metadata.InstanceMetadata{}, fmt.Errorf("retrieving name tag: %w", err)
|
|
||||||
}
|
|
||||||
instanceRole, err := readInstanceTag(ctx, m.imds, cloud.TagRole)
|
instanceRole, err := readInstanceTag(ctx, m.imds, cloud.TagRole)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return metadata.InstanceMetadata{}, fmt.Errorf("retrieving role tag: %w", err)
|
return metadata.InstanceMetadata{}, fmt.Errorf("retrieving role tag: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return metadata.InstanceMetadata{
|
return metadata.InstanceMetadata{
|
||||||
Name: name,
|
Name: identity.InstanceID,
|
||||||
ProviderID: fmt.Sprintf("aws:///%s/%s", identity.AvailabilityZone, identity.InstanceID),
|
ProviderID: fmt.Sprintf("aws:///%s/%s", identity.AvailabilityZone, identity.InstanceID),
|
||||||
Role: role.FromString(instanceRole),
|
Role: role.FromString(instanceRole),
|
||||||
VPCIP: identity.PrivateIP,
|
VPCIP: identity.PrivateIP,
|
||||||
|
@ -47,12 +47,11 @@ func TestSelf(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
tags: map[string]string{
|
tags: map[string]string{
|
||||||
tagName: "test-instance",
|
|
||||||
cloud.TagRole: "controlplane",
|
cloud.TagRole: "controlplane",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantSelf: metadata.InstanceMetadata{
|
wantSelf: metadata.InstanceMetadata{
|
||||||
Name: "test-instance",
|
Name: "test-instance-id",
|
||||||
ProviderID: "aws:///test-zone/test-instance-id",
|
ProviderID: "aws:///test-zone/test-instance-id",
|
||||||
Role: role.ControlPlane,
|
Role: role.ControlPlane,
|
||||||
VPCIP: "192.0.2.1",
|
VPCIP: "192.0.2.1",
|
||||||
@ -68,12 +67,11 @@ func TestSelf(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
tags: map[string]string{
|
tags: map[string]string{
|
||||||
tagName: "test-instance",
|
|
||||||
cloud.TagRole: "worker",
|
cloud.TagRole: "worker",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantSelf: metadata.InstanceMetadata{
|
wantSelf: metadata.InstanceMetadata{
|
||||||
Name: "test-instance",
|
Name: "test-instance-id",
|
||||||
ProviderID: "aws:///test-zone/test-instance-id",
|
ProviderID: "aws:///test-zone/test-instance-id",
|
||||||
Role: role.Worker,
|
Role: role.Worker,
|
||||||
VPCIP: "192.0.2.1",
|
VPCIP: "192.0.2.1",
|
||||||
@ -102,21 +100,6 @@ func TestSelf(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"name not set": {
|
|
||||||
imds: &stubIMDS{
|
|
||||||
instanceDocumentResp: &imds.GetInstanceIdentityDocumentOutput{
|
|
||||||
InstanceIdentityDocument: imds.InstanceIdentityDocument{
|
|
||||||
InstanceID: "test-instance-id",
|
|
||||||
AvailabilityZone: "test-zone",
|
|
||||||
PrivateIP: "192.0.2.1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tags: map[string]string{
|
|
||||||
cloud.TagRole: "controlplane",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
wantErr: true,
|
|
||||||
},
|
|
||||||
"role not set": {
|
"role not set": {
|
||||||
imds: &stubIMDS{
|
imds: &stubIMDS{
|
||||||
instanceDocumentResp: &imds.GetInstanceIdentityDocumentOutput{
|
instanceDocumentResp: &imds.GetInstanceIdentityDocumentOutput{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user