Skip to content

Commit 7319f63

Browse files
authored
feat: Add support for fetching vendored chart (#83)
1 parent bca0f02 commit 7319f63

36 files changed

+276
-279
lines changed

example/cluster/byok/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ resource "plural_cluster" "byok" {
1818
kubeconfig = {
1919
# Required, can be sourced from environment variables
2020
# export PLURAL_KUBE_CONFIG_PATH to read from local file
21+
# i.e. export PLURAL_KUBE_CONFIG_PATH=$KUBECONFIG
2122
}
2223
metadata = jsonencode({
2324
test1 = "test"

internal/common/bindings.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ type Bindings struct {
1515
Write types.Set `tfsdk:"write"`
1616
}
1717

18-
func (cb *Bindings) ReadAttributes(ctx context.Context, d diag.Diagnostics) []*console.PolicyBindingAttributes {
18+
func (cb *Bindings) ReadAttributes(ctx context.Context, d *diag.Diagnostics) []*console.PolicyBindingAttributes {
1919
if cb == nil {
2020
return nil
2121
}
2222

2323
return policyBindingAttributes(cb.Read, ctx, d)
2424
}
2525

26-
func (cb *Bindings) WriteAttributes(ctx context.Context, d diag.Diagnostics) []*console.PolicyBindingAttributes {
26+
func (cb *Bindings) WriteAttributes(ctx context.Context, d *diag.Diagnostics) []*console.PolicyBindingAttributes {
2727
if cb == nil {
2828
return nil
2929
}
3030

3131
return policyBindingAttributes(cb.Write, ctx, d)
3232
}
3333

34-
func policyBindingAttributes(bindings types.Set, ctx context.Context, d diag.Diagnostics) []*console.PolicyBindingAttributes {
34+
func policyBindingAttributes(bindings types.Set, ctx context.Context, d *diag.Diagnostics) []*console.PolicyBindingAttributes {
3535
if bindings.IsNull() {
3636
return nil
3737
}
@@ -51,7 +51,7 @@ func policyBindingAttributes(bindings types.Set, ctx context.Context, d diag.Dia
5151
return result
5252
}
5353

54-
func (cb *Bindings) From(readBindings []*console.PolicyBindingFragment, writeBindings []*console.PolicyBindingFragment, ctx context.Context, d diag.Diagnostics) {
54+
func (cb *Bindings) From(readBindings []*console.PolicyBindingFragment, writeBindings []*console.PolicyBindingFragment, ctx context.Context, d *diag.Diagnostics) {
5555
if cb == nil {
5656
return
5757
}
@@ -60,7 +60,7 @@ func (cb *Bindings) From(readBindings []*console.PolicyBindingFragment, writeBin
6060
cb.Write = bindingsFrom(writeBindings, cb.Write, ctx, d)
6161
}
6262

63-
func bindingsFrom(bindings []*console.PolicyBindingFragment, config types.Set, ctx context.Context, d diag.Diagnostics) types.Set {
63+
func bindingsFrom(bindings []*console.PolicyBindingFragment, config types.Set, ctx context.Context, d *diag.Diagnostics) types.Set {
6464
if len(bindings) == 0 {
6565
// Rewriting config to state to avoid inconsistent result errors.
6666
// This could happen, for example, when sending "nil" to API and "[]" is returned as a result.
@@ -91,7 +91,7 @@ func bindingsFrom(bindings []*console.PolicyBindingFragment, config types.Set, c
9191
return setValue
9292
}
9393

94-
func SetToPolicyBindingAttributes(set types.Set, ctx context.Context, d diag.Diagnostics) []*console.PolicyBindingAttributes {
94+
func SetToPolicyBindingAttributes(set types.Set, ctx context.Context, d *diag.Diagnostics) []*console.PolicyBindingAttributes {
9595
return policyBindingAttributes(set, ctx, d)
9696
}
9797

internal/common/cluster_node_pool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var ClusterNodePoolAttrTypes = map[string]attr.Type{
3030
"cloud_settings": types.ObjectType{AttrTypes: NodePoolCloudSettingsAttrTypes},
3131
}
3232

33-
func (c *ClusterNodePool) LabelsAttribute(ctx context.Context, d diag.Diagnostics) *string {
33+
func (c *ClusterNodePool) LabelsAttribute(ctx context.Context, d *diag.Diagnostics) *string {
3434
if c.Labels.IsNull() {
3535
return nil
3636
}
@@ -40,7 +40,7 @@ func (c *ClusterNodePool) LabelsAttribute(ctx context.Context, d diag.Diagnostic
4040
return AttributesJson(elements, d)
4141
}
4242

43-
func (c *ClusterNodePool) TaintsAttribute(ctx context.Context, d diag.Diagnostics) []*console.TaintAttributes {
43+
func (c *ClusterNodePool) TaintsAttribute(ctx context.Context, d *diag.Diagnostics) []*console.TaintAttributes {
4444
if c.Taints.IsNull() {
4545
return nil
4646
}
@@ -130,7 +130,7 @@ func (c *NodePoolCloudSettingsAWS) Attributes() *console.AwsNodeCloudAttributes
130130
}
131131
}
132132

133-
func ClusterNodePoolsFrom(nodePools []*console.NodePoolFragment, configNodePools types.Map, ctx context.Context, d diag.Diagnostics) types.Map {
133+
func ClusterNodePoolsFrom(nodePools []*console.NodePoolFragment, configNodePools types.Map, ctx context.Context, d *diag.Diagnostics) types.Map {
134134
configNodePoolsElements := make(map[string]ClusterNodePool, len(configNodePools.Elements()))
135135
d.Append(configNodePools.ElementsAs(ctx, &configNodePoolsElements, false)...)
136136

@@ -154,7 +154,7 @@ func ClusterNodePoolsFrom(nodePools []*console.NodePoolFragment, configNodePools
154154
return mapValue
155155
}
156156

157-
func clusterNodePoolTaintsFrom(nodePool *console.NodePoolFragment, ctx context.Context, d diag.Diagnostics) types.Set {
157+
func clusterNodePoolTaintsFrom(nodePool *console.NodePoolFragment, ctx context.Context, d *diag.Diagnostics) types.Set {
158158
if len(nodePool.Taints) == 0 {
159159
return types.SetNull(basetypes.ObjectType{AttrTypes: NodePoolTaintAttrTypes})
160160
}

internal/common/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/hashicorp/terraform-plugin-framework/types"
1010
)
1111

12-
func AttributesJson(m map[string]types.String, d diag.Diagnostics) *string {
12+
func AttributesJson(m map[string]types.String, d *diag.Diagnostics) *string {
1313
stringMap := map[string]string{}
1414
for key, val := range m {
1515
stringMap[key] = val.ValueString()

internal/common/map.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/hashicorp/terraform-plugin-framework/types"
88
)
99

10-
func MapFrom(values map[string]any, ctx context.Context, d diag.Diagnostics) types.Map {
10+
func MapFrom(values map[string]any, ctx context.Context, d *diag.Diagnostics) types.Map {
1111
if values == nil {
1212
return types.MapNull(types.StringType)
1313
}
@@ -17,7 +17,7 @@ func MapFrom(values map[string]any, ctx context.Context, d diag.Diagnostics) typ
1717
return mapValue
1818
}
1919

20-
func MapFromWithConfig(values map[string]any, config types.Map, ctx context.Context, d diag.Diagnostics) types.Map {
20+
func MapFromWithConfig(values map[string]any, config types.Map, ctx context.Context, d *diag.Diagnostics) types.Map {
2121
if len(values) == 0 {
2222
// Rewriting config to state to avoid inconsistent result errors.
2323
// This could happen, for example, when sending "nil" to API and "{}" is returned as a result.

internal/common/set.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/hashicorp/terraform-plugin-framework/types"
88
)
99

10-
func SetFrom(values []*string, config types.Set, ctx context.Context, d diag.Diagnostics) types.Set {
10+
func SetFrom(values []*string, config types.Set, ctx context.Context, d *diag.Diagnostics) types.Set {
1111
if len(values) == 0 {
1212
// Rewriting config to state to avoid inconsistent result errors.
1313
// This could happen, for example, when sending "nil" to API and "[]" is returned as a result.

internal/common/tags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
console "github.com/pluralsh/console/go/client"
99
)
1010

11-
func TagsFrom(tags []*console.ClusterTags, config types.Map, d diag.Diagnostics) basetypes.MapValue {
11+
func TagsFrom(tags []*console.ClusterTags, config types.Map, d *diag.Diagnostics) basetypes.MapValue {
1212
if len(tags) == 0 {
1313
// Rewriting config to state to avoid inconsistent result errors.
1414
// This could happen, for example, when sending "nil" to API and "{}" is returned as a result.

internal/datasource/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,6 @@ func (d *clusterDataSource) Read(ctx context.Context, req datasource.ReadRequest
215215
return
216216
}
217217

218-
data.From(cluster, ctx, resp.Diagnostics)
218+
data.From(cluster, ctx, &resp.Diagnostics)
219219
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
220220
}

internal/datasource/cluster_model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type cluster struct {
2727
NodePools types.Map `tfsdk:"node_pools"`
2828
}
2929

30-
func (c *cluster) From(cl *console.ClusterFragment, ctx context.Context, d diag.Diagnostics) {
30+
func (c *cluster) From(cl *console.ClusterFragment, ctx context.Context, d *diag.Diagnostics) {
3131
metadata, err := json.Marshal(cl.Metadata)
3232
if err != nil {
3333
d.AddError("Provider Error", fmt.Sprintf("Cannot marshall metadata, got error: %s", err))

internal/datasource/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ func (d *configDataSource) Read(ctx context.Context, req datasource.ReadRequest,
6666
return
6767
}
6868

69-
data.From(resp.Diagnostics)
69+
data.From(&resp.Diagnostics)
7070
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
7171
}

0 commit comments

Comments
 (0)