Skip to content

Commit

Permalink
fix(deps): update module github.com/cilium/cilium to v1.17.0-pre.0.0.…
Browse files Browse the repository at this point in the history
…20240915100140-abf32d4f1f08
  • Loading branch information
littlejo committed Sep 16, 2024
1 parent af3812d commit b5c4cda
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .github/tf/clustermesh/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ resource "cilium_clustermesh" "this2" {
}

resource "cilium_clustermesh_connection" "this" {
destination_context = "kind-test2"
provider = cilium.mesh1
destination_contexts = ["kind-test2"]
provider = cilium.mesh1
depends_on = [
cilium_clustermesh.this,
cilium_clustermesh.this2,
Expand Down
30 changes: 22 additions & 8 deletions cilium/cluster_mesh_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (
"context"
"fmt"
"os"
"strings"
"time"

"github.com/cilium/cilium/cilium-cli/clustermesh"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
Expand All @@ -38,8 +40,9 @@ type CiliumClusterMeshConnectResource struct {
type CiliumClusterMeshConnectResourceModel struct {
//SourceEndpoints types.List `tfsdk:"source_endpoint"`
//DestinationEndpoints types.List `tfsdk:"destination_endpoint"`
DestinationContext types.String `tfsdk:"destination_context"`
Id types.String `tfsdk:"id"`
DestinationContexts types.List `tfsdk:"destination_contexts"`
ConnectionMode types.String `tfsdk:"connection_mode"`
Id types.String `tfsdk:"id"`
}

func (r *CiliumClusterMeshConnectResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
Expand All @@ -52,11 +55,18 @@ func (r *CiliumClusterMeshConnectResource) Schema(ctx context.Context, req resou
MarkdownDescription: "Cluster Mesh connection resource. This is equivalent to cilium cli: `cilium clustermesh connect` and `cilium clustermesh disconnect`: It manages the connections between two Kubernetes clusters.",

Attributes: map[string]schema.Attribute{
"destination_context": schema.StringAttribute{
MarkdownDescription: "Kubernetes configuration context of destination cluster",
"destination_contexts": schema.ListAttribute{
ElementType: types.StringType,
MarkdownDescription: "Kubernetes configuration contexts of destination clusters",
Optional: true,
Computed: true,
Default: stringdefault.StaticString(""),
Default: listdefault.StaticValue(types.ListNull(types.StringType)),
},
"connection_mode": schema.StringAttribute{
MarkdownDescription: ConcatDefault("Connection mode. unicast, bidirectional and mesh", "bidirectional"),
Optional: true,
Computed: true,
Default: stringdefault.StaticString("bidirectional"),
},
//"destination_endpoint": schema.ListAttribute{
// ElementType: types.StringType,
Expand Down Expand Up @@ -121,9 +131,11 @@ func (r *CiliumClusterMeshConnectResource) Create(ctx context.Context, req resou
return
}
params.Namespace = namespace
params.DestinationContext = data.DestinationContext.ValueString()
params.HelmReleaseName = helm_release

params.DestinationContext = ValueList(ctx, data.DestinationContexts)
params.ConnectionMode = data.ConnectionMode.ValueString()

cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if err := cm.ConnectWithHelm(context.Background()); err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to connect cluster: %s", err))
Expand All @@ -132,7 +144,7 @@ func (r *CiliumClusterMeshConnectResource) Create(ctx context.Context, req resou

// For the purposes of this example code, hardcoding a response value to
// save into the Terraform state.
data.Id = types.StringValue("ciliumclustermeshconnect-" + params.DestinationContext)
data.Id = types.StringValue("ciliumclustermeshconnect-" + strings.Join(params.DestinationContext, "-"))

// Write logs using the tflog package
// Documentation: https://terraform.io/plugin/log
Expand Down Expand Up @@ -195,7 +207,8 @@ func (r *CiliumClusterMeshConnectResource) Update(ctx context.Context, req resou
return
}
params.Namespace = namespace
params.DestinationContext = data.DestinationContext.ValueString()
params.DestinationContext = ValueList(ctx, data.DestinationContexts)
params.ConnectionMode = data.ConnectionMode.ValueString()
params.HelmReleaseName = helm_release

cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
Expand Down Expand Up @@ -229,6 +242,7 @@ func (r *CiliumClusterMeshConnectResource) Delete(ctx context.Context, req resou

params.Namespace = namespace
params.HelmReleaseName = helm_release
params.ConnectionMode = data.ConnectionMode.ValueString()

cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if err := cm.DisconnectWithHelm(context.Background()); err != nil {
Expand Down
19 changes: 2 additions & 17 deletions cilium/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,7 @@ func (r *CiliumDeployResource) Create(ctx context.Context, req resource.CreateRe
params.HelmReleaseName = helm_release
wait := data.Wait.ValueBool()

helmSet := make([]types.String, 0, len(data.HelmSet.Elements()))
data.HelmSet.ElementsAs(ctx, &helmSet, false)

h := []string{}
for _, e := range helmSet {
h = append(h, e.ValueString())
}

options.Values = h
options.Values = ValueList(ctx, data.HelmSet)

values := data.Values.ValueString()

Expand Down Expand Up @@ -314,15 +306,8 @@ func (r *CiliumDeployResource) Update(ctx context.Context, req resource.UpdateRe
params.HelmResetValues = data.Reset.ValueBool()
params.HelmReuseValues = data.Reuse.ValueBool()
wait := data.Wait.ValueBool()
helmSet := make([]types.String, 0, len(data.HelmSet.Elements()))
data.HelmSet.ElementsAs(ctx, &helmSet, false)

h := []string{}
for _, e := range helmSet {
h = append(h, e.ValueString())
}

options.Values = h
options.Values = ValueList(ctx, data.HelmSet)

values := data.Values.ValueString()

Expand Down
11 changes: 11 additions & 0 deletions cilium/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,14 @@ func (c *CiliumClient) CheckDaemonsetAvailability(ctx context.Context, namespace

return nil
}

func ValueList(ctx context.Context, l types.List) []string {
destinationContexts := make([]types.String, 0, len(l.Elements()))
l.ElementsAs(ctx, &destinationContexts, false)

d := []string{}
for _, e := range destinationContexts {
d = append(d, e.ValueString())
}
return d
}
19 changes: 2 additions & 17 deletions cilium/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,7 @@ func (r *CiliumInstallResource) Create(ctx context.Context, req resource.CreateR
params.HelmReleaseName = helm_release
wait := data.Wait.ValueBool()

helmSet := make([]types.String, 0, len(data.HelmSet.Elements()))
data.HelmSet.ElementsAs(ctx, &helmSet, false)

h := []string{}
for _, e := range helmSet {
h = append(h, e.ValueString())
}

options.Values = h
options.Values = ValueList(ctx, data.HelmSet)

values := data.Values.ValueString()

Expand Down Expand Up @@ -314,15 +306,8 @@ func (r *CiliumInstallResource) Update(ctx context.Context, req resource.UpdateR
params.HelmResetValues = data.Reset.ValueBool()
params.HelmReuseValues = data.Reuse.ValueBool()
wait := data.Wait.ValueBool()
helmSet := make([]types.String, 0, len(data.HelmSet.Elements()))
data.HelmSet.ElementsAs(ctx, &helmSet, false)

h := []string{}
for _, e := range helmSet {
h = append(h, e.ValueString())
}

options.Values = h
options.Values = ValueList(ctx, data.HelmSet)

values := data.Values.ValueString()

Expand Down
43 changes: 23 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
module github.com/littlejo/terraform-provider-cilium

go 1.22.2
go 1.23.0

toolchain go1.23.1

require (
github.com/cilium/cilium v1.17.0-pre.0
github.com/cilium/cilium v1.17.0-pre.0.0.20240915100140-abf32d4f1f08
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-framework v1.11.0
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.10.0
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.15.4
k8s.io/apimachinery v0.31.0
k8s.io/apimachinery v0.31.1
)

require (
Expand All @@ -36,11 +38,11 @@ require (
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cilium/charts v0.0.0-20240814125739-05190b06aeb3 // indirect
github.com/cilium/charts v0.0.0-20240821152433-5a417ba8217b // indirect
github.com/cilium/ebpf v0.16.0 // indirect
github.com/cilium/hive v0.0.0-20240816121742-535330fad6ce // indirect
github.com/cilium/proxy v0.0.0-20240723112637-48fa07fc1729 // indirect
github.com/cilium/statedb v0.2.5 // indirect
github.com/cilium/proxy v0.0.0-20240909042906-ae435a5bef38 // indirect
github.com/cilium/statedb v0.3.0 // indirect
github.com/cilium/workerpool v1.2.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/containerd v1.7.14 // indirect
Expand Down Expand Up @@ -174,7 +176,7 @@ require (
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/vishvananda/netlink v1.2.1-beta.2.0.20240524165444-4d4ba1473f21 // indirect
github.com/vishvananda/netlink v1.2.1 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
Expand All @@ -189,7 +191,7 @@ require (
github.com/zclconf/go-cty v1.15.0 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
Expand All @@ -203,32 +205,33 @@ require (
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240820151423-278611b39280 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.66.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.30.3 // indirect
k8s.io/apiextensions-apiserver v0.30.3 // indirect
k8s.io/apiserver v0.30.3 // indirect
k8s.io/cli-runtime v0.30.3 // indirect
k8s.io/client-go v0.30.3 // indirect
k8s.io/component-base v0.30.3 // indirect
k8s.io/api v0.31.1 // indirect
k8s.io/apiextensions-apiserver v0.31.1 // indirect
k8s.io/apiserver v0.31.1 // indirect
k8s.io/cli-runtime v0.31.1 // indirect
k8s.io/client-go v0.31.1 // indirect
k8s.io/component-base v0.31.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108 // indirect
k8s.io/kubectl v0.30.3 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
k8s.io/utils v0.0.0-20240821151609-f90d01438635 // indirect
oras.land/oras-go v1.2.5 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.4-0.20230814161922-911ddcda40a8 // indirect
sigs.k8s.io/kustomize/api v0.17.2 // indirect
sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit b5c4cda

Please sign in to comment.