Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
general repository maintenance
Browse files Browse the repository at this point in the history
- new license
- go.mod tidy
- remove old docs
- add description and examples
  • Loading branch information
Luiggi33 committed Jul 28, 2024
1 parent 2c6f103 commit e2cc413
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 533 deletions.
376 changes: 4 additions & 372 deletions LICENSE

Large diffs are not rendered by default.

30 changes: 0 additions & 30 deletions docs/data-sources/example.md

This file was deleted.

26 changes: 0 additions & 26 deletions docs/functions/example.md

This file was deleted.

26 changes: 0 additions & 26 deletions docs/index.md

This file was deleted.

31 changes: 0 additions & 31 deletions docs/resources/example.md

This file was deleted.

1 change: 1 addition & 0 deletions examples/resources/pterodactyl_user/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import pterodactyl_user.example terraformer
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/Luiggi33/pterodactyl-client-go v0.0.0-20240724052502-aab4042020e2
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-framework v1.10.0
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
github.com/hashicorp/terraform-plugin-log v0.9.0
)

Expand Down Expand Up @@ -36,7 +37,6 @@ require (
github.com/hashicorp/hc-install v0.7.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-framework-validators v0.13.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
Expand Down
9 changes: 6 additions & 3 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ func (p *pterodactylProvider) Metadata(_ context.Context, _ provider.MetadataReq
// Schema defines the provider-level schema for configuration data.
func (p *pterodactylProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "The Pterodactyl provider allows Terraform to interact with the Pterodactyl Panel API.",
Attributes: map[string]schema.Attribute{
"host": schema.StringAttribute{
Optional: true,
Description: "The Pterodactyl Panel host URL.",
Optional: true,
},
"api_key": schema.StringAttribute{
Optional: true,
Sensitive: true,
Description: "The Pterodactyl Panel API key.",
Optional: true,
Sensitive: true,
},
},
}
Expand Down
45 changes: 29 additions & 16 deletions internal/provider/user_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ func (d *userDataSource) Metadata(ctx context.Context, req datasource.MetadataRe
// Schema defines the schema for the data source.
func (d *userDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "The Pterodactyl user data source allows Terraform to read user data from the Pterodactyl Panel API.",
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Optional: true,
Computed: true,
Description: "The ID of the user.",
Optional: true,
Computed: true,
Validators: []validator.Int64{
int64validator.ExactlyOneOf(
path.MatchRoot("id"),
Expand All @@ -69,8 +71,9 @@ func (d *userDataSource) Schema(ctx context.Context, req datasource.SchemaReques
},
},
"external_id": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "The external ID of the user.",
Optional: true,
Computed: true,
Validators: []validator.String{
stringvalidator.ExactlyOneOf(
path.MatchRoot("id"),
Expand All @@ -81,11 +84,13 @@ func (d *userDataSource) Schema(ctx context.Context, req datasource.SchemaReques
},
},
"uuid": schema.StringAttribute{
Computed: true,
Description: "The UUID of the user.",
Computed: true,
},
"username": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "The username of the user.",
Optional: true,
Computed: true,
Validators: []validator.String{
stringvalidator.ExactlyOneOf(
path.MatchRoot("id"),
Expand All @@ -96,8 +101,9 @@ func (d *userDataSource) Schema(ctx context.Context, req datasource.SchemaReques
},
},
"email": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "The email of the user.",
Optional: true,
Computed: true,
Validators: []validator.String{
stringvalidator.ExactlyOneOf(
path.MatchRoot("id"),
Expand All @@ -108,25 +114,32 @@ func (d *userDataSource) Schema(ctx context.Context, req datasource.SchemaReques
},
},
"first_name": schema.StringAttribute{
Computed: true,
Description: "The first name of the user.",
Computed: true,
},
"last_name": schema.StringAttribute{
Computed: true,
Description: "The last name of the user.",
Computed: true,
},
"language": schema.StringAttribute{
Computed: true,
Description: "The language of the user.",
Computed: true,
},
"root_admin": schema.BoolAttribute{
Computed: true,
Description: "Is the user the root admin.",
Computed: true,
},
"is_2fa": schema.BoolAttribute{
Computed: true,
Description: "Is the user using 2FA.",
Computed: true,
},
"created_at": schema.StringAttribute{
Computed: true,
Description: "The date and time the user was created.",
Computed: true,
},
"updated_at": schema.StringAttribute{
Computed: true,
Description: "The date and time the user was last updated.",
Computed: true,
},
},
}
Expand Down
22 changes: 15 additions & 7 deletions internal/provider/user_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,41 @@ func (r *userResource) Metadata(_ context.Context, req resource.MetadataRequest,
// Schema defines the schema for the resource.
func (r *userResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "The Pterodactyl user resource allows Terraform to manage users in the Pterodactyl Panel API.",
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Computed: true,
Description: "The ID of the user.",
Computed: true,
PlanModifiers: []planmodifier.Int64{
int64planmodifier.UseStateForUnknown(),
},
},
"username": schema.StringAttribute{
Required: true,
Description: "The username of the user.",
Required: true,
},
"email": schema.StringAttribute{
Required: true,
Description: "The email of the user.",
Required: true,
},
"first_name": schema.StringAttribute{
Required: true,
Description: "The first name of the user.",
Required: true,
},
"last_name": schema.StringAttribute{
Required: true,
Description: "The last name of the user.",
Required: true,
},
"created_at": schema.StringAttribute{
Computed: true,
Description: "The creation date of the user.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"updated_at": schema.StringAttribute{
Computed: true,
Description: "The last update date of the user.",
Computed: true,
},
},
}
Expand Down
40 changes: 27 additions & 13 deletions internal/provider/users_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,46 +56,60 @@ func (d *usersDataSource) Metadata(ctx context.Context, req datasource.MetadataR
// Schema defines the schema for the data source.
func (d *usersDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "The Pterodactyl users data source allows Terraform to read user data from the Pterodactyl Panel API.",
Attributes: map[string]schema.Attribute{
"users": schema.ListNestedAttribute{
Computed: true,
Description: "The list of users.",
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Computed: true,
Description: "The ID of the user.",
Computed: true,
},
"external_id": schema.StringAttribute{
Computed: true,
Description: "The external ID of the user.",
Computed: true,
},
"uuid": schema.StringAttribute{
Computed: true,
Description: "The UUID of the user.",
Computed: true,
},
"username": schema.StringAttribute{
Computed: true,
Description: "The username of the user.",
Computed: true,
},
"email": schema.StringAttribute{
Computed: true,
Description: "The email of the user.",
Computed: true,
},
"first_name": schema.StringAttribute{
Computed: true,
Description: "The first name of the user.",
Computed: true,
},
"last_name": schema.StringAttribute{
Computed: true,
Description: "The last name of the user.",
Computed: true,
},
"language": schema.StringAttribute{
Computed: true,
Description: "The language of the user.",
Computed: true,
},
"root_admin": schema.BoolAttribute{
Computed: true,
Description: "Is the user the root admin.",
Computed: true,
},
"is_2fa": schema.BoolAttribute{
Computed: true,
Description: "Is the user using 2FA.",
Computed: true,
},
"created_at": schema.StringAttribute{
Computed: true,
Description: "The creation date of the user.",
Computed: true,
},
"updated_at": schema.StringAttribute{
Computed: true,
Description: "The last update date of the user.",
Computed: true,
},
},
},
Expand Down
7 changes: 2 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package main

import (
Expand All @@ -21,7 +18,7 @@ import (

// Run the docs generation tool, check its repository for more information on how it works and how docs
// can be customized.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name scaffolding
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name pterodactyl

var (
// these will be set by the goreleaser configuration
Expand All @@ -36,7 +33,7 @@ func main() {
flag.Parse()

opts := providerserver.ServeOpts{
Address: "registry.terraform.io/luiggi33/pterodactyl",
Address: "registry.terraform.io/Luiggi33/pterodactyl",
Debug: debug,
}

Expand Down
Loading

0 comments on commit e2cc413

Please sign in to comment.