Skip to content

Commit

Permalink
Add parallel connections
Browse files Browse the repository at this point in the history
  • Loading branch information
littlejo committed Sep 28, 2024
1 parent ad17349 commit e8eee9f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 166 deletions.
9 changes: 9 additions & 0 deletions cilium/cluster_mesh_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"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/int32default"
"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"
Expand All @@ -41,6 +42,7 @@ type CiliumClusterMeshConnectResourceModel struct {
//SourceEndpoints types.List `tfsdk:"source_endpoint"`
//DestinationEndpoints types.List `tfsdk:"destination_endpoint"`
DestinationContexts types.List `tfsdk:"destination_contexts"`
Parallel types.Int32 `tfsdk:"parallel"`
ConnectionMode types.String `tfsdk:"connection_mode"`
Id types.String `tfsdk:"id"`
}
Expand Down Expand Up @@ -68,6 +70,12 @@ func (r *CiliumClusterMeshConnectResource) Schema(ctx context.Context, req resou
Computed: true,
Default: stringdefault.StaticString("bidirectional"),
},
"parallel": schema.Int32Attribute{
MarkdownDescription: ConcatDefault("Number of parallel connections of destination clusters", "1"),
Optional: true,
Computed: true,
Default: int32default.StaticInt32(1),
},
//"destination_endpoint": schema.ListAttribute{
// ElementType: types.StringType,
// MarkdownDescription: "IP of ClusterMesh service of destination cluster",
Expand Down Expand Up @@ -135,6 +143,7 @@ func (r *CiliumClusterMeshConnectResource) Create(ctx context.Context, req resou

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

cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if err := cm.ConnectWithHelm(context.Background()); err != nil {
Expand Down
1 change: 1 addition & 0 deletions docs/resources/clustermesh_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ provider "cilium" {

- `destination_contexts` (List of String) Kubernetes configuration contexts of destination clusters
- `connection_mode` (String) Connection Mode { `unicast` | `bidirectional` | `mesh` } (Default: `bidirectional`).
- `parallel` (Number) Number of parallel connections of destination clusters (Default: `1`).

### Read-Only

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ require (
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand Down Expand Up @@ -133,7 +132,6 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
Expand Down Expand Up @@ -236,3 +234,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/cilium/cilium => github.com/littlejo/cilium v0.0.0-20240925071401-dd6506321871
Loading

0 comments on commit e8eee9f

Please sign in to comment.