terraform: provide required configuration for yawol on OpenStack

This commit is contained in:
Malte Poll 2024-02-09 17:27:12 +01:00
parent bab27fbc69
commit b5e848a87e
5 changed files with 59 additions and 1 deletions

View File

@ -340,6 +340,18 @@ func (c *Client) ShowInfrastructure(ctx context.Context, provider cloudprovider.
LoadBalancerName: loadBalancerName,
AttestationURL: attestationURL,
}
case cloudprovider.OpenStack:
networkIDOutput, ok := tfState.Values.Outputs["network_id"]
if !ok {
return state.Infrastructure{}, errors.New("no network_id output found")
}
networkID, ok := networkIDOutput.Value.(string)
if !ok {
return state.Infrastructure{}, errors.New("invalid type in network_id output: not a string")
}
res.OpenStack = &state.OpenStack{
NetworkID: networkID,
}
}
return res, nil
}

View File

@ -125,6 +125,8 @@ func extraConstellationServicesValues(
"yawolFloatingID": openStackCfg.FloatingIPPoolID,
"yawolFlavorID": openStackCfg.YawolFlavorID,
"yawolImageID": openStackCfg.YawolImageID,
"yawolNetworkID": output.OpenStack.NetworkID,
"yawolAPIHost": fmt.Sprintf("https://%s:%d", output.InClusterEndpoint, constants.KubernetesPort),
}
}
case cloudprovider.GCP:

View File

@ -132,6 +132,9 @@ type Infrastructure struct {
// description: |
// Values specific to a Constellation cluster running on GCP.
GCP *GCP `yaml:"gcp,omitempty"`
// description: |
// Values specific to a Constellation cluster running on OpenStack.
OpenStack *OpenStack `yaml:"openstack,omitempty"`
}
// GCP describes the infra state related to GCP.
@ -168,6 +171,13 @@ type Azure struct {
AttestationURL string `yaml:"attestationURL"`
}
// OpenStack describes the infra state related to OpenStack.
type OpenStack struct {
// description: |
// ID of the network
NetworkID string `yaml:"networkID"`
}
// New creates a new cluster state (file).
func New() *State {
return &State{

View File

@ -16,6 +16,7 @@ var (
InfrastructureDoc encoder.Doc
GCPDoc encoder.Doc
AzureDoc encoder.Doc
OpenStackDoc encoder.Doc
)
func init() {
@ -74,7 +75,7 @@ func init() {
FieldName: "infrastructure",
},
}
InfrastructureDoc.Fields = make([]encoder.Doc, 9)
InfrastructureDoc.Fields = make([]encoder.Doc, 10)
InfrastructureDoc.Fields[0].Name = "uid"
InfrastructureDoc.Fields[0].Type = "string"
InfrastructureDoc.Fields[0].Note = ""
@ -120,6 +121,11 @@ func init() {
InfrastructureDoc.Fields[8].Note = ""
InfrastructureDoc.Fields[8].Description = "Values specific to a Constellation cluster running on GCP."
InfrastructureDoc.Fields[8].Comments[encoder.LineComment] = "Values specific to a Constellation cluster running on GCP."
InfrastructureDoc.Fields[9].Name = "openstack"
InfrastructureDoc.Fields[9].Type = "OpenStack"
InfrastructureDoc.Fields[9].Note = ""
InfrastructureDoc.Fields[9].Description = "Values specific to a Constellation cluster running on OpenStack."
InfrastructureDoc.Fields[9].Comments[encoder.LineComment] = "Values specific to a Constellation cluster running on OpenStack."
GCPDoc.Type = "GCP"
GCPDoc.Comments[encoder.LineComment] = "GCP describes the infra state related to GCP."
@ -182,6 +188,22 @@ func init() {
AzureDoc.Fields[5].Note = ""
AzureDoc.Fields[5].Description = "MAA endpoint that can be used as a fallback for veryifying the ID key digests\nin the cluster's attestation report if the enforcement policy is set accordingly.\nCan be left empty otherwise."
AzureDoc.Fields[5].Comments[encoder.LineComment] = "MAA endpoint that can be used as a fallback for veryifying the ID key digests"
OpenStackDoc.Type = "OpenStack"
OpenStackDoc.Comments[encoder.LineComment] = "OpenStack describes the infra state related to OpenStack."
OpenStackDoc.Description = "OpenStack describes the infra state related to OpenStack."
OpenStackDoc.AppearsIn = []encoder.Appearance{
{
TypeName: "Infrastructure",
FieldName: "openstack",
},
}
OpenStackDoc.Fields = make([]encoder.Doc, 1)
OpenStackDoc.Fields[0].Name = "networkID"
OpenStackDoc.Fields[0].Type = "string"
OpenStackDoc.Fields[0].Note = ""
OpenStackDoc.Fields[0].Description = "ID of the network"
OpenStackDoc.Fields[0].Comments[encoder.LineComment] = "ID of the network"
}
func (_ State) Doc() *encoder.Doc {
@ -204,6 +226,10 @@ func (_ Azure) Doc() *encoder.Doc {
return &AzureDoc
}
func (_ OpenStack) Doc() *encoder.Doc {
return &OpenStackDoc
}
// GetConfigurationDoc returns documentation for the file ./state_doc.go.
func GetConfigurationDoc() *encoder.FileDoc {
return &encoder.FileDoc{
@ -215,6 +241,7 @@ func GetConfigurationDoc() *encoder.FileDoc {
&InfrastructureDoc,
&GCPDoc,
&AzureDoc,
&OpenStackDoc,
},
}
}

View File

@ -35,3 +35,10 @@ output "ip_cidr_node" {
value = local.cidr_vpc_subnet_nodes
description = "CIDR block of the node network."
}
# OpenStack-specific outputs
output "network_id" {
value = openstack_networking_network_v2.vpc_network.id
description = "The OpenStack network id the cluster is deployed in."
}