Skip to content

Auto generated data source for Server #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/data-sources/server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "laravelforge_server Data Source - laravelforge"
subcategory: ""
description: |-
Server data source
---

# laravelforge_server (Data Source)

Server data source



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (Number) The ID of the resource.

### Read-Only

- `blackfire_status` (String)
- `created_at` (String)
- `credential_id` (Number) This is only required when the provider is not `custom`.
- `database_type` (String) Valid values are `mysql8`,`mariadb`,`postgres`, `postgres13`, `postgres14` or `postgres15`.
- `ip_address` (String) The IP Address of the server. Only required when the provider is `custom`.
- `is_ready` (String)
- `name` (String)
- `network` (List of Number) An array of server IDs that the server should be able to connect to.
- `opcache_status` (String)
- `papertrail_status` (String)
- `php_cli_version` (String)
- `php_version` (String) Valid values are `php82`, `php81`, `php80`, `php74`, `php73`,`php72`,`php82`, `php70`, and `php56`.
- `private_ip_address` (String) The Private IP Address of the server. Only required when the provider is `custom`.
- `region` (String) The name of the region where the server will be created. This value is not required you are building a Custom VPS server. [Valid region identifiers](/api-documentation#regions).
- `revoked` (String)
- `size` (String)
- `tags` (List of String)


1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ func (p *ForgeProvider) Resources(ctx context.Context) []func() resource.Resourc
func (p *ForgeProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
NewDaemonDataSource,
NewServerDataSource,
}
}

52 changes: 26 additions & 26 deletions internal/provider/server_data_source.go
Original file line number Diff line number Diff line change
@@ -55,78 +55,78 @@ func (d *ServerDataSource) Schema(ctx context.Context, req datasource.SchemaRequ

Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
MarkdownDescription: "",
Computed: true,
MarkdownDescription: "The ID of the resource.",
Required: true,
},
"credential_id": schema.Int64Attribute{
MarkdownDescription: "",
Optional: true,
MarkdownDescription: "This is only required when the provider is not `custom`.",
Computed: true,
},
"name": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"size": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"region": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
MarkdownDescription: "The name of the region where the server will be created. This value is not required you are building a Custom VPS server. [Valid region identifiers](/api-documentation#regions).",
Computed: true,
},
"php_version": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
MarkdownDescription: "Valid values are `php82`, `php81`, `php80`, `php74`, `php73`,`php72`,`php82`, `php70`, and `php56`.",
Computed: true,
},
"php_cli_version": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"opcache_status": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"database_type": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
MarkdownDescription: "Valid values are `mysql8`,`mariadb`,`postgres`, `postgres13`, `postgres14` or `postgres15`.",
Computed: true,
},
"ip_address": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
MarkdownDescription: "The IP Address of the server. Only required when the provider is `custom`.",
Computed: true,
},
"private_ip_address": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
MarkdownDescription: "The Private IP Address of the server. Only required when the provider is `custom`.",
Computed: true,
},
"blackfire_status": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"papertrail_status": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"revoked": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"created_at": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"is_ready": schema.StringAttribute{
MarkdownDescription: "",
Optional: true,
Computed: true,
},
"network": schema.ListAttribute{
ElementType: types.Int64Type,
MarkdownDescription: "",
Optional: true,
MarkdownDescription: "An array of server IDs that the server should be able to connect to.",
Computed: true,
},
"tags": schema.ListAttribute{
ElementType: types.StringType,
MarkdownDescription: "",
Optional: true,
Computed: true,
},
},
}
35 changes: 35 additions & 0 deletions internal/provider/server_data_source_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package provider

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccServerDataSource(t *testing.T) {
rnd := generateRandomResourceName()
name := "data.forge_server." + rnd

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Read testing
{
Config: testAccServerDataSourceConfig(rnd),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(name, "id", "123"),
),
},
},
})
}

func testAccServerDataSourceConfig(resourceName string) string {
return fmt.Sprintf(`
data "forge_server" "%[1]s" {
id = "123"
}
`, resourceName)
}