Skip to content

Commit

Permalink
Merge pull request #1398 from linode/dev
Browse files Browse the repository at this point in the history
Release v2.20.0
  • Loading branch information
yec-akamai authored Apr 23, 2024
2 parents 4ab3fca + 507c47a commit f09810d
Show file tree
Hide file tree
Showing 34 changed files with 993 additions and 656 deletions.
6 changes: 6 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@
- name: bug
description: issues that report a bug
color: ed8e21
- name: keep
description: prevent github from closing issue
color: 9c5186
- name: stale
description: github will close this issue soon
color: ab4f5c
8 changes: 6 additions & 2 deletions docs/data-sources/account_availabilities.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
page_title: "Linode: linode_account_availabilities"
description: |-
Provides information about services which are unavailable for the current Linode account.
Provides information about services availabilities for the current Linode account.
---

# linode\_account\_availabilities

Provides information about services which are unavailable for the current Linode account.
Provides information about services availabilities for the current Linode account.

## Example Usage

Expand Down Expand Up @@ -47,8 +47,12 @@ Each Linode account availability will be stored in the `availabilities` attribut

* `unavailable` - A set of services that are unavailable for the given region.

* `available` - A set of services which are available for the given region.

## Filterable Fields

* `region`

* `unavailable`

* `available`
8 changes: 5 additions & 3 deletions docs/data-sources/account_availability.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
page_title: "Linode: linode_account_availability"
description: |-
Provides details about resource availability in a region to an account specifically.
Provides details about service availability in a region to an account specifically.
---

# linode\_account\_availability

Provides details about resource availability in a region to an account specifically.
Provides details about service availability in a region to an account specifically.

## Example Usage

Expand All @@ -30,4 +30,6 @@ The Linode Account Availability data source exports the following attributes:

* `region` - The region ID.

* `unavailable` - A list of resources which are NOT available to the account in a region.
* `unavailable` - A set of services which are unavailable to the account in a region.

* `available` - A set of services which are available to the account in a region.
13 changes: 7 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637
github.com/hashicorp/go-hclog v1.6.2
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/terraform-plugin-framework v1.7.0
github.com/hashicorp/terraform-plugin-framework v1.8.0
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1
github.com/hashicorp/terraform-plugin-framework-timetypes v0.3.0
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-go v0.22.1
github.com/hashicorp/terraform-plugin-go v0.22.2
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.15.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-plugin-testing v1.7.0
github.com/linode/linodego v1.32.0
github.com/linode/linodego v1.33.0
github.com/linode/linodego/k8s v1.25.2
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.22.0
golang.org/x/net v0.24.0
golang.org/x/sync v0.6.0
)

require (
Expand Down Expand Up @@ -97,15 +98,15 @@ require (
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.3 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8J
github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw=
github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U=
github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk=
github.com/hashicorp/terraform-plugin-framework v1.7.0 h1:wOULbVmfONnJo9iq7/q+iBOBJul5vRovaYJIu2cY/Pw=
github.com/hashicorp/terraform-plugin-framework v1.7.0/go.mod h1:jY9Id+3KbZ17OMpulgnWLSfwxNVYSoYBQFTgsx044CI=
github.com/hashicorp/terraform-plugin-framework v1.8.0 h1:P07qy8RKLcoBkCrY2RHJer5AEvJnDuXomBgou6fD8kI=
github.com/hashicorp/terraform-plugin-framework v1.8.0/go.mod h1:/CpTukO88PcL/62noU7cuyaSJ4Rsim+A/pa+3rUVufY=
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 h1:gm5b1kHgFFhaKFhm4h2TgvMUlNzFAtUqlcOWnWPm+9E=
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1/go.mod h1:MsjL1sQ9L7wGwzJ5RjcI6FzEMdyoBnw+XK8ZnOvQOLY=
github.com/hashicorp/terraform-plugin-framework-timetypes v0.3.0 h1:egR4InfakWkgepZNUATWGwkrPhaAYOTEybPfEol+G/I=
github.com/hashicorp/terraform-plugin-framework-timetypes v0.3.0/go.mod h1:9vjvl36aY1p6KltaA5QCvGC5hdE/9t4YuhGftw6WOgE=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg=
github.com/hashicorp/terraform-plugin-go v0.22.1 h1:iTS7WHNVrn7uhe3cojtvWWn83cm2Z6ryIUDTRO0EV7w=
github.com/hashicorp/terraform-plugin-go v0.22.1/go.mod h1:qrjnqRghvQ6KnDbB12XeZ4FluclYwptntoWCr9QaXTI=
github.com/hashicorp/terraform-plugin-go v0.22.2 h1:5o8uveu6eZUf5J7xGPV0eY0TPXg3qpmwX9sce03Bxnc=
github.com/hashicorp/terraform-plugin-go v0.22.2/go.mod h1:drq8Snexp9HsbFZddvyLHN6LuWHHndSQg+gV+FPkcIM=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-mux v0.15.0 h1:+/+lDx0WUsIOpkAmdwBIoFU8UP9o2eZASoOnLsWbKME=
Expand Down Expand Up @@ -191,8 +191,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/linode/linodego v1.32.0 h1:OmZzB3iON6uu84VtLFf64uKmAQqJJarvmsVguroioPI=
github.com/linode/linodego v1.32.0/go.mod h1:y8GDP9uLVH4jTB9qyrgw79qfKdYJmNCGUOJmfuiOcmI=
github.com/linode/linodego v1.33.0 h1:cX2FYry7r6CA1ujBMsdqiM4VhvIQtnWsOuVblzfBhCw=
github.com/linode/linodego v1.33.0/go.mod h1:dSJJgIwqZCF5wnpuC6w5cyIbRtcexAm7uVvuJopGB40=
github.com/linode/linodego/k8s v1.25.2 h1:PY6S0sAD3xANVvM9WY38bz9GqMTjIbytC8IJJ9Cv23o=
github.com/linode/linodego/k8s v1.25.2/go.mod h1:DC1XCSRZRGsmaa/ggpDPSDUmOM6aK1bhSIP6+f9Cwhc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
Expand Down Expand Up @@ -291,8 +291,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI=
golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8=
golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -355,10 +355,10 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
Expand Down
47 changes: 10 additions & 37 deletions linode/account/framework_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ import (
)

func NewDataSource() datasource.DataSource {
return &DataSource{}
return &DataSource{
BaseDataSource: helper.NewBaseDataSource(
helper.BaseDataSourceConfig{
Name: "linode_account",
Schema: &frameworkDataSourceSchema,
},
),
}
}

type DataSource struct {
client *linodego.Client
helper.BaseDataSource
}

func (data *DataSourceModel) parseAccount(account *linodego.Account) {
Expand All @@ -34,24 +41,6 @@ func (data *DataSourceModel) parseAccount(account *linodego.Account) {
data.ID = types.StringValue(account.Email)
}

func (d *DataSource) Configure(
ctx context.Context,
req datasource.ConfigureRequest,
resp *datasource.ConfigureResponse,
) {
// Prevent panic if the provider has not been configured.
if req.ProviderData == nil {
return
}

meta := helper.GetDataSourceMeta(req, resp)
if resp.Diagnostics.HasError() {
return
}

d.client = meta.Client
}

type DataSourceModel struct {
Email types.String `tfsdk:"email"`
FirstName types.String `tfsdk:"first_name"`
Expand All @@ -68,29 +57,13 @@ type DataSourceModel struct {
ID types.String `tfsdk:"id"`
}

func (d *DataSource) Metadata(
ctx context.Context,
req datasource.MetadataRequest,
resp *datasource.MetadataResponse,
) {
resp.TypeName = "linode_account"
}

func (d *DataSource) Schema(
ctx context.Context,
req datasource.SchemaRequest,
resp *datasource.SchemaResponse,
) {
resp.Schema = frameworkDatasourceSchema
}

func (d *DataSource) Read(
ctx context.Context,
req datasource.ReadRequest,
resp *datasource.ReadResponse,
) {
tflog.Debug(ctx, "Read data.linode_account")
client := d.client
client := d.Meta.Client

var data DataSourceModel

Expand Down
2 changes: 1 addition & 1 deletion linode/account/framework_datasource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
)

var frameworkDatasourceSchema = schema.Schema{
var frameworkDataSourceSchema = schema.Schema{
Attributes: map[string]schema.Attribute{
"email": schema.StringAttribute{
Description: "The email address for this Account, for account management communications, " +
Expand Down
1 change: 1 addition & 0 deletions linode/accountavailabilities/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestAccDataSourceAccountAvailabilities_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(resourceName, "availabilities.0.region"),
resource.TestCheckResourceAttrSet(resourceName, "availabilities.0.unavailable.#"),
resource.TestCheckResourceAttrSet(resourceName, "availabilities.0.available.#"),
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
var filterConfig = frameworkfilter.Config{
"region": {APIFilterable: false, TypeFunc: frameworkfilter.FilterTypeString},
"unavailable": {APIFilterable: false, TypeFunc: frameworkfilter.FilterTypeString},
"available": {APIFilterable: false, TypeFunc: frameworkfilter.FilterTypeString},
}

var frameworkDataSourceSchema = schema.Schema{
Expand Down
17 changes: 17 additions & 0 deletions linode/accountavailabilities/framework_models_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ func TestParseAvailabilities(t *testing.T) {
"something",
"something else",
},
Available: []string{
"something available",
},
}

avail2 := linodego.AccountAvailability{
Region: "us-iad",
Unavailable: []string{
"another thing",
},
Available: []string{
"something else",
},
}

model.parseAvailabilities(context.Background(), []linodego.AccountAvailability{avail1, avail2})
Expand Down Expand Up @@ -54,4 +60,15 @@ func TestParseAvailabilities(t *testing.T) {
"mismatch when comparing unavailable list",
)
}

var availList []string
model.Availabilities[0].Available.ElementsAs(context.Background(), &availList, false)
if !reflect.DeepEqual(
availList,
[]string{"something available"},
) {
t.Error(
"mismatch when comparing available list",
)
}
}
1 change: 1 addition & 0 deletions linode/accountavailability/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAccDataSourceNodeBalancers_basic(t *testing.T) {

resource.TestCheckResourceAttr(resourceName, "region", region),
resource.TestCheckResourceAttrSet(resourceName, "unavailable.#"),
resource.TestCheckResourceAttrSet(resourceName, "available.#"),
),
},
},
Expand Down
5 changes: 5 additions & 0 deletions linode/accountavailability/framework_datasource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ var AccountAvailabilityAttributes = map[string]schema.Attribute{
Description: "A set of unavailable services for the current account in this region.",
Computed: true,
},
"available": schema.SetAttribute{
ElementType: types.StringType,
Description: "A set of available services for the current account in this region.",
Computed: true,
},
}
7 changes: 7 additions & 0 deletions linode/accountavailability/framework_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
type AccountAvailabilityModel struct {
Region types.String `tfsdk:"region"`
Unavailable types.Set `tfsdk:"unavailable"`
Available types.Set `tfsdk:"available"`
}

func (d *AccountAvailabilityModel) ParseAvailability(
Expand All @@ -25,5 +26,11 @@ func (d *AccountAvailabilityModel) ParseAvailability(
}
d.Unavailable = unavailable

available, diags := types.SetValueFrom(ctx, types.StringType, availability.Available)
if diags != nil {
return diags
}
d.Available = available

return nil
}
1 change: 1 addition & 0 deletions linode/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func (p *FrameworkProvider) Resources(ctx context.Context) []func() resource.Res
instancedisk.NewResource,
lkenodepool.NewResource,
image.NewResource,
nbconfig.NewResource,
}
}

Expand Down
Loading

0 comments on commit f09810d

Please sign in to comment.