Skip to content

Commit

Permalink
WIP: Add openstack provider to hcl and json targets
Browse files Browse the repository at this point in the history
  • Loading branch information
ederst committed Apr 29, 2021
1 parent ff8d903 commit 1cabf53
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
14 changes: 1 addition & 13 deletions upup/pkg/fi/cloudup/openstacktasks/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,11 @@ func (_ *Network) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes

type terraformNetwork struct {
Name *string `json:"name,omitempty" cty:"name"`
// LaunchConfigurationName *terraform.Literal `json:"launch_configuration,omitempty" cty:"launch_configuration"`
// LaunchTemplate *terraformAutoscalingLaunchTemplateSpecification `json:"launch_template,omitempty" cty:"launch_template"`
// MaxSize *int64 `json:"max_size,omitempty" cty:"max_size"`
// MinSize *int64 `json:"min_size,omitempty" cty:"min_size"`
// MixedInstancesPolicy []*terraformMixedInstancesPolicy `json:"mixed_instances_policy,omitempty" cty:"mixed_instances_policy"`
// VPCZoneIdentifier []*terraform.Literal `json:"vpc_zone_identifier,omitempty" cty:"vpc_zone_identifier"`
// Tags []*terraformASGTag `json:"tag,omitempty" cty:"tag"`
// MetricsGranularity *string `json:"metrics_granularity,omitempty" cty:"metrics_granularity"`
// EnabledMetrics []*string `json:"enabled_metrics,omitempty" cty:"enabled_metrics"`
// SuspendedProcesses []*string `json:"suspended_processes,omitempty" cty:"suspended_processes"`
// InstanceProtection *bool `json:"protect_from_scale_in,omitempty" cty:"protect_from_scale_in"`
// LoadBalancers []*terraform.Literal `json:"load_balancers,omitempty" cty:"load_balancers"`
// TargetGroupARNs []*terraform.Literal `json:"target_group_arns,omitempty" cty:"target_group_arns"`
}

func (_ *Network) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Network) error {
tf := &terraformNetwork{
// ID: e.TerraformLink(),
Name: e.Name,
}

Expand Down
4 changes: 4 additions & 0 deletions upup/pkg/fi/cloudup/openstacktasks/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ resource "openstack_networking_network_v2" "test" {
terraform {
required_version = ">= 0.12.26"
required_providers {
openstack = {
"source" = "terraform-provider-openstack/openstack"
"version" = ">= 1.40.0"
}
}
}
`,
Expand Down
5 changes: 5 additions & 0 deletions upup/pkg/fi/cloudup/terraform/target_hcl2.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ func (t *TerraformTarget) finishHCL2(taskMap map[string]fi.Task) error {
"version": cty.StringVal(">= 1.33.0"),
})
}
} else if t.Cloud.ProviderID() == kops.CloudProviderOpenstack {
writeMap(requiredProvidersBody, "openstack", map[string]cty.Value{
"source": cty.StringVal("terraform-provider-openstack/openstack"),
"version": cty.StringVal(">= 1.40.0"),
})
}

bytes := hclwrite.Format(f.Bytes())
Expand Down
8 changes: 8 additions & 0 deletions upup/pkg/fi/cloudup/terraform/target_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ func (t *TerraformTarget) finishJSON(taskMap map[string]fi.Task) error {
requiredProviderAWS[k] = v
}
requiredProvidersByName["aws"] = requiredProviderAWS
} else if t.Cloud.ProviderID() == kops.CloudProviderOpenstack {
requiredProviderOpenStack := make(map[string]interface{})
requiredProviderOpenStack["source"] = "terraform-provider-openstack/openstack"
requiredProviderOpenStack["version"] = ">= 1.40.0"
for k, v := range tfGetProviderExtraConfig(t.clusterSpecTarget) {
requiredProviderOpenStack[k] = v
}
requiredProvidersByName["openstack"] = requiredProviderOpenStack
}

if len(requiredProvidersByName) != 0 {
Expand Down

0 comments on commit 1cabf53

Please sign in to comment.