commit 24c7a19068c8197ed212163f1e7ea2fc9d860139
parent 3520c8989567869053a03154b0fce7b0f936e740
Author: MTRNord <mtrnord1@gmail.com>
Date: Wed, 27 Dec 2023 01:27:08 +0100
Fix docs
Diffstat:
5 files changed, 2 insertions(+), 253 deletions(-)
diff --git a/docs/data-sources/matrix_example.md b/docs/data-sources/matrix_example.md
@@ -1,24 +0,0 @@
----
-# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "matrix_example Data Source - matrix-terraform-provider"
-subcategory: ""
-description: |-
- Example data source
----
-
-# matrix_example (Data Source)
-
-Example data source
-
-
-
-<!-- schema generated by tfplugindocs -->
-## Schema
-
-### Optional
-
-- `configurable_attribute` (String) Example configurable attribute
-
-### Read-Only
-
-- `id` (String) Example identifier
diff --git a/docs/resources/matrix_example.md b/docs/resources/matrix_example.md
@@ -1,86 +0,0 @@
----
-# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "matrix_example Resource - matrix-terraform-provider"
-subcategory: ""
-description: |-
- Example resource
----
-
-# matrix_example (Resource)
-
-Example resource
-
-## Example Usage
-
-```terraform
-# Existing media
-resource "matrix_content" "catpic" {
- # Your MXC URI must fit the following format/example:
- # Format: mxc://origin/media_id
- # Example: mxc://matrix.org/SomeGeneratedId
- origin = "matrix.org"
- media_id = "SomeGeneratedId"
-}
-
-# New media (upload)
-resource "matrix_content" "catpic" {
- file_path = "/path/to/cat_pic.png"
- file_name = "cat_pic.png"
- file_type = "image/png"
-}
-
-# Username/password user
-resource "matrix_user" "foouser" {
- username = "foouser"
- password = "hunter2"
-
- # These properties are optional, and will update the user's profile
- # We're using a reference to the Media used in an earlier example
- display_name = "My Cool User"
- avatar_mxc = matrix_content.catpic.id
-}
-
-
-# Access token user
-resource "matrix_user" "baruser" {
- access_token = "MDAxOtherCharactersHere"
-
- # These properties are optional, and will update the user's profile
- # We're using a reference to the Media used in an earlier example
- display_name = "My Cool User"
- avatar_mxc = matrix_content.catpic.id
-}
-
-# Already existing room
-resource "matrix_room" "fooroom" {
- room_id = "!somewhere:domain.com"
- member_access_token = matrix_user.foouser.access_token
-}
-
-# New room
-resource "matrix_room" "barroom" {
- creator_user_id = matrix_user.foouser.id
- member_access_token = matrix_user.foouser.access_token
-
- # The rest is optional
- name = "My Room"
- avatar_mxc = matrix_content.catpic.id
- topic = "For testing only please"
- preset = "public_chat"
- guests_allowed = true
- invite_user_ids = ["${matrix_user.baruser.id}"]
- local_alias_localpart = "myroom"
-}
-```
-
-<!-- schema generated by tfplugindocs -->
-## Schema
-
-### Optional
-
-- `configurable_attribute` (String) Example configurable attribute
-- `defaulted` (String) Example configurable attribute with default value
-
-### Read-Only
-
-- `id` (String) Example identifier
diff --git a/internal/provider/example_data_source.go b/internal/provider/example_data_source.go
@@ -1,105 +0,0 @@
-// Copyright (c) HashiCorp, Inc.
-// SPDX-License-Identifier: MPL-2.0
-
-package provider
-
-import (
- "context"
- "fmt"
- "net/http"
-
- "github.com/hashicorp/terraform-plugin-framework/datasource"
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/hashicorp/terraform-plugin-log/tflog"
-)
-
-// Ensure provider defined types fully satisfy framework interfaces.
-var _ datasource.DataSource = &ExampleDataSource{}
-
-func NewExampleDataSource() datasource.DataSource {
- return &ExampleDataSource{}
-}
-
-// ExampleDataSource defines the data source implementation.
-type ExampleDataSource struct {
- client *http.Client
-}
-
-// ExampleDataSourceModel describes the data source data model.
-type ExampleDataSourceModel struct {
- ConfigurableAttribute types.String `tfsdk:"configurable_attribute"`
- Id types.String `tfsdk:"id"`
-}
-
-func (d *ExampleDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_example"
-}
-
-func (d *ExampleDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
- resp.Schema = schema.Schema{
- // This description is used by the documentation generator and the language server.
- MarkdownDescription: "Example data source",
-
- Attributes: map[string]schema.Attribute{
- "configurable_attribute": schema.StringAttribute{
- MarkdownDescription: "Example configurable attribute",
- Optional: true,
- },
- "id": schema.StringAttribute{
- MarkdownDescription: "Example identifier",
- Computed: true,
- },
- },
- }
-}
-
-func (d *ExampleDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
- // Prevent panic if the provider has not been configured.
- if req.ProviderData == nil {
- return
- }
-
- client, ok := req.ProviderData.(*http.Client)
-
- if !ok {
- resp.Diagnostics.AddError(
- "Unexpected Data Source Configure Type",
- fmt.Sprintf("Expected *http.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
- )
-
- return
- }
-
- d.client = client
-}
-
-func (d *ExampleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
- var data ExampleDataSourceModel
-
- // Read Terraform configuration data into the model
- resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
-
- if resp.Diagnostics.HasError() {
- return
- }
-
- // If applicable, this is a great opportunity to initialize any necessary
- // provider client data and make a call using it.
- // httpResp, err := d.client.Do(httpReq)
- // if err != nil {
- // resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read example, got error: %s", err))
- // return
- // }
-
- // For the purposes of this example code, hardcoding a response value to
- // save into the Terraform state.
- data.Id = types.StringValue("example-id")
-
- // Write logs using the tflog package
- // Documentation: https://terraform.io/plugin/log
- tflog.Trace(ctx, "read a data source")
-
- // Save data into Terraform state
- resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
-}
diff --git a/internal/provider/example_data_source_test.go b/internal/provider/example_data_source_test.go
@@ -1,32 +0,0 @@
-// Copyright (c) HashiCorp, Inc.
-// SPDX-License-Identifier: MPL-2.0
-
-package provider
-
-import (
- "testing"
-
- "github.com/hashicorp/terraform-plugin-testing/helper/resource"
-)
-
-func TestAccExampleDataSource(t *testing.T) {
- resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
- ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
- Steps: []resource.TestStep{
- // Read testing
- {
- Config: testAccExampleDataSourceConfig,
- Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("data.scaffolding_example.test", "id", "example-id"),
- ),
- },
- },
- })
-}
-
-const testAccExampleDataSourceConfig = `
-data "scaffolding_example" "test" {
- configurable_attribute = "example"
-}
-`
diff --git a/internal/provider/provider.go b/internal/provider/provider.go
@@ -178,15 +178,11 @@ func (p *MatrixProvider) Configure(ctx context.Context, req provider.ConfigureRe
}
func (p *MatrixProvider) Resources(ctx context.Context) []func() resource.Resource {
- return []func() resource.Resource{
- NewExampleResource,
- }
+ return []func() resource.Resource{}
}
func (p *MatrixProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
- return []func() datasource.DataSource{
- NewExampleDataSource,
- }
+ return []func() datasource.DataSource{}
}
func New(version string) func() provider.Provider {