From ab309f9cc85548b21c88e638fafd512acb71b7c0 Mon Sep 17 00:00:00 2001 From: Diogo Serrano Date: Wed, 10 Jul 2024 15:10:45 +0100 Subject: [PATCH] Add instance dns name (#102) --- docs/resources/instance.md | 1 + go.mod | 2 +- go.sum | 4 ++-- internal/provider/instance_resource.go | 7 +++++++ internal/provider/instance_types.go | 4 ++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/resources/instance.md b/docs/resources/instance.md index ef88d97..1b82e8d 100644 --- a/docs/resources/instance.md +++ b/docs/resources/instance.md @@ -62,6 +62,7 @@ resource "genesiscloud_instance" "example" { ### Read-Only - `created_at` (String) The timestamp when this image was created in RFC 3339. +- `dns_name` (String) The dns name of the instance. - `id` (String) The unique ID of the instance. - `image_id` (String) The resulting image ID of the instance. - `private_ip` (String) The private IPv4 IP-Address (IPv4 address). diff --git a/go.mod b/go.mod index cb8eda5..f9f6a7e 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 toolchain go1.22.1 require ( - github.com/genesiscloud/genesiscloud-go v1.0.8 + github.com/genesiscloud/genesiscloud-go v1.0.9 github.com/hashicorp/go-retryablehttp v0.7.7 github.com/hashicorp/terraform-plugin-docs v0.19.4 github.com/hashicorp/terraform-plugin-framework v1.9.0 diff --git a/go.sum b/go.sum index 7557145..cf7d29a 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,8 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= -github.com/genesiscloud/genesiscloud-go v1.0.8 h1:HiRHHaST1UOgsIAko739LPICB9SkgafalJHVu26DdKk= -github.com/genesiscloud/genesiscloud-go v1.0.8/go.mod h1:OAMjSCejQTC4BBLWXleegT/fg+X46SZ6t/vW9RPtXWg= +github.com/genesiscloud/genesiscloud-go v1.0.9 h1:IiRBbO7yRZYz9pBJbRfc3DRiai666T12k/4PvhZXOTw= +github.com/genesiscloud/genesiscloud-go v1.0.9/go.mod h1:OAMjSCejQTC4BBLWXleegT/fg+X46SZ6t/vW9RPtXWg= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= diff --git a/internal/provider/instance_resource.go b/internal/provider/instance_resource.go index 5f6b628..e8adae8 100644 --- a/internal/provider/instance_resource.go +++ b/internal/provider/instance_resource.go @@ -63,6 +63,13 @@ func (r *InstanceResource) Schema(ctx context.Context, req resource.SchemaReques stringplanmodifier.UseStateForUnknown(), // immutable }, }), + "dns_name": resourceenhancer.Attribute(ctx, schema.StringAttribute{ + MarkdownDescription: "The dns name of the instance.", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), // immutable + }, + }), "id": resourceenhancer.Attribute(ctx, schema.StringAttribute{ MarkdownDescription: "The unique ID of the instance.", Computed: true, diff --git a/internal/provider/instance_types.go b/internal/provider/instance_types.go index 6facee2..28ae3d4 100644 --- a/internal/provider/instance_types.go +++ b/internal/provider/instance_types.go @@ -23,6 +23,9 @@ type InstanceResourceModel struct { // Hostname The hostname of your instance. Hostname types.String `tfsdk:"hostname"` + // DnsName The dns name of your instance. + DnsName types.String `tfsdk:"dns_name"` + // Id The unique ID of the instance. Id types.String `tfsdk:"id"` @@ -92,6 +95,7 @@ func (data *InstanceResourceModel) PopulateFromClientResponse(ctx context.Contex data.Id = types.StringValue(instance.Id) data.Name = types.StringValue(instance.Name) data.Hostname = types.StringValue(instance.Hostname) + data.DnsName = types.StringValue(instance.DnsName) data.Type = types.StringValue(string(instance.Type)) data.ImageId = types.StringValue(instance.Image.Id)