mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-06-19 11:44:20 -04:00
cli: refactor terraform output parsing (#2158)
This commit is contained in:
parent
dccb1dfde9
commit
720c48ea45
1 changed files with 38 additions and 34 deletions
|
@ -216,45 +216,49 @@ func (c *Client) ShowCluster(ctx context.Context, provider cloudprovider.Provide
|
||||||
Secret: secret,
|
Secret: secret,
|
||||||
UID: uid,
|
UID: uid,
|
||||||
}
|
}
|
||||||
// TODO add provider
|
|
||||||
switch provider {
|
switch provider {
|
||||||
case cloudprovider.GCP:
|
case cloudprovider.GCP:
|
||||||
gcpProjectOutput, ok := tfState.Values.Outputs["project"]
|
gcpProjectOutput, ok := tfState.Values.Outputs["project"]
|
||||||
if ok {
|
if !ok {
|
||||||
gcpProject, ok := gcpProjectOutput.Value.(string)
|
return ApplyOutput{}, errors.New("no project output found")
|
||||||
if !ok {
|
}
|
||||||
return ApplyOutput{}, errors.New("invalid type in project output: not a string")
|
gcpProject, ok := gcpProjectOutput.Value.(string)
|
||||||
}
|
if !ok {
|
||||||
cidrNodesOutput, ok := tfState.Values.Outputs["ip_cidr_nodes"]
|
return ApplyOutput{}, errors.New("invalid type in project output: not a string")
|
||||||
if !ok {
|
}
|
||||||
return ApplyOutput{}, errors.New("no ip_cidr_nodes output found")
|
|
||||||
}
|
cidrNodesOutput, ok := tfState.Values.Outputs["ip_cidr_nodes"]
|
||||||
cidrNodes, ok := cidrNodesOutput.Value.(string)
|
if !ok {
|
||||||
if !ok {
|
return ApplyOutput{}, errors.New("no ip_cidr_nodes output found")
|
||||||
return ApplyOutput{}, errors.New("invalid type in ip_cidr_nodes output: not a string")
|
}
|
||||||
}
|
cidrNodes, ok := cidrNodesOutput.Value.(string)
|
||||||
cidrPodsOutput, ok := tfState.Values.Outputs["ip_cidr_pods"]
|
if !ok {
|
||||||
if !ok {
|
return ApplyOutput{}, errors.New("invalid type in ip_cidr_nodes output: not a string")
|
||||||
return ApplyOutput{}, errors.New("no ip_cidr_pods output found")
|
}
|
||||||
}
|
|
||||||
cidrPods, ok := cidrPodsOutput.Value.(string)
|
cidrPodsOutput, ok := tfState.Values.Outputs["ip_cidr_pods"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return ApplyOutput{}, errors.New("invalid type in ip_cidr_pods output: not a string")
|
return ApplyOutput{}, errors.New("no ip_cidr_pods output found")
|
||||||
}
|
}
|
||||||
res.GCP = &GCPApplyOutput{
|
cidrPods, ok := cidrPodsOutput.Value.(string)
|
||||||
ProjectID: gcpProject,
|
if !ok {
|
||||||
IPCidrNode: cidrNodes,
|
return ApplyOutput{}, errors.New("invalid type in ip_cidr_pods output: not a string")
|
||||||
IPCidrPod: cidrPods,
|
}
|
||||||
}
|
|
||||||
|
res.GCP = &GCPApplyOutput{
|
||||||
|
ProjectID: gcpProject,
|
||||||
|
IPCidrNode: cidrNodes,
|
||||||
|
IPCidrPod: cidrPods,
|
||||||
}
|
}
|
||||||
case cloudprovider.Azure:
|
case cloudprovider.Azure:
|
||||||
var attestationURL string
|
attestationURLOutput, ok := tfState.Values.Outputs["attestationURL"]
|
||||||
if ok {
|
if !ok {
|
||||||
if attestationURLOutput, ok := tfState.Values.Outputs["attestationURL"]; ok {
|
return ApplyOutput{}, errors.New("no attestationURL output found")
|
||||||
if attestationURLString, ok := attestationURLOutput.Value.(string); ok {
|
}
|
||||||
attestationURL = attestationURLString
|
attestationURL, ok := attestationURLOutput.Value.(string)
|
||||||
}
|
if !ok {
|
||||||
}
|
return ApplyOutput{}, errors.New("invalid type in attestationURL output: not a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
azureUAMIOutput, ok := tfState.Values.Outputs["user_assigned_identity_client_id"]
|
azureUAMIOutput, ok := tfState.Values.Outputs["user_assigned_identity_client_id"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue