Compare commits

...

3 Commits

Author SHA1 Message Date
Oscar Hermoso f88bb2b1f6 Create ssh_key resource, ssh example 2024-08-16 17:38:04 +08:00
Oscar Hermoso ec743c932a Fix indentation of provider_gen_config.yml to skip ignored attributes 2024-08-12 20:49:29 +08:00
Oscar Hermoso 375fee8674 Update README with link to provider registry 2024-08-12 18:29:42 +08:00
34 changed files with 838 additions and 21776 deletions
+6
View File
@@ -5,6 +5,7 @@
*.so
*.dylib
bin
dist
terraform-provider-binarylane
# Test binary, built with `go test -c`
@@ -25,3 +26,8 @@ go.work.sum
# Misc
tmp
# Normally, you wouldn't want to exclude lock files, but in this case, we're
# using Terraform's lock file to store the provider version, so we need to
# ignore it.
terraform.lock.hcl
+124
View File
@@ -0,0 +1,124 @@
# Contributing
## Local development
### First time setup
Based on [this example from the terraform docs](https://developer.hashicorp.com/terraform/plugin/code-generation/workflow-example),
1. `go mod tidy`
2. Run `go generate` to fetch/transform the OpenAPI spec in `internal/binarylane/openapi.json`
3. Create or modify `~/.terraformrc` in your home directory
```hcl
provider_installation {
dev_overrides {
# Example GOBIN path, will need to be replaced with your own GOBIN path. Default is $GOPATH/bin
"oscarhermoso/binarylane" = "/home/oscarhermoso/Git/terraform-provider-binarylane/bin"
}
direct {}
}
```
4. Build and test the provider
```sh
go build -o bin/terraform-provider-binarylane
go install
cd examples/basic
terraform plan
terraform apply
```
### Adding resources/data sources to the provider
1. Make any changes to `provider_gen_config.yml` (see https://developer.hashicorp.com/terraform/plugin/code-generation/openapi-generator#generator-config)
2. Update generated files
```sh
go generate
```
3. Scaffold any new resources and data sources
```sh
tfplugingen-framework scaffold resource \
--output-dir ./internal/provider \
--name REPLACE_ME
```
```sh
tfplugingen-framework scaffold data-source \
--output-dir ./internal/provider \
--name REPLACE_ME
```
4. Populate the template scaffolding:
Define the interfaces that the resource/data source should implement:
```diff
- var _ resource.Resource = (*replaceMeResource)(nil)
+ // Ensure the implementation satisfies the expected interfaces.
+ var (
+ _ resource.Resource = &replaceMeResource{}
+ _ resource.ResourceWithConfigure = &replaceMeResource{}
+ // _ resource.ResourceWithImportState = &replaceMeResource{}
+ )
```
Pass the API client to the resource:
```diff
- type replaceMeResource struct{}
+ type replaceMeResource struct {
+ bc *BinarylaneClient
+ }
```
Add a `Configure` method to the resource:
```diff
+ func (d *replaceMeResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
+ if req.ProviderData == nil {
+ return
+ }
+ bc, ok := req.ProviderData.(BinarylaneClient)
+ if !ok {
+ resp.Diagnostics.AddError(
+ "Unexpected Data Source Configure Type",
+ fmt.Sprintf("Expected *BinarylaneClient, got: %T.", req.ProviderData),
+ )
+ return
+ }
+ d.bc = &bc
+ }
```
Delete the local `*ResourceModel` struct, and import the generated `resources.*Model` instead.
```diff
- type replaceMeResourceModel struct {
- Id types.String `tfsdk:"id"`
- }
```
```diff
func (r *replaceMeResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
- var data replaceMeResourceModel
+ var data resources.ReplaceMeModel
```
Add the new data source/resource to `provider.go`:
```diff
return []func() resource.Resource{
# ...
+ NewReplaceMeResource,
}
```
+4 -49
View File
@@ -1,4 +1,4 @@
# binary-lane-terraform-provider
# terraform-provider-binarylane
See the examples in the [examples directory](./examples/basic/main.tf).
@@ -16,56 +16,11 @@ resource "binarylane_server" "example" {
If somehow you use this in production I would be pretty impressed.
- [x] Create/delete a server when runing locally
- [ ] Publish to Terraform Registry (and maybe OpenTofu?)
- [x] [Publish to Terraform Registry](https://registry.terraform.io/providers/oscarhermoso/binarylane/latest/docs/resources/server)
- [ ] (and maybe OpenTofu?)
- [ ] Deploy the rest of the owl
## Local development
Based on [this example from the terraform docs](https://developer.hashicorp.com/terraform/plugin/code-generation/workflow-example),
1. `go mod tidy`
2. Run `go generate` to fetch/transform the OpenAPI spec in `internal/binarylane/openapi.json`
3. Make any changes to `provider_gen_config.yml` (see https://developer.hashicorp.com/terraform/plugin/code-generation/openapi-generator#generator-config), and run `go generate` again
4. Scaffold any new resources and data sources
```sh
tfplugingen-framework scaffold data-source \
--name REPLACE_ME \
--output-dir ./internal/provider
```
```sh
tfplugingen-framework scaffold data-source \
--name REPLACE_ME \
--output-dir ./internal/provider
```
5. Create or modify `~/.terraformrc` in your home directory
```hcl
provider_installation {
dev_overrides {
# Example GOBIN path, will need to be replaced with your own GOBIN path. Default is $GOPATH/bin
"hashicorp.com/oscarhermoso/binarylane" = "/home/oscarhermoso/Git/terraform-provider-binarylane/bin"
}
direct {}
}
```
6. Build and test the provider
```sh
go build -o bin/terraform-provider-binarylane
go install
cd examples/resources/binarylane_image
terraform plan
terraform apply
```
## Notes
## Parameters
Images:
+20
View File
@@ -0,0 +1,20 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "binarylane_server Data Source - terraform-provider-binarylane"
subcategory: ""
description: |-
---
# binarylane_server (Data Source)
<!-- schema generated by tfplugindocs -->
## Schema
### Read-Only
- `id` (String) The ID of this resource.
+20
View File
@@ -0,0 +1,20 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "binarylane_ssh_key Data Source - terraform-provider-binarylane"
subcategory: ""
description: |-
---
# binarylane_ssh_key (Data Source)
<!-- schema generated by tfplugindocs -->
## Schema
### Read-Only
- `id` (String) The ID of this resource.
+2 -1
View File
@@ -1,8 +1,9 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "binarylane Provider"
subcategory: ""
description: |-
---
# binarylane Provider
+1 -447
View File
@@ -1,6 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "binarylane_server Resource - terraform-provider-binarylane"
subcategory: ""
description: |-
Provides a Binary Lane Server resource. This can be used to create and delete servers.
---
@@ -24,452 +25,5 @@ Provides a Binary Lane Server resource. This can be used to create and delete se
- `backups` (Boolean) If true this will enable two daily backups for the server. Options.daily_backups will override this value if provided. Setting this to false has no effect.
- `id` (Number) The ID of the server to fetch.
- `ipv6` (Boolean) If true this will enable IPv6 for this server.
- `licenses` (Attributes List) The desired set of licenses. (see [below for nested schema](#nestedatt--licenses))
- `name` (String) The hostname of your server, such as vps01.yourcompany.com. If not provided, the server will be created with a random name.
- `options1` (Attributes) This may be left null to accept all of the defaults for the selected size. (see [below for nested schema](#nestedatt--options1))
- `password` (String, Sensitive) If this is provided the specified or default remote user's account password will be set to this value. Only valid if the server supports password change actions (check server.password_change_supported via the servers endpoint). If omitted and the server supports password change actions a random password will be generated and emailed to the account email address.
- `port_blocking` (Boolean) Port blocking of outgoing connections for email, SSH and Remote Desktop (TCP ports 22, 25, and 3389) is enabled by default for all new servers. If this is false port blocking will be disabled. Disabling port blocking is only available to reviewed accounts.
- `ssh_keys` (List of String) This may be either the SSH keys Ids or fingerprints. If this is null or not provided any SSH keys that have been marked as default will be deployed (if the operating system supports SSH keys). Submit an empty array to disable deployment of default keys.
- `user_data` (String) If provided this will be used to initialise the new server. This must be left null if the Image does not support UserData, see DistributionInfo.Features for more information.
- `vpc_id` (Number) Leave null to use default (public) network for the selected region.
### Read-Only
- `links` (Attributes) (see [below for nested schema](#nestedatt--links))
- `server` (Attributes) (see [below for nested schema](#nestedatt--server))
<a id="nestedatt--licenses"></a>
### Nested Schema for `licenses`
Required:
- `count` (Number) The number of licences.
- `software_id` (Number) The ID of the software to license.
<a id="nestedatt--options1"></a>
### Nested Schema for `options1`
Optional:
- `daily_backups` (Number) Leave null to accept the default for the size if this is a new server or to keep the current value if this is a resize of an existing server.
- `disk` (Number) The total storage in GB for this server.
If specified this is the absolute value, not just the additional storage above what is included in the size.
Leave null to accept the default for the size if this is a new server or a resize to a different base size, or to keep the current value if this a resize with the same base size but different options.
Valid values for sizes that do not provide a value for options.restricted_storage_values_gb:
- must be a multiple of 5
- &gt; 60GB must be a multiple of 10
- &gt; 200GB must be a multiple of 100
- `ipv4_addresses` (Number) The total count of IPv4 addresses for this server. If specified this is the absolute value, not just the additional IPv4 addresses above what is included in the size. Leave null to accept the default for the size if this is a new server or to keep the current value if this is a resize of an existing server. Must not exceed the size.ipv4_addresses_max value.
- `memory` (Number) The total memory in MB for this server.
If specified this is the absolute value, not just the additional memory above what is included in the size.
Leave null to accept the default for the size if this is a new server or a resize to a different base size, or to keep the current value if this a resize with the same base size but different options.
Valid values:
- must be a multiple of 128
- &gt; 2048MB must be a multiple of 1024
- &gt; 16384MB must be a multiple of 2048
- &gt; 24576MB must be a multiple of 4096
- `monthly_backups` (Number) Leave null to accept the default for the size if this is a new server or to keep the current value if this is a resize of an existing server.
- `offsite_backups` (Boolean) Leave null to accept the default for the size if this is a new server or to keep the current value if this is a resize of an existing server.
- `transfer` (Number) The total transfer per month in TB for this server.
If specified this is the absolute value, not just the additional transfer above what is included in the size.
Leave null to accept the default for the size if this is a new server or a resize to a different base size, or to keep the current value if this a resize with the same base size but different options.
Valid values (when converted to GB by multiplying the value provided by 1024):
- must be a multiple of 5GB
- &gt; 30GB must be a multiple of 10
- &gt; 200GB must be a multiple of 100
- &gt; 2000GB must be a multiple of 1000
- `weekly_backups` (Number) Leave null to accept the default for the size if this is a new server or to keep the current value if this is a resize of an existing server.
<a id="nestedatt--links"></a>
### Nested Schema for `links`
Read-Only:
- `actions` (Attributes List) (see [below for nested schema](#nestedatt--links--actions))
<a id="nestedatt--links--actions"></a>
### Nested Schema for `links.actions`
Read-Only:
- `href` (String)
- `id` (Number)
- `rel` (String)
<a id="nestedatt--server"></a>
### Nested Schema for `server`
Read-Only:
- `advanced_features` (Attributes) The currently enabled advanced features, machine type and processor flags. (see [below for nested schema](#nestedatt--server--advanced_features))
- `attached_backup` (Attributes) An object that provides details of any backup image currently attached to the server.. (see [below for nested schema](#nestedatt--server--attached_backup))
- `backup_ids` (List of Number) A list of the currently existing backup image IDs for this server (if any).
- `backup_settings` (Attributes) Detailed backup settings for the server. (see [below for nested schema](#nestedatt--server--backup_settings))
- `cancelled_at` (String) If the server has been cancelled, this is the date and time in ISO8601 format of that cancellation.
- `created_at` (String) The date and time in ISO8601 format of this server's initial creation.
- `disk` (Number) The total disk in GB of this server.
- `disks` (Attributes List) A list of the disks that are currently attached to the server. (see [below for nested schema](#nestedatt--server--disks))
- `failover_ips` (List of String) A list of any assigned failover IP addresses for this server.
- `features` (List of String) A list of the currently enabled features on this server.
- `host` (Attributes) Summary information about the host of this server. (see [below for nested schema](#nestedatt--server--host))
- `id` (Number) The ID of this server.
- `image` (Attributes) The base image used to create this server. (see [below for nested schema](#nestedatt--server--image))
- `kernel` (Attributes) The currently selected kernel for the server. (see [below for nested schema](#nestedatt--server--kernel))
- `memory` (Number) The memory in MB of this server.
- `name` (String) The hostname of this server.
- `networks` (Attributes) A list of the networks of the server. (see [below for nested schema](#nestedatt--server--networks))
- `next_backup_window` (Attributes) The details of the next scheduled backup, if any. (see [below for nested schema](#nestedatt--server--next_backup_window))
- `partner_id` (Number) The server ID of the partner of this server, if one has been assigned.
- `password_change_supported` (Boolean) If this is true the password_reset server action can be called to change a user's password. If this is false the password_reset server action will merely clear the root/administrator password allowing the password to be changed via the web console.
- `permalink` (String) A randomly generated two-word identifier assigned to servers in regions that support this feature.
- `region` (Attributes) The region this server is allocated to. (see [below for nested schema](#nestedatt--server--region))
- `selected_size_options` (Attributes) An object that details the selected options for the current size. (see [below for nested schema](#nestedatt--server--selected_size_options))
- `size` (Attributes) The currently selected size for this server. (see [below for nested schema](#nestedatt--server--size))
- `size_slug` (String) The slug of the currently selected size for this server.
| - `status` (String) | Value | Description |
| ------------------- | ------------------------------------------------------------------------------------ |
| new | The server is currently in the process of building and is not yet available for use. |
| active | The server is available for use. |
| archive | The server is powered off due to cancellation or non payment. |
| off | The server has been powered off, but may be powered back on. |
- `vcpus` (Number) The number of virtual CPUs of this server.
- `vpc_id` (Number) The VPC ID that this server is allocated to. If this value is null the server is in the default (public) network for the region.
<a id="nestedatt--server--advanced_features"></a>
### Nested Schema for `server.advanced_features`
Read-Only:
- `enabled_advanced_features` (List of String) A list of the currently enabled advanced features for this server.
- `machine_type` (String) The machine_type (corresponding to a KVM version) used for this server.
A null value indicates automatic selection of the best KVM machine type supported by the host node.
- `processor_model` (Number) The ID of the processor model (and therefore CPU flags) available for this server.
A null value indicates automatic selection of the best processor model supported by the host node.
This does not change the physical CPU, only the CPU flags available to the operating system.
- `video_device` (String) Video Device
| Value | Description |
| ------------ | ------------------------------------- |
| cirrus-logic | Cirrus Logic GD5446 |
| standard | Standard VGA with VESA 2.0 extensions |
| virtio | Virtio VGA (800x600) |
| virtio-wide | Virtio VGA (1600x900) |
<a id="nestedatt--server--attached_backup"></a>
### Nested Schema for `server.attached_backup`
Read-Only:
- `attached_at` (String) The date and time in ISO8601 format when this image was attached to the server.
- `attachment_expires` (String) The date and time in ISO8601 format when the backup will be automatically detached unless it is manually detached earlier.
- `disk_identifiers` (List of String) A list of the operating specific disk identifiers for the attached backup disks.
- `id` (Number) The ID of the backup image.
<a id="nestedatt--server--backup_settings"></a>
### Nested Schema for `server.backup_settings`
Read-Only:
- `backup_day_of_month` (Number) If monthly backups are enabled the day of the month the monthly backup will occur.
- `backup_day_of_week` (Number) If weekly backups are enabled the day of the week that the weekly backup will occur. Sunday is day 0.
- `backup_hour_of_day` (Number) The hour of the day that backups will be scheduled. This is an approximate value.
- `offsite_backup_settings` (Attributes) If offsite backups are enabled this details how they are stored and managed. (see [below for nested schema](#nestedatt--server--backup_settings--offsite_backup_settings))
<a id="nestedatt--server--backup_settings--offsite_backup_settings"></a>
### Nested Schema for `server.backup_settings.offsite_backup_settings`
Read-Only:
- `manage_offsite_copies` (Boolean) This only has effect if a custom offsite location is being used: the internal offsite backup location always manages copies.
If this is true old offsite backups will be removed once the replacement upload is complete.
If this is false backups must be removed from the Amazon S3 bucket manually. Amazon will charge your S3 account at their standard rate for every backup stored.
- `offsite_backup_location` (String) If a custom backup location is used, this is the provided location.
- `use_custom_backup_location` (Boolean) If this is true a custom backup location will be used. If false our internally managed offsite backup location be used.
<a id="nestedatt--server--disks"></a>
### Nested Schema for `server.disks`
Read-Only:
- `description` (String) A description of this disk.
- `id` (Number) The ID of this disk.
- `primary` (Boolean) A primary disk is treated differently from other disks.
- `size_gigabytes` (Number) The size of the disk in GB.
<a id="nestedatt--server--host"></a>
### Nested Schema for `server.host`
Read-Only:
- `display_name` (String) The name for this host.
- `status_page` (String) This is the URL of the status page of the host. This will normally only be set if the host is under maintenance.
- `uptime_ms` (Number) The current uptime in milliseconds of this host.
<a id="nestedatt--server--image"></a>
### Nested Schema for `server.image`
Read-Only:
- `backup_info` (Attributes) If this image is a backup, this object will provide further information. (see [below for nested schema](#nestedatt--server--image--backup_info))
- `created_at` (String) If this is a backup image this is the date and time in ISO8601 format when the image was created.
- `description` (String) A description that may provide further details or warnings about the image.
- `distribution` (String) If this is an operating system image, this is the name of the distribution. If this is a backup image, this is the name of the distribution the server is using.
- `distribution_info` (Attributes) This object may provide further information about the distribution. (see [below for nested schema](#nestedatt--server--image--distribution_info))
- `distribution_surcharges` (Attributes) If this is not null the use of this image may incur surcharges above the base cost of the server. All costs are in AU$. (see [below for nested schema](#nestedatt--server--image--distribution_surcharges))
- `error_message` (String) If the image creation failed this may provide further information.
- `full_name` (String) If this is an operating system image, this is the name and version of the distribution. If this is a backup image, this is the server hostname and label of the backup if it exists, otherwise it is the server hostname and UTC timestamp of the creation of the image.
- `id` (Number) The ID of this image.
- `min_disk_size` (Number) For a distribution image this is the minimum disk size in GB required to install the operating system. For a backup image this is the minimum total disk size in GB required to restore the backup.
- `min_memory_megabytes` (Number) This is minimum memory in MB necessary to support this operating system (or the base operating system for a backup image).
- `name` (String) If this is an operating system image, this is the name of the operating system version. If this is a backup image, this is the label of the backup if it exists, otherwise it is the UTC timestamp of the creation of the image.
- `public` (Boolean) A public image is available to all users. A private image is available only to the account that created the image.
- `regions` (List of String) The slugs of the regions where the image is available for use.
- `size_gigabytes` (Number) For a distribution image this is the disk size used in GB by the operating system on initial install. For a backup image this is the size of the compressed backup image in GB.
- `slug` (String) If this is an operating system image this is a slug which may be used as an alternative to the ID as a reference.
| - `status` (String) | Value | Description |
| ------------------- | ---------------------------------------------------------------------------------------------------------- |
| NEW | The image is new. |
| available | The image is available for use. |
| pending | The image is pending and is not yet available for use. |
| deleted | The image has been deleted and is no longer available for use. |
| - `type` (String) | Value | Description |
| ----- | ----------- |
| custom | An image uploaded by a user. |
| snapshot | A snapshot. Snapshot creation is not currently supported so only distribution images will have this value. |
| backup | A backup of a server. |
<a id="nestedatt--server--image--backup_info"></a>
### Nested Schema for `server.image.backup_info`
Read-Only:
- `backup_disks` (Attributes List) A list of the individual disks that make up this backup. (see [below for nested schema](#nestedatt--server--image--backup_info--backup_disks))
- `iso` (Boolean) If this is true the backup is an ISO image and cannot be restored. ISO images may only be attached for use as a boot disk or an additional disk.
- `locked` (Boolean) If this is true the backup is locked and cannot be replaced.
- `offsite` (Boolean) If this is true, an attempt to create an offsite copy was made. This does not mean that the offsite copy attempt was successful or that the copy still exists.
- `server_id` (Number) The server ID that was used to create this backup.
| - `type` (String) | Value | Description |
| ----------------- | ---------------------------------------------------------------------------------- |
| daily | A backup which is scheduled to be taken each day. |
| weekly | A backup which is scheduled to be taken each week. |
| monthly | A backup which is scheduled to be taken each month. |
| temporary | A backup which is created on demand and only retained for a maximum of seven days. |
<a id="nestedatt--server--image--backup_info--backup_disks"></a>
### Nested Schema for `server.image.backup_info.backup_disks`
Read-Only:
- `description` (String) A description of this disk.
- `id` (Number) The ID of this backup disk.
- `min_disk_size` (Number) This is the minimum disk size in GB required to restore this disk image.
- `size_gigabytes` (Number) This is the compressed size of the disk image in GB.
<a id="nestedatt--server--image--distribution_info"></a>
### Nested Schema for `server.image.distribution_info`
Read-Only:
- `features` (List of String) Features supported by this distribution.
- `image_id` (Number) If this is a backup image, the operating system ID of the server at the time the backup was created.
- `password_recovery` (String) Supported methods of password recovery.
| Value | Description |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| manual | Password must be reset manually using the recovery console and rescue disk. |
| offline-clear | Password can be cleared for the admin/root user only. New password needs to be provided on login via the console (Requires restart). |
| offline-change | Password can be reset and new credentials sent (Requires restart). |
| online-change | Password may be reset without requiring a reboot via installed QEMU Guest Agent. |
- `remote_access_user` (String) User name to use when connecting via remote access (RDP or SSH).
<a id="nestedatt--server--image--distribution_surcharges"></a>
### Nested Schema for `server.image.distribution_surcharges`
Read-Only:
- `surcharge_base_cost` (Number) The additional cost for using this operating system as the base image for a size.
- `surcharge_min_vcpu` (Number) The minimum vcpu count for surcharge calculations.
- `surcharge_per_memory_max_megabytes` (Number) The maximum memory in MB that counts towards the surcharge_per_memory_mb. Any memory above this cap does not attract the surcharge.
- `surcharge_per_memory_megabyte` (Number) The additional cost per MB for using this operating system as the base image for a size.
- `surcharge_per_vcpu` (Number) The additional cost per vcpu for using this operating system as the base image for a size.
<a id="nestedatt--server--kernel"></a>
### Nested Schema for `server.kernel`
Read-Only:
- `id` (Number) The ID of this kernel.
- `name` (String) This name of this kernel.
- `version` (String) The version (if any) of this kernel.
<a id="nestedatt--server--networks"></a>
### Nested Schema for `server.networks`
Read-Only:
- `ipv6_reverse_nameservers` (List of String) Any configured IPv6 reverse nameservers for this server. Please see our documentation for how this interacts with IPv6 nameserver settings at the account level.
- `port_blocking` (Boolean) Whether the default port blocking is enabled for this server.
- `recent_ddos` (Boolean) If this is true this server has been the target of a recent DDOS attack. An email will have been sent to your email address when the DDOS was detected (and if it has ended, when it ended) with more details.
- `separate_private_network_interface` (Boolean) Whether a separate private network interface is provided for the server's VPC traffic.
- `source_and_destination_check` (Boolean) If enabled, this server is only able to send and receive data packets directly addressed to an IP address assigned to this server.
- `v4` (Attributes List) A list of the IPv4 networks for this server. (see [below for nested schema](#nestedatt--server--networks--v4))
- `v6` (Attributes List) A list of the IPv6 networks for this server. (see [below for nested schema](#nestedatt--server--networks--v6))
<a id="nestedatt--server--networks--v4"></a>
### Nested Schema for `server.networks.v4`
Read-Only:
- `gateway` (String) The gateway for this network.
- `ip_address` (String) The IP address for this network.
- `nat_target` (String) If this is not null this property is the private IP address which receives packets from this network.
- `netmask` (String)
- `reverse_name` (String) The reverse name (if any) for this network.
| - `type` (String) | Value | Description |
| ----------------- | -------------------------------------------- |
| private | A private (non internet accessible) network. |
| public | A public (internet accessible) network. |
<a id="nestedatt--server--networks--v6"></a>
### Nested Schema for `server.networks.v6`
Read-Only:
- `gateway` (String) The gateway for this network.
- `ip_address` (String) The IP address for this network.
- `nat_target` (String) If this is not null this property is the private IP address which receives packets from this network.
- `netmask` (String)
- `reverse_name` (String) The reverse name (if any) for this network.
| - `type` (String) | Value | Description |
| ----------------- | -------------------------------------------- |
| private | A private (non internet accessible) network. |
| public | A public (internet accessible) network. |
<a id="nestedatt--server--next_backup_window"></a>
### Nested Schema for `server.next_backup_window`
Read-Only:
- `end` (String) The expected latest date and time in ISO8601 format of the next scheduled backup.
This is not a guarantee that the backup will have started or completed by this date and time.
- `start` (String) The approximate earliest start date and time in ISO8601 format of the next scheduled backup.
<a id="nestedatt--server--region"></a>
### Nested Schema for `server.region`
Read-Only:
- `available` (Boolean) Whether this region is available for the allocation of new resources.
- `features` (List of String) A list of features available for resources in this region.
- `name` (String) The name of this region.
- `name_servers` (List of String) A list of nameservers available for resources in this region.
- `sizes` (List of String) The slugs of the sizes available in this region.
- `slug` (String) The unique slug for this region.
<a id="nestedatt--server--selected_size_options"></a>
### Nested Schema for `server.selected_size_options`
Read-Only:
- `daily_backups` (Number) The number of retained daily backups. e.g. if this is '2' we will store two daily backups, so each daily backup will be retained for two days before being overwritten.
- `disk` (Number) The total storage in GB for this server.
- `ipv4_addresses` (Number) The total count of IPv4 addresses for this server.
- `memory` (Number) The total memory in MB for this server.
- `monthly_backups` (Number) The number of retained monthly backups. e.g. if this is '3' we will store three monthly backups, so each monthly backup will be retained for three months before being overwritten.
- `offsite_backups` (Boolean) If this is true any daily, weekly or monthly backups will be duplicated to an off-site location.
- `transfer` (Number) The total transfer per month in TB for this server.
- `weekly_backups` (Number) The number of retained weekly backups. e.g. if this is '1' we will store one weekly backup, so that weekly backup will be retained for one week before being overwritten.
<a id="nestedatt--server--size"></a>
### Nested Schema for `server.size`
Read-Only:
- `available` (Boolean) If this is false the size is not available for new servers.
- `cpu_description` (String) A description of the CPU provided in this size.
- `description` (String) A description of this size.
- `disk` (Number) The included storage for this size in GB.
- `excess_transfer_cost_per_gigabyte` (Number) The excess charged for any transfer above the included data transfer in AU$ per GB.
- `memory` (Number) The included memory for this size in MB.
- `options2` (Attributes) Available add-ons (optional features not included in the base price) for the size. All costs are in AU$ per month (pro-rated). (see [below for nested schema](#nestedatt--server--size--options2))
- `price_hourly` (Number) Hourly price in AU$.
- `price_monthly` (Number) Monthly Price in AU$.
- `regions` (List of String) A list of region slugs where this size is available regardless of stock.
If this a response to a query that included a selected operating system this response will only include regions where that operating system is available on this size,
otherwise not all regions listed will support all operating systems on this size.
- `regions_out_of_stock` (List of String) A list of region slugs where the size is normally available but is currently not available due to lack of stock.
- `size_type` (Attributes) The type of this size, generally used to differentiate sizes optimized for different usages. (see [below for nested schema](#nestedatt--server--size--size_type))
- `slug` (String) The slug of this size.
- `storage_description` (String) A description of the storage provided in this size.
- `transfer` (Number) The included data transfer for this size in TB.
- `vcpu_units` (String) This is the unit that the vcpus field counts, e.g. "core" or "thread".
- `vcpus` (Number) The count of virtual CPUs for this size. See vcpu_units for a description of how each virtual CPU maps to the underlying hardware.
<a id="nestedatt--server--size--options2"></a>
### Nested Schema for `server.size.options2`
Read-Only:
- `backups_cost_per_backup_per_gigabyte` (Number) The cost per GB of storage of each selected backup. See the API support document for how to calculate the final cost of backups based on the options selected.
- `daily_backups` (Number) The number of daily backups included in the base size cost.
- `discount_for_no_public_ipv4` (Number) This is the discount (if any) that is applied if no public IPv4 addresses are selected.
- `disk_cost_per_additional_gigabyte` (Number) The additional cost per GB per month for additional storage space.
- `disk_max` (Number) The maximum storage in GB permitted on this size.
- `disk_min` (Number) The minimum storage in GB permitted on this size.
- `ipv4_addresses_cost_per_address` (Number) The additional cost per public IPv4 address per month for additional IPv4 addresses.
- `ipv4_addresses_max` (Number) The maximum number of IPv4 addresses permitted on this size.
- `memory_cost_per_additional_megabyte` (Number) The additional cost per MB per month for additional memory.
- `memory_max` (Number) The maximum memory in MB permitted on this size.
- `monthly_backups` (Number) The number of monthly backups included in the base size cost.
- `offsite_backup_frequency_cost` (Attributes) The additional cost per GB of storage for enabling offsite backups based on highest frequency of backups currently enabled. All costs are in AU$. (see [below for nested schema](#nestedatt--server--size--options2--offsite_backup_frequency_cost))
- `offsite_backups_cost_per_gigabyte` (Number) The additional cost per GB of storage for enabling offsite backups. See the API support document for how to calculate the final cost of backups based on the options selected.
- `restricted_disk_values` (List of Number) If this is null the normal valid values in the documentation for SizeOptionsRequest are used, otherwise only these values (in GB) are permitted.
- `transfer_cost_per_additional_gigabyte` (Number) The additional cost per GB per month for additional included transfer.
- `transfer_max` (Number) The maximum transfer in TB permitted for this size.
- `weekly_backups` (Number) The number of weekly backups included in the base size cost.
<a id="nestedatt--server--size--options2--offsite_backup_frequency_cost"></a>
### Nested Schema for `server.size.options2.offsite_backup_frequency_cost`
Read-Only:
- `daily_per_gigabyte` (Number) The additional cost per GB per month for enabling daily offsite backups. Only the highest value of the daily, weekly and monthly is applied. See the API support document for how to calculate the final cost of backups based on the options selected.
- `monthly_per_gigabyte` (Number) The additional cost per GB per month for enabling monthly offsite backups. Only the highest value of the daily, weekly and monthly is applied. See the API support document for how to calculate the final cost of backups based on the options selected.
- `weekly_per_gigabyte` (Number) The additional cost per GB per month for enabling weekly offsite backups. Only the highest value of the daily, weekly and monthly is applied. See the API support document for how to calculate the final cost of backups based on the options selected.
<a id="nestedatt--server--size--size_type"></a>
### Nested Schema for `server.size.size_type`
Read-Only:
- `description` (String) The description of this size type, generally used to indicate the intended use case for sizes of this type.
- `name` (String) The name of this size type.
- `slug` (String) The slug of this size type.
+26
View File
@@ -0,0 +1,26 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "binarylane_ssh_key Resource - terraform-provider-binarylane"
subcategory: ""
description: |-
TODO
---
# binarylane_ssh_key (Resource)
TODO
<!-- schema generated by tfplugindocs -->
## Schema
### Required
- `name` (String) A name to help you identify the key.
- `public_key` (String) The public key in OpenSSH "authorized_keys" format.
### Optional
- `default` (Boolean) Optional: If true this will be added to all new server installations (if we support SSH Key injection for the server's operating system).
- `id` (Number) The ID or fingerprint of the SSH Key to fetch.
+24
View File
@@ -0,0 +1,24 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/oscarhermoso/binarylane" {
version = "0.1.0"
hashes = [
"h1:M/GVWGdH+W26pw8o6O2zvzorVZvi0hZbaKCT8scoqT8=",
"zh:07c855b20ad789e78602918ce1565b5e1ac411df92b1f9f4a654ef3da77bcd1e",
"zh:09530d6532dcff2ccdf48de853d7144f0c66d7be203883461b256f52e719c06d",
"zh:2c118c8c7572f60739b4f0ac5cecbadd56636fa63f7f4e7f0c6cdec427fbd609",
"zh:3a51045b18ec6f7bd0ff642370f45b7ba936afa9d0e79ff52481a447adb99b66",
"zh:64608398b9da27f5b1efa2d164fc20e4cb924ebef6cdf80da7b4329f344dbf13",
"zh:a9808dacc075dd53774fe559862f22b9ab02a22b789dde59cff0ea3b42f37c73",
"zh:b22dc91a867a470da75f8887f432938cf5db314943c1f90203eff39ce8e24e85",
"zh:c110e831eafd8a138f9af9efc1730b8c3295cec54561918676744b0f6968498c",
"zh:cd4a98509c740beff50979c1e50c00e5b3915bf35185c89b9f306a2432b54a2c",
"zh:cf3b046ec96b5140fb6dacceead8d9ed723debcf580462ab93a5ed1578eaeab8",
"zh:d395d9a1d681980f0068e2146a4961e0a39c572ffdf131d5d5c1f3a91296a5e8",
"zh:eaf6c069dc35c9a6c97502b1b283d4a815730f70b0cfb637d26e29f2a70c2a51",
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
"zh:f31a253fc4c7f0d37ec2bfe2ca2e40c7c51a0db355039d56123160c97bdf7c90",
"zh:fdbadc51fc6c9ac6f2a68d5846fdb743be7b0344307c9dbf6d90252753894633",
]
}
+5 -3
View File
@@ -1,7 +1,7 @@
terraform {
required_providers {
binarylane = {
source = "hashicorp.com/oscarhermoso/binarylane"
source = "oscarhermoso/binarylane"
}
}
}
@@ -12,8 +12,10 @@ provider "binarylane" {
}
resource "binarylane_server" "example" {
name = "example"
name = "tf-example"
region = "per" # or "syd", "mel", "bne", "sin"
image = "ubuntu-24.04"
size = "std-min"
size = "std-min" # 1 VPCU, 1 GB Memory, 20 GB NVME Storage, 1000 GB Data Transfer
# password will be generated automatically and mailed to the account holder
}
+42
View File
@@ -0,0 +1,42 @@
# Local .terraform directories
**/.terraform/*
# .tfstate files
*.tfstate
*.tfstate.*
# Crash log files
crash.log
crash.*.log
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json
# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json
# Ignore transient lock info files created by terraform apply
.terraform.tfstate.lock.info
# Include override files you do wish to add to version control using negated pattern
# !example_override.tf
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
# Ignore CLI configuration files
.terraformrc
terraform.rc
# Misc
# Don't commit private keys
id_ed25519
+24
View File
@@ -0,0 +1,24 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/oscarhermoso/binarylane" {
version = "0.1.1"
hashes = [
"h1:GvTza7TvwgMCegUJ/q+kmteckZ8Sc/lqsIUK2UCxxAU=",
"zh:025de19988848b2e6b8dacd61b7e99274641f32ea9a9e1a67f7dad006630916f",
"zh:0b5ce83392db3e7693a8c9a71b9c1eb60983c43f758f8a2623a6b64778e683b9",
"zh:0bf621429caa7c4468e2996f6c517178761b0492f8611603efd912797ef4da7c",
"zh:1c4db19c124efecde6910a7e9ecbdb5f3f9042685457a3828ca0c5a43da9f43d",
"zh:30fe222bc7cdfadfe3872d443a8f6db957711fa3961f62601a9b974bda995637",
"zh:3b21a79e2d69d76364a043319bd54c86080eee3016f11b73f821f22629e8b0ef",
"zh:3bbc5ea741c85267ff25bd6db1c0863548f2da2c2277bfbf30955080282fa4f0",
"zh:414887df5094afe07ce13d521c57e161301437f8891876d9d480409ffc51e5e2",
"zh:594827a9be3de7ab4fe634be3d933c5c5a0de665293feab34037da6af5355bf6",
"zh:7d73d2ca49b8a6d6f8fe23cf0adfc1fae17fcbb2b1f0a6fb7eef0b3cca5995e1",
"zh:ad0b99751f3ee17630edeed6bec065defcbb08abd377b09169a7826d0f5896ef",
"zh:c4c1ed1f41a238b50a802efc2e8fd025d5e3a1ebd0a6a0b3d84cde1b0a7eda4a",
"zh:cfb3b91d255258583d41382f3adea82af76afff7ba607daff739b951a4a27012",
"zh:d865a4a7886c8354c0636d005904ef090dfad2ea2f5ef27b1ecad2e2dcd9964b",
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
]
}
+12
View File
@@ -0,0 +1,12 @@
# examples/ssh
## Generate SSH key pair
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
## Testing
```sh
ssh-keygen -t ed25519 -C "test@company.internal" \
-f ./id_ed25519 -N ""
```
+1
View File
@@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJCsuosklP0T4fJcQDgkeVh7dQu+eV+vev1CfwdUkj7h test@company.internal
+30
View File
@@ -0,0 +1,30 @@
terraform {
required_providers {
binarylane = {
source = "oscarhermoso/binarylane"
}
}
}
provider "binarylane" {
# api_url = "" # Defaults to "https://api.binarylane.com"
# api_token = "" # Recommend setting with environment variable BINARYLANE_API_TOKEN
}
resource "binarylane_ssh_key" "example" {
name = "test-user"
public_key = file("./id_ed25519.pub") # Likely "~/.ssh/id_ed25519.pub"
default = true # Currently, the server will only register SSH keys that are added as global defaults
}
resource "binarylane_server" "example" {
name = "tf-example"
region = "per"
image = "ubuntu-24.04"
size = "std-min"
depends_on = [binarylane_ssh_key.example] # Wait for SSH key to be created as a global default
# TODO: Extend provider with "ssh_key_id" option for explicit registraton of keys
}
+1
View File
@@ -8,3 +8,4 @@ package main
//go:generate mkdir -p internal/resources internal/data_sources
//go:generate go run github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework generate resources --input=./provider_code_spec.json --output=./internal/resources --package=resources
//go:generate go run github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework generate data-sources --input=./provider_code_spec.json --output=./internal/data_sources --package=data_sources
//go:generate tfplugindocs generate
+1 -12
View File
@@ -9,9 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-framework v1.11.0
github.com/hashicorp/terraform-plugin-framework-validators v0.13.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
github.com/oapi-codegen/oapi-codegen/v2 v2.3.0
github.com/oapi-codegen/runtime v1.1.1
)
@@ -23,7 +21,6 @@ require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
@@ -40,13 +37,11 @@ require (
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/swag v0.22.8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/cli v1.1.6 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
@@ -54,12 +49,10 @@ require (
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hc-install v0.8.0 // indirect
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.22.1 // indirect
github.com/hashicorp/terraform-plugin-codegen-spec v0.1.1 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.23.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
@@ -73,8 +66,6 @@ require (
github.com/mattn/go-runewidth v0.0.15 // 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.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oklog/run v1.0.0 // indirect
@@ -85,7 +76,6 @@ require (
github.com/rivo/uniseg v0.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
@@ -105,7 +95,6 @@ require (
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/appengine v1.6.8 // 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.34.0 // indirect
-29
View File
@@ -16,11 +16,8 @@ github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
@@ -80,7 +77,6 @@ github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
@@ -113,8 +109,6 @@ github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuD
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
@@ -131,10 +125,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hc-install v0.8.0 h1:LdpZeXkZYMQhoKPCecJHlKvUkQFixN/nvyR1CdfOLjI=
github.com/hashicorp/hc-install v0.8.0/go.mod h1:+MwJYjDfCruSD/udvBmRB22Nlkwwkwf5sAB6uTIhSaU=
github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14=
github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ=
github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg=
github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec=
@@ -155,10 +145,6 @@ github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/12
github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ=
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-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0/go.mod h1:sl/UoabMc37HA6ICVMmGO+/0wofkVIRxf+BMb/dnoIg=
github.com/hashicorp/terraform-plugin-testing v1.10.0 h1:2+tmRNhvnfE4Bs8rB6v58S/VpqzGC6RCh9Y8ujdn+aw=
github.com/hashicorp/terraform-plugin-testing v1.10.0/go.mod h1:iWRW3+loP33WMch2P/TEyCxxct/ZEcCGMquSLSCVsrc=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
@@ -209,10 +195,6 @@ github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa1
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
@@ -278,9 +260,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
@@ -306,8 +285,6 @@ github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUei
github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0=
github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw=
go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -372,11 +349,9 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
@@ -390,9 +365,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
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-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=
@@ -408,7 +380,6 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4=
google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+20 -60
View File
@@ -101,23 +101,15 @@ type ClientInterface interface {
PostAccountKeys(ctx context.Context, body PostAccountKeysJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// DeleteAccountKeysKeyId request
DeleteAccountKeysKeyId(ctx context.Context, keyId struct {
union json.RawMessage
}, reqEditors ...RequestEditorFn) (*http.Response, error)
DeleteAccountKeysKeyId(ctx context.Context, keyId int, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetAccountKeysKeyId request
GetAccountKeysKeyId(ctx context.Context, keyId struct {
union json.RawMessage
}, reqEditors ...RequestEditorFn) (*http.Response, error)
GetAccountKeysKeyId(ctx context.Context, keyId int, reqEditors ...RequestEditorFn) (*http.Response, error)
// PutAccountKeysKeyIdWithBody request with any body
PutAccountKeysKeyIdWithBody(ctx context.Context, keyId struct {
union json.RawMessage
}, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
PutAccountKeysKeyIdWithBody(ctx context.Context, keyId int, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
PutAccountKeysKeyId(ctx context.Context, keyId struct {
union json.RawMessage
}, body PutAccountKeysKeyIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
PutAccountKeysKeyId(ctx context.Context, keyId int, body PutAccountKeysKeyIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetActions request
GetActions(ctx context.Context, params *GetActionsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
@@ -623,9 +615,7 @@ func (c *Client) PostAccountKeys(ctx context.Context, body PostAccountKeysJSONRe
return c.Client.Do(req)
}
func (c *Client) DeleteAccountKeysKeyId(ctx context.Context, keyId struct {
union json.RawMessage
}, reqEditors ...RequestEditorFn) (*http.Response, error) {
func (c *Client) DeleteAccountKeysKeyId(ctx context.Context, keyId int, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewDeleteAccountKeysKeyIdRequest(c.Server, keyId)
if err != nil {
return nil, err
@@ -637,9 +627,7 @@ func (c *Client) DeleteAccountKeysKeyId(ctx context.Context, keyId struct {
return c.Client.Do(req)
}
func (c *Client) GetAccountKeysKeyId(ctx context.Context, keyId struct {
union json.RawMessage
}, reqEditors ...RequestEditorFn) (*http.Response, error) {
func (c *Client) GetAccountKeysKeyId(ctx context.Context, keyId int, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewGetAccountKeysKeyIdRequest(c.Server, keyId)
if err != nil {
return nil, err
@@ -651,9 +639,7 @@ func (c *Client) GetAccountKeysKeyId(ctx context.Context, keyId struct {
return c.Client.Do(req)
}
func (c *Client) PutAccountKeysKeyIdWithBody(ctx context.Context, keyId struct {
union json.RawMessage
}, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
func (c *Client) PutAccountKeysKeyIdWithBody(ctx context.Context, keyId int, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewPutAccountKeysKeyIdRequestWithBody(c.Server, keyId, contentType, body)
if err != nil {
return nil, err
@@ -665,9 +651,7 @@ func (c *Client) PutAccountKeysKeyIdWithBody(ctx context.Context, keyId struct {
return c.Client.Do(req)
}
func (c *Client) PutAccountKeysKeyId(ctx context.Context, keyId struct {
union json.RawMessage
}, body PutAccountKeysKeyIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
func (c *Client) PutAccountKeysKeyId(ctx context.Context, keyId int, body PutAccountKeysKeyIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewPutAccountKeysKeyIdRequest(c.Server, keyId, body)
if err != nil {
return nil, err
@@ -2856,9 +2840,7 @@ func NewPostAccountKeysRequestWithBody(server string, contentType string, body i
}
// NewDeleteAccountKeysKeyIdRequest generates requests for DeleteAccountKeysKeyId
func NewDeleteAccountKeysKeyIdRequest(server string, keyId struct {
union json.RawMessage
}) (*http.Request, error) {
func NewDeleteAccountKeysKeyIdRequest(server string, keyId int) (*http.Request, error) {
var err error
var pathParam0 string
@@ -2892,9 +2874,7 @@ func NewDeleteAccountKeysKeyIdRequest(server string, keyId struct {
}
// NewGetAccountKeysKeyIdRequest generates requests for GetAccountKeysKeyId
func NewGetAccountKeysKeyIdRequest(server string, keyId struct {
union json.RawMessage
}) (*http.Request, error) {
func NewGetAccountKeysKeyIdRequest(server string, keyId int) (*http.Request, error) {
var err error
var pathParam0 string
@@ -2928,9 +2908,7 @@ func NewGetAccountKeysKeyIdRequest(server string, keyId struct {
}
// NewPutAccountKeysKeyIdRequest calls the generic PutAccountKeysKeyId builder with application/json body
func NewPutAccountKeysKeyIdRequest(server string, keyId struct {
union json.RawMessage
}, body PutAccountKeysKeyIdJSONRequestBody) (*http.Request, error) {
func NewPutAccountKeysKeyIdRequest(server string, keyId int, body PutAccountKeysKeyIdJSONRequestBody) (*http.Request, error) {
var bodyReader io.Reader
buf, err := json.Marshal(body)
if err != nil {
@@ -2941,9 +2919,7 @@ func NewPutAccountKeysKeyIdRequest(server string, keyId struct {
}
// NewPutAccountKeysKeyIdRequestWithBody generates requests for PutAccountKeysKeyId with any type of body
func NewPutAccountKeysKeyIdRequestWithBody(server string, keyId struct {
union json.RawMessage
}, contentType string, body io.Reader) (*http.Request, error) {
func NewPutAccountKeysKeyIdRequestWithBody(server string, keyId int, contentType string, body io.Reader) (*http.Request, error) {
var err error
var pathParam0 string
@@ -8539,23 +8515,15 @@ type ClientWithResponsesInterface interface {
PostAccountKeysWithResponse(ctx context.Context, body PostAccountKeysJSONRequestBody, reqEditors ...RequestEditorFn) (*PostAccountKeysResponse, error)
// DeleteAccountKeysKeyIdWithResponse request
DeleteAccountKeysKeyIdWithResponse(ctx context.Context, keyId struct {
union json.RawMessage
}, reqEditors ...RequestEditorFn) (*DeleteAccountKeysKeyIdResponse, error)
DeleteAccountKeysKeyIdWithResponse(ctx context.Context, keyId int, reqEditors ...RequestEditorFn) (*DeleteAccountKeysKeyIdResponse, error)
// GetAccountKeysKeyIdWithResponse request
GetAccountKeysKeyIdWithResponse(ctx context.Context, keyId struct {
union json.RawMessage
}, reqEditors ...RequestEditorFn) (*GetAccountKeysKeyIdResponse, error)
GetAccountKeysKeyIdWithResponse(ctx context.Context, keyId int, reqEditors ...RequestEditorFn) (*GetAccountKeysKeyIdResponse, error)
// PutAccountKeysKeyIdWithBodyWithResponse request with any body
PutAccountKeysKeyIdWithBodyWithResponse(ctx context.Context, keyId struct {
union json.RawMessage
}, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutAccountKeysKeyIdResponse, error)
PutAccountKeysKeyIdWithBodyWithResponse(ctx context.Context, keyId int, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutAccountKeysKeyIdResponse, error)
PutAccountKeysKeyIdWithResponse(ctx context.Context, keyId struct {
union json.RawMessage
}, body PutAccountKeysKeyIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutAccountKeysKeyIdResponse, error)
PutAccountKeysKeyIdWithResponse(ctx context.Context, keyId int, body PutAccountKeysKeyIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutAccountKeysKeyIdResponse, error)
// GetActionsWithResponse request
GetActionsWithResponse(ctx context.Context, params *GetActionsParams, reqEditors ...RequestEditorFn) (*GetActionsResponse, error)
@@ -11819,9 +11787,7 @@ func (c *ClientWithResponses) PostAccountKeysWithResponse(ctx context.Context, b
}
// DeleteAccountKeysKeyIdWithResponse request returning *DeleteAccountKeysKeyIdResponse
func (c *ClientWithResponses) DeleteAccountKeysKeyIdWithResponse(ctx context.Context, keyId struct {
union json.RawMessage
}, reqEditors ...RequestEditorFn) (*DeleteAccountKeysKeyIdResponse, error) {
func (c *ClientWithResponses) DeleteAccountKeysKeyIdWithResponse(ctx context.Context, keyId int, reqEditors ...RequestEditorFn) (*DeleteAccountKeysKeyIdResponse, error) {
rsp, err := c.DeleteAccountKeysKeyId(ctx, keyId, reqEditors...)
if err != nil {
return nil, err
@@ -11830,9 +11796,7 @@ func (c *ClientWithResponses) DeleteAccountKeysKeyIdWithResponse(ctx context.Con
}
// GetAccountKeysKeyIdWithResponse request returning *GetAccountKeysKeyIdResponse
func (c *ClientWithResponses) GetAccountKeysKeyIdWithResponse(ctx context.Context, keyId struct {
union json.RawMessage
}, reqEditors ...RequestEditorFn) (*GetAccountKeysKeyIdResponse, error) {
func (c *ClientWithResponses) GetAccountKeysKeyIdWithResponse(ctx context.Context, keyId int, reqEditors ...RequestEditorFn) (*GetAccountKeysKeyIdResponse, error) {
rsp, err := c.GetAccountKeysKeyId(ctx, keyId, reqEditors...)
if err != nil {
return nil, err
@@ -11841,9 +11805,7 @@ func (c *ClientWithResponses) GetAccountKeysKeyIdWithResponse(ctx context.Contex
}
// PutAccountKeysKeyIdWithBodyWithResponse request with arbitrary body returning *PutAccountKeysKeyIdResponse
func (c *ClientWithResponses) PutAccountKeysKeyIdWithBodyWithResponse(ctx context.Context, keyId struct {
union json.RawMessage
}, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutAccountKeysKeyIdResponse, error) {
func (c *ClientWithResponses) PutAccountKeysKeyIdWithBodyWithResponse(ctx context.Context, keyId int, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutAccountKeysKeyIdResponse, error) {
rsp, err := c.PutAccountKeysKeyIdWithBody(ctx, keyId, contentType, body, reqEditors...)
if err != nil {
return nil, err
@@ -11851,9 +11813,7 @@ func (c *ClientWithResponses) PutAccountKeysKeyIdWithBodyWithResponse(ctx contex
return ParsePutAccountKeysKeyIdResponse(rsp)
}
func (c *ClientWithResponses) PutAccountKeysKeyIdWithResponse(ctx context.Context, keyId struct {
union json.RawMessage
}, body PutAccountKeysKeyIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutAccountKeysKeyIdResponse, error) {
func (c *ClientWithResponses) PutAccountKeysKeyIdWithResponse(ctx context.Context, keyId int, body PutAccountKeysKeyIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutAccountKeysKeyIdResponse, error) {
rsp, err := c.PutAccountKeysKeyId(ctx, keyId, body, reqEditors...)
if err != nil {
return nil, err
+6 -1
View File
@@ -8,7 +8,12 @@ curl https://api.binarylane.com.au/reference/openapi.json --output $OPENAPI_FILE
cat <<<$(jq '.paths |= with_entries(.key |= sub("/v2/"; "/"))' $OPENAPI_FILE) >$OPENAPI_FILE
# Set the base URL with a /v2 suffix
cat <<<$(jq '.servers[0].url = "https://api.binarylane.com.au/v2"' $OPENAPI_FILE) >$OPENAPI_FILE
# Terraform can't hanlde oneOf types, so we need to remove them and add a type: "string"
# Terraform can't handle oneOf types, so we need to replace them with basic types
cat <<<$(jq '.components.schemas.CreateServerRequest.properties.image |= del(.oneOf) + {type:"string"}' $OPENAPI_FILE) >$OPENAPI_FILE
cat <<<$(jq '.paths["/account/keys/{key_id}"].delete.parameters[0].schema |= del(.oneOf) + {type:"integer"}' $OPENAPI_FILE) >$OPENAPI_FILE
cat <<<$(jq '.paths["/account/keys/{key_id}"].put.parameters[0].schema |= del(.oneOf) + {type:"integer"}' $OPENAPI_FILE) >$OPENAPI_FILE
cat <<<$(jq '.paths["/account/keys/{key_id}"].get.parameters[0].schema |= del(.oneOf) + {type:"integer"}' $OPENAPI_FILE) >$OPENAPI_FILE
cat <<<$(jq '.paths["/account/keys/{key_id}"].delete.parameters[0].schema |= del(.oneOf) + {type:"integer"}' $OPENAPI_FILE) >$OPENAPI_FILE
cat <<<$(jq '.paths["/account/keys/{key_id}"].delete.parameters[0].schema |= del(.oneOf) + {type:"integer"}' $OPENAPI_FILE) >$OPENAPI_FILE
# Remove the "/paths/{image_id}" path because its duplicated by "/images/{image_id_or_slug}"
cat <<<$(jq 'del(.paths."/images/{image_id}")' $OPENAPI_FILE) >$OPENAPI_FILE
+6 -27
View File
@@ -1594,15 +1594,8 @@
"description": "The ID or fingerprint of the SSH Key to fetch.",
"required": true,
"schema": {
"oneOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"example": 5
"example": 5,
"type": "integer"
}
}
],
@@ -1652,15 +1645,8 @@
"description": "The ID or fingerprint of the SSH Key to update.",
"required": true,
"schema": {
"oneOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"example": 5
"example": 5,
"type": "integer"
}
}
],
@@ -1733,15 +1719,8 @@
"description": "The ID or fingerprint of the SSH Key to delete.",
"required": true,
"schema": {
"oneOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"example": 5
"example": 5,
"type": "integer"
}
}
],
-18
View File
@@ -3142,27 +3142,9 @@ type GetAccountKeysParams struct {
// PostAccountKeysJSONBody defines parameters for PostAccountKeys.
type PostAccountKeysJSONBody = SshKeyRequest
// DeleteAccountKeysKeyIdParamsKeyId0 defines parameters for DeleteAccountKeysKeyId.
type DeleteAccountKeysKeyIdParamsKeyId0 = int
// DeleteAccountKeysKeyIdParamsKeyId1 defines parameters for DeleteAccountKeysKeyId.
type DeleteAccountKeysKeyIdParamsKeyId1 = string
// GetAccountKeysKeyIdParamsKeyId0 defines parameters for GetAccountKeysKeyId.
type GetAccountKeysKeyIdParamsKeyId0 = int
// GetAccountKeysKeyIdParamsKeyId1 defines parameters for GetAccountKeysKeyId.
type GetAccountKeysKeyIdParamsKeyId1 = string
// PutAccountKeysKeyIdJSONBody defines parameters for PutAccountKeysKeyId.
type PutAccountKeysKeyIdJSONBody = UpdateSshKeyRequest
// PutAccountKeysKeyIdParamsKeyId0 defines parameters for PutAccountKeysKeyId.
type PutAccountKeysKeyIdParamsKeyId0 = int
// PutAccountKeysKeyIdParamsKeyId1 defines parameters for PutAccountKeysKeyId.
type PutAccountKeysKeyIdParamsKeyId1 = string
// GetActionsParams defines parameters for GetActions.
type GetActionsParams struct {
// Page The selected page. Page numbering starts at 1
@@ -0,0 +1,26 @@
// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
package data_sources
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
)
func SshKeyDataSourceSchema(ctx context.Context) schema.Schema {
return schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Required: true,
Description: "The ID or fingerprint of the SSH Key to fetch.",
MarkdownDescription: "The ID or fingerprint of the SSH Key to fetch.",
},
},
}
}
type SshKeyModel struct {
Id types.Int64 `tfsdk:"id"`
}
+5 -1
View File
@@ -141,11 +141,15 @@ func (p *binarylaneProvider) Metadata(_ context.Context, _ provider.MetadataRequ
}
func (p *binarylaneProvider) DataSources(_ context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{}
return []func() datasource.DataSource{
NewServerDataSource,
NewSshKeyDataSource,
}
}
func (p *binarylaneProvider) Resources(_ context.Context) []func() resource.Resource {
return []func() resource.Resource{
NewServerResource,
NewSshKeyResource,
}
}
-49
View File
@@ -1,49 +0,0 @@
package provider
import (
"fmt"
"math/rand"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
)
const (
providerConfig = `
provider "binarylane" {
}
`
)
var (
testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
"binarylane": providerserver.NewProtocol6WithError(New("test")()),
}
)
const TestAccNamePrefix = "tf-acc"
func TestAccPreCheck(t *testing.T) {
if v := os.Getenv("BINARYLANE_API_TOKEN"); v == "" {
t.Fatal("BINARYLANE_API_TOKEN must be set for acceptance tests")
}
if v := os.Getenv("BINARYLANE_ACC_TEST_PROJECT"); v == "" {
t.Fatal("BINARYLANE_ACC_TEST_PROJECT must be set for acceptance tests")
}
if v := os.Getenv("BINARYLANE_ACC_TEST_LOCATION"); v == "" {
t.Fatal("BINARYLANE_ACC_TEST_LOCATION must be set for acceptance tests")
}
}
func GetRandomResourceName(resType string) string {
var letters = []rune("abcdefghijklmnopqrstuvwxyz")
b := make([]rune, 8)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return fmt.Sprintf("%s-%s-%s", TestAccNamePrefix, resType, string(b))
}
+3 -7
View File
@@ -2,10 +2,10 @@ package provider
import (
"context"
"terraform-provider-binarylane/internal/data_sources"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
)
var _ datasource.DataSource = (*serverDataSource)(nil)
@@ -16,10 +16,6 @@ func NewServerDataSource() datasource.DataSource {
type serverDataSource struct{}
type serverDataSourceModel struct {
Id types.String `tfsdk:"id"`
}
func (d *serverDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_server"
}
@@ -35,7 +31,7 @@ func (d *serverDataSource) Schema(ctx context.Context, req datasource.SchemaRequ
}
func (d *serverDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var data serverDataSourceModel
var data data_sources.ServerModel
// Read Terraform configuration data into the model
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
@@ -47,7 +43,7 @@ func (d *serverDataSource) Read(ctx context.Context, req datasource.ReadRequest,
// Read API call logic
// Example data value setting
data.Id = types.StringValue("example-id")
// data.Id = types.StringValue("example-id")
// Save data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
+24 -23
View File
@@ -77,35 +77,35 @@ func (r *serverResource) Schema(ctx context.Context, _ resource.SchemaRequest, r
}
func (r *serverResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var plan resources.ServerModel
var data resources.ServerModel
// Read Terraform plan data into the model
diags := req.Plan.Get(ctx, &plan)
diags := req.Plan.Get(ctx, &data)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
// Create API call logic
tflog.Debug(ctx, fmt.Sprintf("Creating server: name=%s", plan.Name.ValueString()))
tflog.Debug(ctx, fmt.Sprintf("Creating server: name=%s", data.Name.ValueString()))
body := binarylane.CreateServerRequest{
Name: plan.Name.ValueStringPointer(),
Image: plan.Image.ValueString(),
Region: plan.Region.ValueString(),
Size: plan.Size.ValueString(),
Name: data.Name.ValueStringPointer(),
Image: data.Image.ValueString(),
Region: data.Region.ValueString(),
Size: data.Size.ValueString(),
}
if plan.Password.IsNull() {
plan.Password = types.StringUnknown()
if data.Password.IsNull() {
data.Password = types.StringNull()
} else {
body.Password = plan.Password.ValueStringPointer()
body.Password = data.Password.ValueStringPointer()
}
serverResp, err := r.bc.client.PostServersWithResponse(ctx, body)
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("Error creating server: name=%s", plan.Name.ValueString()),
fmt.Sprintf("Error creating server: name=%s", data.Name.ValueString()),
err.Error(),
)
return
@@ -114,16 +114,16 @@ func (r *serverResource) Create(ctx context.Context, req resource.CreateRequest,
if serverResp.StatusCode() != http.StatusOK {
resp.Diagnostics.AddError(
"Unexpected HTTP status code creating server",
fmt.Sprintf("Received %s creating new server: name=%s. Details: %s", serverResp.Status(), plan.Name.ValueString(), serverResp.Body))
fmt.Sprintf("Received %s creating new server: name=%s. Details: %s", serverResp.Status(), data.Name.ValueString(), serverResp.Body))
return
}
assignInt64(serverResp.JSON200.Server.Id, &plan.Id)
assignStr(serverResp.JSON200.Server.Name, &plan.Name)
assignStr(serverResp.JSON200.Server.Image.Slug, &plan.Image)
assignStr(serverResp.JSON200.Server.Region.Slug, &plan.Region)
assignStr(serverResp.JSON200.Server.Size.Slug, &plan.Size)
plan.Backups = types.BoolValue(serverResp.JSON200.Server.NextBackupWindow != nil)
assignInt64(serverResp.JSON200.Server.Id, &data.Id)
assignStr(serverResp.JSON200.Server.Name, &data.Name)
assignStr(serverResp.JSON200.Server.Image.Slug, &data.Image)
assignStr(serverResp.JSON200.Server.Region.Slug, &data.Region)
assignStr(serverResp.JSON200.Server.Size.Slug, &data.Size)
data.Backups = types.BoolValue(serverResp.JSON200.Server.NextBackupWindow != nil)
// assignBool(&serverResp.JSON200.Server.Networks.PortBlocking, &plan.PortBlocking)
if resp.Diagnostics.HasError() {
@@ -131,7 +131,7 @@ func (r *serverResource) Create(ctx context.Context, req resource.CreateRequest,
}
// Save data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...)
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
func (r *serverResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
@@ -157,7 +157,7 @@ func (r *serverResource) Read(ctx context.Context, req resource.ReadRequest, res
if serverResp.StatusCode() != http.StatusOK {
resp.Diagnostics.AddError(
"Unexpected HTTP status code creating server",
"Unexpected HTTP status code reading server",
fmt.Sprintf("Received %s reading server: name=%s. Details: %s", serverResp.Status(), data.Id.String(), serverResp.Body))
return
}
@@ -184,6 +184,7 @@ func (r *serverResource) Update(ctx context.Context, req resource.UpdateRequest,
}
// Update API call logic
// TODO
// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
@@ -207,7 +208,7 @@ func (r *serverResource) Delete(ctx context.Context, req resource.DeleteRequest,
Reason: &reason,
}
delResp, err := r.bc.client.DeleteServersServerIdWithResponse(ctx, data.Id.ValueInt64(), &params)
serverResp, err := r.bc.client.DeleteServersServerIdWithResponse(ctx, data.Id.ValueInt64(), &params)
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("Error deleting server: name=%s, server_id=%s", data.Name.ValueString(), data.Id.String()),
@@ -216,10 +217,10 @@ func (r *serverResource) Delete(ctx context.Context, req resource.DeleteRequest,
return
}
if delResp.StatusCode() != http.StatusNoContent {
if serverResp.StatusCode() != http.StatusNoContent {
resp.Diagnostics.AddError(
"Unexpected HTTP status code deleting server",
fmt.Sprintf("Received %s deleting server: name=%s, server_id=%s. Details: %s", delResp.Status(), data.Name.ValueString(), data.Id.String(), delResp.Body))
fmt.Sprintf("Received %s deleting server: name=%s, server_id=%s. Details: %s", serverResp.Status(), data.Name.ValueString(), data.Id.String(), serverResp.Body))
return
}
}
-78
View File
@@ -1,78 +0,0 @@
package provider
import (
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccOrderResource(t *testing.T) {
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and Read testing
{
Config: providerConfig + `
resource "binarylane_server" "example" {
name = "example"
region = "per"
image = "ubuntu-24.04"
size = "std-min"
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
// Verify number of items
resource.TestCheckResourceAttr("binarylane_server.test", "items.#", "1"),
// Verify first order item
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.quantity", "2"),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.id", "1"),
// Verify first coffee item has Computed attributes filled.
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.description", ""),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.image", "/hashicorp.png"),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.name", "HCP Aeropress"),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.price", "200"),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.teaser", "Automation in a cup"),
// Verify dynamic values have any value set in the state.
resource.TestCheckResourceAttrSet("binarylane_server.test", "id"),
resource.TestCheckResourceAttrSet("binarylane_server.test", "last_updated"),
),
},
// ImportState testing
{
ResourceName: "binarylane_server.test",
ImportState: true,
ImportStateVerify: true,
// The last_updated attribute does not exist in the HashiCups
// API, therefore there is no value for it during import.
ImportStateVerifyIgnore: []string{"last_updated"},
},
// Update and Read testing
{
Config: providerConfig + `
resource "binarylane_server" "test" {
items = [
{
coffee = {
id = 2
}
quantity = 2
},
]
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
// Verify first order item updated
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.quantity", "2"),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.id", "2"),
// Verify first coffee item has Computed attributes updated.
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.description", ""),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.image", "/packer.png"),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.name", "Packer Spiced Latte"),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.price", "350"),
resource.TestCheckResourceAttr("binarylane_server.test", "items.0.coffee.teaser", "Packed with goodness to spice up your images"),
),
},
// Delete testing automatically occurs in TestCase
},
})
}
+73
View File
@@ -0,0 +1,73 @@
package provider
import (
"context"
"fmt"
"net/http"
"terraform-provider-binarylane/internal/resources"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
)
var _ datasource.DataSource = (*sshKeyDataSource)(nil)
func NewSshKeyDataSource() datasource.DataSource {
return &sshKeyDataSource{}
}
type sshKeyDataSource struct {
bc *BinarylaneClient
}
func (d *sshKeyDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_ssh_key"
}
func (d *sshKeyDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Computed: true,
},
},
}
}
func (d *sshKeyDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var data resources.SshKeyModel
// Read Terraform configuration data into the model
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
// Read API call logic
sshResp, err := d.bc.client.GetAccountKeysKeyIdWithResponse(ctx, int(data.Id.ValueInt64()))
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("Error reading SSH Key: name=%s", data.Name.ValueString()),
err.Error(),
)
return
}
if sshResp.StatusCode() != http.StatusOK {
resp.Diagnostics.AddError(
"Unexpected HTTP status code reading SSH Key",
fmt.Sprintf("Received %s reading SSH Key: name=%s. Details: %s", sshResp.Status(), data.Name.ValueString(), sshResp.Body),
)
return
}
// Example data value setting
data.Id = types.Int64Value(*sshResp.JSON200.SshKey.Id)
data.Default = types.BoolValue(*sshResp.JSON200.SshKey.Default)
data.Name = types.StringValue(*sshResp.JSON200.SshKey.Name)
data.PublicKey = types.StringValue(*sshResp.JSON200.SshKey.PublicKey)
// Save data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
+190
View File
@@ -0,0 +1,190 @@
package provider
import (
"context"
"fmt"
"net/http"
"terraform-provider-binarylane/internal/binarylane"
"terraform-provider-binarylane/internal/resources"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/types"
)
// Ensure the implementation satisfies the expected interfaces.
var (
_ resource.Resource = &sshKeyResource{}
_ resource.ResourceWithConfigure = &sshKeyResource{}
// _ resource.ResourceWithImportState = &serverResource{}
)
func NewSshKeyResource() resource.Resource {
return &sshKeyResource{}
}
type sshKeyResource struct {
bc *BinarylaneClient
}
func (d *sshKeyResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
if req.ProviderData == nil {
return
}
bc, ok := req.ProviderData.(BinarylaneClient)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Data Source Configure Type",
fmt.Sprintf("Expected *BinarylaneClient, got: %T.", req.ProviderData),
)
return
}
d.bc = &bc
}
func (r *sshKeyResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_ssh_key"
}
func (r *sshKeyResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = resources.SshKeyResourceSchema(ctx)
resp.Schema.Description = "TODO"
// Overrides
defaultAttr := resp.Schema.Attributes["default"]
resp.Schema.Attributes["default"] = schema.BoolAttribute{
Optional: true,
Computed: true,
Description: defaultAttr.GetDescription(),
MarkdownDescription: defaultAttr.GetMarkdownDescription(),
Default: booldefault.StaticBool(false), // Add default to backups
}
}
func (r *sshKeyResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var data resources.SshKeyModel
// Read Terraform plan data into the model
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
// Create API call logic
sshResp, err := r.bc.client.PostAccountKeysWithResponse(ctx, binarylane.SshKeyRequest{
Name: data.Name.ValueString(),
Default: data.Default.ValueBoolPointer(),
PublicKey: data.PublicKey.ValueString(),
})
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("Error creating SSH Key: name=%s", data.Name.ValueString()),
err.Error(),
)
return
}
if sshResp.StatusCode() != http.StatusOK {
resp.Diagnostics.AddError(
"Unexpected HTTP status code creating server",
fmt.Sprintf("Received %s creating new server: name=%s. Details: %s", sshResp.Status(), data.Name.ValueString(), sshResp.Body),
)
return
}
// Set data values
data.Id = types.Int64Value(*sshResp.JSON200.SshKey.Id)
if resp.Diagnostics.HasError() {
return
}
// Save data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
func (r *sshKeyResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var data resources.SshKeyModel
// Read Terraform prior state data into the model
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
// Read API call logic
sshResp, err := r.bc.client.GetAccountKeysKeyIdWithResponse(ctx, int(data.Id.ValueInt64()))
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("Error creating SSH Key: name=%s", data.Name.ValueString()),
err.Error(),
)
return
}
if sshResp.StatusCode() != http.StatusOK {
resp.Diagnostics.AddError(
"Unexpected HTTP status code creating server",
fmt.Sprintf("Received %s creating new server: name=%s. Details: %s", sshResp.Status(), data.Name.ValueString(), sshResp.Body),
)
return
}
// Set data values
data.Id = types.Int64Value(*sshResp.JSON200.SshKey.Id)
data.Default = types.BoolValue(*sshResp.JSON200.SshKey.Default)
data.Name = types.StringValue(*sshResp.JSON200.SshKey.Name)
data.PublicKey = types.StringValue(*sshResp.JSON200.SshKey.PublicKey)
// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
func (r *sshKeyResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
var data resources.SshKeyModel
// Read Terraform plan data into the model
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
// Update API call logic
// TODO
// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
func (r *sshKeyResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
var data resources.SshKeyModel
// Read Terraform prior state data into the model
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
// Delete API call logic
sshResp, err := r.bc.client.DeleteAccountKeysKeyIdWithResponse(ctx, int(data.Id.ValueInt64()))
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("Error deleting SSH Key: name=%s", data.Name.ValueString()),
err.Error(),
)
return
}
if sshResp.StatusCode() != http.StatusNoContent {
resp.Diagnostics.AddError(
"Unexpected HTTP status code deleting SSH Key",
fmt.Sprintf("Received %s deleting SSH Key: name=%s. Details: %s", sshResp.Status(), data.Name.ValueString(), sshResp.Body),
)
return
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,54 @@
// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
package resources
import (
"context"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
)
func SshKeyResourceSchema(ctx context.Context) schema.Schema {
return schema.Schema{
Attributes: map[string]schema.Attribute{
"default": schema.BoolAttribute{
Optional: true,
Computed: true,
Description: "Optional: If true this will be added to all new server installations (if we support SSH Key injection for the server's operating system).",
MarkdownDescription: "Optional: If true this will be added to all new server installations (if we support SSH Key injection for the server's operating system).",
},
"id": schema.Int64Attribute{
Optional: true,
Computed: true,
Description: "The ID or fingerprint of the SSH Key to fetch.",
MarkdownDescription: "The ID or fingerprint of the SSH Key to fetch.",
},
"name": schema.StringAttribute{
Required: true,
Description: "A name to help you identify the key.",
MarkdownDescription: "A name to help you identify the key.",
Validators: []validator.String{
stringvalidator.LengthAtLeast(1),
},
},
"public_key": schema.StringAttribute{
Required: true,
Description: "The public key in OpenSSH \"authorized_keys\" format.",
MarkdownDescription: "The public key in OpenSSH \"authorized_keys\" format.",
Validators: []validator.String{
stringvalidator.LengthAtLeast(1),
},
},
},
}
}
type SshKeyModel struct {
Default types.Bool `tfsdk:"default"`
Id types.Int64 `tfsdk:"id"`
Name types.String `tfsdk:"name"`
PublicKey types.String `tfsdk:"public_key"`
}
+45 -1451
View File
File diff suppressed because it is too large Load Diff
+36 -10
View File
@@ -49,16 +49,32 @@ resources:
generated and emailed to the account email address.
sensitive: true
optional_required: optional
ignores:
- ipv6
- licenses
- links
- options
- server
- ssh_keys
- vpc_id
- user_data
- port_blocking
ignores:
- ipv6
- licenses
- links
- options
- server
- ssh_keys
- vpc_id
- user_data
- port_blocking
ssh_key:
create:
path: /account/keys
method: POST
read:
path: /account/keys/{key_id}
method: GET
delete:
path: /account/keys/{key_id}
method: DELETE
schema:
attributes:
aliases:
key_id: id
ignores:
- ssh_key
data_sources:
server:
@@ -79,3 +95,13 @@ data_sources:
- vpc_id
- user_data
- port_blocking
ssh_key:
read:
path: /account/keys/{key_id}
method: GET
schema:
attributes:
aliases:
key_id: id
ignores:
- ssh_key