Skip to content

Commit

Permalink
Update libraries (#35)
Browse files Browse the repository at this point in the history
* Update api-client-go to v0.5.0

* Update kubectl to v0.26.2
  • Loading branch information
nikita-akuity authored Mar 16, 2023
1 parent 1382663 commit 2d55d2e
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 138 deletions.
7 changes: 3 additions & 4 deletions akp/data_source_akp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,12 @@ func (d *AkpInstanceDataSource) Schema(ctx context.Context, req datasource.Schem
MarkdownDescription: "In case some clusters don't have network access to your private Git provider you can delegate these operations to one specific cluster.",
Computed: true,
Attributes: map[string]schema.Attribute{
"control_plane": schema.SingleNestedAttribute{
MarkdownDescription: "Redundant. Always `null`",
"control_plane": schema.BoolAttribute{
MarkdownDescription: "Use Control Plane",
Computed: true,
Attributes: map[string]schema.Attribute{},
},
"managed_cluster": schema.SingleNestedAttribute{
MarkdownDescription: "Cluster",
MarkdownDescription: "Use Managed Cluster",
Computed: true,
Attributes: map[string]schema.Attribute{
"cluster_name": schema.StringAttribute{
Expand Down
7 changes: 3 additions & 4 deletions akp/data_source_akp_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,12 @@ func (d *AkpInstancesDataSource) Schema(ctx context.Context, req datasource.Sche
MarkdownDescription: "In case some clusters don't have network access to your private Git provider you can delegate these operations to one specific cluster.",
Computed: true,
Attributes: map[string]schema.Attribute{
"control_plane": schema.SingleNestedAttribute{
MarkdownDescription: "Redundant. Always `null`",
"control_plane": schema.BoolAttribute{
MarkdownDescription: "Use Control Plane",
Computed: true,
Attributes: map[string]schema.Attribute{},
},
"managed_cluster": schema.SingleNestedAttribute{
MarkdownDescription: "Cluster",
MarkdownDescription: "Use Managed Cluster",
Computed: true,
Attributes: map[string]schema.Attribute{
"cluster_name": schema.StringAttribute{
Expand Down
12 changes: 4 additions & 8 deletions akp/resource_akp_instance_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -300,15 +299,12 @@ func (r *AkpInstanceResource) Schema(ctx context.Context, req resource.SchemaReq
MarkdownDescription: "In case some clusters don't have network access to your private Git provider you can delegate these operations to one specific cluster.",
Optional: true,
Attributes: map[string]schema.Attribute{
"control_plane": schema.SingleNestedAttribute{
MarkdownDescription: "Redundant. Always `null`",
Computed: true,
PlanModifiers: []planmodifier.Object{
objectplanmodifier.UseStateForUnknown(),
},
"control_plane": schema.BoolAttribute{
MarkdownDescription: "Use Control Plane",
Required: true,
},
"managed_cluster": schema.SingleNestedAttribute{
MarkdownDescription: "Cluster",
MarkdownDescription: "Use Managed Cluster",
Optional: true,
Attributes: map[string]schema.Attribute{
"cluster_name": schema.StringAttribute{
Expand Down
34 changes: 0 additions & 34 deletions akp/types/reposerver_controlplane.go

This file was deleted.

38 changes: 8 additions & 30 deletions akp/types/reposerver_delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import (
)

type AkpRepoServerDelegate struct {
ControlPlane types.Object `tfsdk:"control_plane"`
ControlPlane types.Bool `tfsdk:"control_plane"`
ManagedCluster types.Object `tfsdk:"managed_cluster"`
}

var (
repoServerDelegateAttrTypes = map[string]attr.Type{
"control_plane": types.ObjectType{
AttrTypes: repoServerDelegateControlPlanerAttrTypes,
},
"control_plane": types.BoolType,
"managed_cluster": types.ObjectType{
AttrTypes: repoServerDelegateManagedClusterAttrTypes,
},
Expand All @@ -33,17 +31,9 @@ func MergeRepoServerDelegate(state *AkpRepoServerDelegate, plan *AkpRepoServerDe
if plan.ControlPlane.IsUnknown() {
res.ControlPlane = state.ControlPlane
} else if plan.ControlPlane.IsNull() {
res.ControlPlane = types.ObjectNull(repoServerDelegateControlPlanerAttrTypes)
res.ControlPlane = types.BoolNull()
} else {
var stateRepoServerDelegateCP, planRepoServerDelegateCP AkpRepoServerDelegateControlPlane
diags.Append(state.ControlPlane.As(context.Background(), &stateRepoServerDelegateCP, basetypes.ObjectAsOptions{
UnhandledNullAsEmpty: true,
})...)
diags.Append(plan.ControlPlane.As(context.Background(), &planRepoServerDelegateCP, basetypes.ObjectAsOptions{})...)
resRepoServerDelegateCP, d := MergeRepoServerDelegateControlPlane(&stateRepoServerDelegateCP, &planRepoServerDelegateCP)
diags.Append(d...)
res.ControlPlane, d = types.ObjectValueFrom(context.Background(), repoServerDelegateControlPlanerAttrTypes, resRepoServerDelegateCP)
diags.Append(d...)
res.ControlPlane = plan.ControlPlane
}

if plan.ManagedCluster.IsUnknown() {
Expand Down Expand Up @@ -72,15 +62,7 @@ func (x *AkpRepoServerDelegate) UpdateObject(p *argocdv1.RepoServerDelegate) dia
diags.AddError("Conversion Error", "*argocdv1.RepoServerDelegate is <nil>")
return diags
}

if p.ControlPlane == nil || p.ControlPlane.String() == "" {
x.ControlPlane = types.ObjectNull(repoServerDelegateControlPlanerAttrTypes)
} else {
controlPlaneObject := &AkpRepoServerDelegateControlPlane{}
diags.Append(controlPlaneObject.UpdateObject(p.ControlPlane)...)
x.ControlPlane, d = types.ObjectValueFrom(context.Background(), repoServerDelegateControlPlanerAttrTypes, controlPlaneObject)
diags.Append(d...)
}
x.ControlPlane = types.BoolValue(p.ControlPlane)

if p.ManagedCluster == nil || p.ManagedCluster.String() == "" {
x.ManagedCluster = types.ObjectNull(repoServerDelegateManagedClusterAttrTypes)
Expand All @@ -98,20 +80,16 @@ func (x *AkpRepoServerDelegate) As(target *argocdv1.RepoServerDelegate) diag.Dia
diags := diag.Diagnostics{}

if x.ControlPlane.IsNull() {
target.ControlPlane = nil
target.ControlPlane = false
} else if !x.ControlPlane.IsUnknown() {
controlPlane := AkpRepoServerDelegateControlPlane{}
targetControlPlane := argocdv1.RepoServerDelegateControlPlane{}
diags.Append(x.ControlPlane.As(context.Background(), &controlPlane, basetypes.ObjectAsOptions{})...)
diags.Append(controlPlane.As(&targetControlPlane)...)
target.ControlPlane = &targetControlPlane
target.ControlPlane = x.ControlPlane.ValueBool()
}

if x.ManagedCluster.IsNull() {
target.ManagedCluster = nil
} else if !x.ManagedCluster.IsUnknown() {
managedCluster := AkpRepoServerDelegateManagedCluster{}
targetManagedCluster := argocdv1.RepoServerDelegateManagedCluster{}
targetManagedCluster := argocdv1.ManagedCluster{}
diags.Append(x.ManagedCluster.As(context.Background(), managedCluster, basetypes.ObjectAsOptions{})...)
diags.Append(managedCluster.As(&targetManagedCluster)...)
target.ManagedCluster = &targetManagedCluster
Expand Down
6 changes: 3 additions & 3 deletions akp/types/reposerver_managedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type AkpRepoServerDelegateManagedCluster struct {
ClusterName types.String `tfsdk:"cluster_name"`
ClusterName types.String `tfsdk:"cluster_name"`
}

var (
Expand All @@ -32,7 +32,7 @@ func MergeRepoServerDelegateManagedCluster(state *AkpRepoServerDelegateManagedCl
return res, diags
}

func (x *AkpRepoServerDelegateManagedCluster) UpdateObject(p *argocdv1.RepoServerDelegateManagedCluster) diag.Diagnostics {
func (x *AkpRepoServerDelegateManagedCluster) UpdateObject(p *argocdv1.ManagedCluster) diag.Diagnostics {
diags := diag.Diagnostics{}
if p == nil {
diags.AddError("Conversion Error", "*argocdv1.RepoServerDelegateManagedCluster is <nil>")
Expand All @@ -46,7 +46,7 @@ func (x *AkpRepoServerDelegateManagedCluster) UpdateObject(p *argocdv1.RepoServe
return diags
}

func (x *AkpRepoServerDelegateManagedCluster) As(target *argocdv1.RepoServerDelegateManagedCluster) diag.Diagnostics {
func (x *AkpRepoServerDelegateManagedCluster) As(target *argocdv1.ManagedCluster) diag.Diagnostics {
diags := diag.Diagnostics{}
target.ClusterName = x.ClusterName.ValueString()
return diags
Expand Down
8 changes: 2 additions & 6 deletions docs/data-sources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,8 @@ Read-Only:

Read-Only:

- `control_plane` (Attributes) Redundant. Always `null` (see [below for nested schema](#nestedatt--repo_server_delegate--control_plane))
- `managed_cluster` (Attributes) Cluster (see [below for nested schema](#nestedatt--repo_server_delegate--managed_cluster))

<a id="nestedatt--repo_server_delegate--control_plane"></a>
### Nested Schema for `repo_server_delegate.control_plane`

- `control_plane` (Boolean) Use Control Plane
- `managed_cluster` (Attributes) Use Managed Cluster (see [below for nested schema](#nestedatt--repo_server_delegate--managed_cluster))

<a id="nestedatt--repo_server_delegate--managed_cluster"></a>
### Nested Schema for `repo_server_delegate.managed_cluster`
Expand Down
8 changes: 2 additions & 6 deletions docs/data-sources/instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,8 @@ Read-Only:

Read-Only:

- `control_plane` (Attributes) Redundant. Always `null` (see [below for nested schema](#nestedatt--instances--repo_server_delegate--control_plane))
- `managed_cluster` (Attributes) Cluster (see [below for nested schema](#nestedatt--instances--repo_server_delegate--managed_cluster))

<a id="nestedatt--instances--repo_server_delegate--control_plane"></a>
### Nested Schema for `instances.repo_server_delegate.control_plane`

- `control_plane` (Boolean) Use Control Plane
- `managed_cluster` (Attributes) Use Managed Cluster (see [below for nested schema](#nestedatt--instances--repo_server_delegate--managed_cluster))

<a id="nestedatt--instances--repo_server_delegate--managed_cluster"></a>
### Nested Schema for `instances.repo_server_delegate.managed_cluster`
Expand Down
12 changes: 4 additions & 8 deletions docs/resources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ Required:
<a id="nestedatt--repo_server_delegate"></a>
### Nested Schema for `repo_server_delegate`

Optional:
Required:

- `managed_cluster` (Attributes) Cluster (see [below for nested schema](#nestedatt--repo_server_delegate--managed_cluster))
- `control_plane` (Boolean) Use Control Plane

Read-Only:
Optional:

- `control_plane` (Attributes) Redundant. Always `null` (see [below for nested schema](#nestedatt--repo_server_delegate--control_plane))
- `managed_cluster` (Attributes) Use Managed Cluster (see [below for nested schema](#nestedatt--repo_server_delegate--managed_cluster))

<a id="nestedatt--repo_server_delegate--managed_cluster"></a>
### Nested Schema for `repo_server_delegate.managed_cluster`
Expand All @@ -249,10 +249,6 @@ Required:
- `cluster_name` (String) Cluster Name


<a id="nestedatt--repo_server_delegate--control_plane"></a>
### Nested Schema for `repo_server_delegate.control_plane`



<a id="nestedatt--resource_settings"></a>
### Nested Schema for `resource_settings`
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ module github.com/akuity/terraform-provider-akp
go 1.19

require (
github.com/akuity/api-client-go v0.4.0
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/akuity/api-client-go v0.5.0
github.com/hashicorp/terraform-plugin-docs v0.14.1
github.com/hashicorp/terraform-plugin-framework v1.1.1
github.com/hashicorp/terraform-plugin-go v0.14.3
github.com/hashicorp/terraform-plugin-log v0.8.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.25.0
k8s.io/apimachinery v0.26.1
k8s.io/cli-runtime v0.26.1
k8s.io/client-go v0.26.1
k8s.io/kubectl v0.26.1
k8s.io/apimachinery v0.26.2
k8s.io/cli-runtime v0.26.2
k8s.io/client-go v0.26.2
k8s.io/kubectl v0.26.2
)

require golang.org/x/mod v0.7.0 // indirect
require golang.org/x/mod v0.9.0 // indirect

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
github.com/fatih/camelcase v1.0.0 // indirect
Expand Down Expand Up @@ -58,8 +58,8 @@ require (
golang.org/x/time v0.3.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/api v0.26.2 // indirect
k8s.io/component-base v0.26.2 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
Expand Down Expand Up @@ -104,7 +104,7 @@ require (
github.com/hashicorp/hc-install v0.5.0 // indirect
github.com/hashicorp/hcl/v2 v2.16.1 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.17.3 // indirect
github.com/hashicorp/terraform-exec v0.18.1 // indirect
github.com/hashicorp/terraform-json v0.15.0 // indirect
github.com/hashicorp/terraform-registry-address v0.1.0 // indirect
github.com/hashicorp/terraform-svchost v0.1.0 // indirect
Expand Down Expand Up @@ -134,7 +134,7 @@ require (
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
github.com/zclconf/go-cty v1.13.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb
golang.org/x/net v0.7.0 // indirect
Expand Down
Loading

0 comments on commit 2d55d2e

Please sign in to comment.