Skip to content

Commit

Permalink
WIP: Add TF render for OpenStack network
Browse files Browse the repository at this point in the history
  • Loading branch information
ederst committed May 4, 2021
1 parent 743fd5c commit d3cf3e8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions upup/pkg/fi/cloudup/openstacktasks/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions upup/pkg/fi/cloudup/openstacktasks/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup/openstack"
"k8s.io/kops/upup/pkg/fi/cloudup/terraform"
)

// +kops:fitask
Expand Down Expand Up @@ -147,3 +148,33 @@ func (_ *Network) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes
klog.V(2).Infof("Using an existing Openstack network, id=%s", fi.StringValue(e.ID))
return nil
}

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{
Name: e.Name,
}

return t.RenderResource("openstack_networking_network_v2", *e.Name, tf)
}

// TerraformLink fills in the property
func (e *Network) TerraformLink() *terraform.Literal {
return terraform.LiteralProperty("openstack_networking_network_v2", fi.StringValue(e.Name), "id")
}

0 comments on commit d3cf3e8

Please sign in to comment.