terraform-provider-matrix

git clone git://archive.git.mtrnord.blog/MTRNord/terraform-provider-matrix.git
Log | Files | Refs | README | LICENSE

commit 3520c8989567869053a03154b0fce7b0f936e740
parent a0fed5e61875821d2f83d2fcce04cbc9ba7834d9
Author: MTRNord <mtrnord1@gmail.com>
Date:   Wed, 27 Dec 2023 01:22:35 +0100

Some initial work on implementing this

Diffstat:
A.github/CODEOWNERS | 1+
A.github/CODE_OF_CONDUCT.md | 5+++++
Adocs/data-sources/matrix_example.md | 24++++++++++++++++++++++++
Ddocs/data-sources/scaffolding_example.md | 30------------------------------
Mdocs/index.md | 27+++++++++++++++++++++------
Adocs/resources/matrix_example.md | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ddocs/resources/scaffolding_example.md | 31-------------------------------
Aexamples/data-sources/.gitkeep | 0
Dexamples/data-sources/scaffolding_example/data-source.tf | 3---
Aexamples/provider-install-verification/main.tf | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mexamples/provider/provider.tf | 20+++++++++++++++++---
Aexamples/resources/matrix_example/resource.tf | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dexamples/resources/scaffolding_example/resource.tf | 3---
Mgo.mod | 4++--
Mgo.sum | 4++--
Minternal/provider/provider.go | 159+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Mmain.go | 5++---
17 files changed, 437 insertions(+), 106 deletions(-)

diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @hashicorp/terraform-devex diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,5 @@ +# Code of Conduct + +HashiCorp Community Guidelines apply to you when interacting with the community here on GitHub and contributing code. + +Please read the full text at https://www.hashicorp.com/community-guidelines diff --git a/docs/data-sources/matrix_example.md b/docs/data-sources/matrix_example.md @@ -0,0 +1,24 @@ +--- +# 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/data-sources/scaffolding_example.md b/docs/data-sources/scaffolding_example.md @@ -1,30 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "scaffolding_example Data Source - terraform-provider-scaffolding-framework" -subcategory: "" -description: |- - Example data source ---- - -# scaffolding_example (Data Source) - -Example data source - -## Example Usage - -```terraform -data "scaffolding_example" "example" { - configurable_attribute = "some-value" -} -``` - -<!-- schema generated by tfplugindocs --> -## Schema - -### Optional - -- `configurable_attribute` (String) Example configurable attribute - -### Read-Only - -- `id` (String) Example identifier diff --git a/docs/index.md b/docs/index.md @@ -1,26 +1,41 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "scaffolding-framework Provider" +page_title: "matrix-terraform-provider Provider" subcategory: "" description: |- --- -# scaffolding-framework Provider +# matrix-terraform-provider Provider ## Example Usage ```terraform -provider "scaffolding" { - # example configuration here +provider "matrix" { + # The client/server URL to access your matrix homeserver with. + # Environment variable: MATRIX_CLIENT_SERVER_URL + client_server_url = "https://matrix.org" + + # The default access token to use for things like content uploads. + # Does not apply for provisioning users. + # Environment variable: MATRIX_DEFAULT_ACCESS_TOKEN + default_access_token = "MDAxSomeRandomString" + + # The default userID to use for things like content uploads. + # Must match the user that owns the default_access_token. + # Does not apply for provisioning users. + # Environment variable: MATRIX_DEFAULT_USERID + default_user_id = "@meow:matrix.org" } ``` <!-- schema generated by tfplugindocs --> ## Schema -### Optional +### Required -- `endpoint` (String) Example provider attribute +- `client_server_url` (String) Address of the matrix server you are acting upon +- `default_access_token` (String, Sensitive) The default access token to use for things like content uploads. +- `default_user_id` (String) The default user id to use for things like content uploads. This must match the access_token diff --git a/docs/resources/matrix_example.md b/docs/resources/matrix_example.md @@ -0,0 +1,86 @@ +--- +# 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/docs/resources/scaffolding_example.md b/docs/resources/scaffolding_example.md @@ -1,31 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "scaffolding_example Resource - terraform-provider-scaffolding-framework" -subcategory: "" -description: |- - Example resource ---- - -# scaffolding_example (Resource) - -Example resource - -## Example Usage - -```terraform -resource "scaffolding_example" "example" { - configurable_attribute = "some-value" -} -``` - -<!-- 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/examples/data-sources/.gitkeep b/examples/data-sources/.gitkeep diff --git a/examples/data-sources/scaffolding_example/data-source.tf b/examples/data-sources/scaffolding_example/data-source.tf @@ -1,3 +0,0 @@ -data "scaffolding_example" "example" { - configurable_attribute = "some-value" -} diff --git a/examples/provider-install-verification/main.tf b/examples/provider-install-verification/main.tf @@ -0,0 +1,83 @@ +terraform { + required_providers { + matrix = { + source = "mtrnord/matrix" + } + } +} + +provider "matrix" { + # The client/server URL to access your matrix homeserver with. + # Environment variable: MATRIX_CLIENT_SERVER_URL + client_server_url = "https://matrix.org" + + # The default access token to use for things like content uploads. + # Does not apply for provisioning users. + # Environment variable: MATRIX_DEFAULT_ACCESS_TOKEN + default_access_token = "MDAxSomeRandomString" + + # The default userID to use for things like content uploads. + # Must match the user that owns the default_access_token. + # Does not apply for provisioning users. + # Environment variable: MATRIX_DEFAULT_USERID + default_user_id = "@meow:matrix.org" +} + +# # 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" +} + diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf @@ -1,3 +1,16 @@ -provider "scaffolding" { - # example configuration here -} +provider "matrix" { + # The client/server URL to access your matrix homeserver with. + # Environment variable: MATRIX_CLIENT_SERVER_URL + client_server_url = "https://matrix.org" + + # The default access token to use for things like content uploads. + # Does not apply for provisioning users. + # Environment variable: MATRIX_DEFAULT_ACCESS_TOKEN + default_access_token = "MDAxSomeRandomString" + + # The default userID to use for things like content uploads. + # Must match the user that owns the default_access_token. + # Does not apply for provisioning users. + # Environment variable: MATRIX_DEFAULT_USERID + default_user_id = "@meow:matrix.org" +} +\ No newline at end of file diff --git a/examples/resources/matrix_example/resource.tf b/examples/resources/matrix_example/resource.tf @@ -0,0 +1,58 @@ +# 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" +} diff --git a/examples/resources/scaffolding_example/resource.tf b/examples/resources/scaffolding_example/resource.tf @@ -1,3 +0,0 @@ -resource "scaffolding_example" "example" { - configurable_attribute = "some-value" -} diff --git a/go.mod b/go.mod @@ -1,4 +1,4 @@ -module github.com/MTRNord/matrix-terraform-provider +module github.com/MTRNord/terraform-provider-matrix go 1.20 @@ -8,7 +8,7 @@ require ( github.com/hashicorp/terraform-plugin-go v0.20.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-testing v1.6.0 - github.com/hashicorp/terraform-provider-scaffolding-framework v0.0.0-20231219111208-befcee6255f2 + github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 ) require ( diff --git a/go.sum b/go.sum @@ -95,8 +95,6 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 h1:X7vB6vn5tON2b49ILa4W7mFA github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0/go.mod h1:ydFcxbdj6klCqYEPkPvdvFKiNGKZLUs+896ODUXCyao= github.com/hashicorp/terraform-plugin-testing v1.6.0 h1:Wsnfh+7XSVRfwcr2jZYHsnLOnZl7UeaOBvsx6dl/608= github.com/hashicorp/terraform-plugin-testing v1.6.0/go.mod h1:cJGG0/8j9XhHaJZRC+0sXFI4uzqQZ9Az4vh6C4GJpFE= -github.com/hashicorp/terraform-provider-scaffolding-framework v0.0.0-20231219111208-befcee6255f2 h1:8v+EGCvEmJL0wiMMORlGckm25QL4D8m1KBe4dk7S+So= -github.com/hashicorp/terraform-provider-scaffolding-framework v0.0.0-20231219111208-befcee6255f2/go.mod h1:v9mQBoqCDSxVqEzd3wCX7l5ZyRCdSc6V8BpoS3tyTAg= 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= @@ -118,6 +116,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U= +github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= diff --git a/internal/provider/provider.go b/internal/provider/provider.go @@ -5,72 +5,185 @@ package provider import ( "context" - "net/http" + "os" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/matrix-org/gomatrix" ) -// Ensure ScaffoldingProvider satisfies various provider interfaces. -var _ provider.Provider = &ScaffoldingProvider{} +// Ensure MatrixProvider satisfies various provider interfaces. +var _ provider.Provider = &MatrixProvider{} -// ScaffoldingProvider defines the provider implementation. -type ScaffoldingProvider struct { +// MatrixProvider defines the provider implementation. +type MatrixProvider struct { // version is set to the provider version on release, "dev" when the // provider is built and ran locally, and "test" when running acceptance // testing. version string } -// ScaffoldingProviderModel describes the provider data model. -type ScaffoldingProviderModel struct { - Endpoint types.String `tfsdk:"endpoint"` +// MatrixProviderModel describes the provider data model. +type MatrixProviderModel struct { + ClientServerUrl types.String `tfsdk:"client_server_url"` + DefaultAccessToken types.String `tfsdk:"default_access_token"` + DefaultUserID types.String `tfsdk:"default_user_id"` } -func (p *ScaffoldingProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { - resp.TypeName = "scaffolding" +func (p *MatrixProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { + resp.TypeName = "matrix" resp.Version = p.version } -func (p *ScaffoldingProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { +func (p *MatrixProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ - "endpoint": schema.StringAttribute{ - MarkdownDescription: "Example provider attribute", - Optional: true, + "client_server_url": schema.StringAttribute{ + MarkdownDescription: "Address of the matrix server you are acting upon", + Required: true, + }, + "default_access_token": schema.StringAttribute{ + MarkdownDescription: "The default access token to use for things like content uploads.", + Required: true, + Sensitive: true, + }, + "default_user_id": schema.StringAttribute{ + MarkdownDescription: "The default user id to use for things like content uploads. This must match the access_token", + Required: true, }, }, } } -func (p *ScaffoldingProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { - var data ScaffoldingProviderModel +func (p *MatrixProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { + var config MatrixProviderModel + + resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) + + if resp.Diagnostics.HasError() { + return + } + + if config.ClientServerUrl.IsUnknown() { + resp.Diagnostics.AddAttributeError( + path.Root("client_server_url"), + "Unknown Matrix Server URL", + "The provider cannot create the Matrix API client as there is an unknown configuration value for the Matrix API host. "+ + "Either target apply the source of the value first, set the value statically in the configuration, or use the MATRIX_CLIENT_SERVER_URL environment variable.", + ) + } + + if config.DefaultAccessToken.IsUnknown() { + resp.Diagnostics.AddAttributeError( + path.Root("default_access_token"), + "Unknown Default Access Token", + "The provider cannot create the Matrix API client as there is an unknown configuration value for the default AccessToken. "+ + "Either target apply the source of the value first, set the value statically in the configuration, or use the MATRIX_DEFAULT_ACCESS_TOKEN environment variable.", + ) + } + + if config.DefaultUserID.IsUnknown() { + resp.Diagnostics.AddAttributeError( + path.Root("default_user_id"), + "Unknown Default User ID", + "The provider cannot create the Matrix API client as there is an unknown configuration value for the default UserID. "+ + "Either target apply the source of the value first, set the value statically in the configuration, or use the MATRIX_DEFAULT_USERID environment variable.", + ) + } + + if resp.Diagnostics.HasError() { + return + } + + // Default values to environment variables, but override + // with Terraform configuration value if set. + + client_server_url := os.Getenv("MATRIX_CLIENT_SERVER_URL") + default_access_token := os.Getenv("MATRIX_DEFAULT_ACCESS_TOKEN") + default_user_id := os.Getenv("MATRIX_DEFAULT_USERID") - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if !config.ClientServerUrl.IsNull() { + client_server_url = config.ClientServerUrl.ValueString() + } + + if !config.DefaultAccessToken.IsNull() { + default_access_token = config.DefaultAccessToken.ValueString() + } + + if !config.DefaultUserID.IsNull() { + default_user_id = config.DefaultUserID.ValueString() + } + + if client_server_url == "" { + resp.Diagnostics.AddAttributeError( + path.Root("client_server_url"), + "Missing Matrix Server URL", + "The provider cannot create the Matrix API client as there is a missing or empty value for the Matrix API host. "+ + "Set the client_server_url value in the configuration or use the MATRIX_CLIENT_SERVER_URL environment variable. "+ + "If either is already set, ensure the value is not empty.", + ) + } + + if default_access_token == "" { + resp.Diagnostics.AddAttributeError( + path.Root("default_access_token"), + "Missing Default Access Token", + "The provider cannot create the Matrix API client as there is a missing or empty value for the default AccessToken. "+ + "Set the default_access_token value in the configuration or use the MATRIX_DEFAULT_ACCESS_TOKEN environment variable. "+ + "If either is already set, ensure the value is not empty.", + ) + } + + if default_user_id == "" { + resp.Diagnostics.AddAttributeError( + path.Root("default_user_id"), + "Missing Default UserID", + "The provider cannot create the Matrix API client as there is a missing or empty value for the default UserID. "+ + "Set the default_user_id value in the configuration or use the MATRIX_DEFAULT_USERID environment variable. "+ + "If either is already set, ensure the value is not empty.", + ) + } if resp.Diagnostics.HasError() { return } - // Configuration values are now available. - // if data.Endpoint.IsNull() { /* ... */ } + ctx = tflog.SetField(ctx, "client_server_url", client_server_url) + ctx = tflog.SetField(ctx, "default_access_token", default_access_token) + ctx = tflog.SetField(ctx, "default_user_id", default_user_id) + ctx = tflog.MaskFieldValuesWithFieldKeys(ctx, "default_access_token") + + tflog.Debug(ctx, "Creating Matrix client") // Example client configuration for data sources and resources - client := http.DefaultClient + client, err := gomatrix.NewClient(client_server_url, default_user_id, default_access_token) + if err != nil { + resp.Diagnostics.AddError( + "Unable to Create Matrix API Client", + "An unexpected error occurred when creating the Matrix API client. "+ + "If the error is not clear, please contact the provider developers.\n\n"+ + "Matrix Client Error: "+err.Error(), + ) + return + } resp.DataSourceData = client resp.ResourceData = client + + tflog.Info(ctx, "Configured Matrix client", map[string]any{"success": true}) } -func (p *ScaffoldingProvider) Resources(ctx context.Context) []func() resource.Resource { +func (p *MatrixProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ NewExampleResource, } } -func (p *ScaffoldingProvider) DataSources(ctx context.Context) []func() datasource.DataSource { +func (p *MatrixProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ NewExampleDataSource, } @@ -78,7 +191,7 @@ func (p *ScaffoldingProvider) DataSources(ctx context.Context) []func() datasour func New(version string) func() provider.Provider { return func() provider.Provider { - return &ScaffoldingProvider{ + return &MatrixProvider{ version: version, } } diff --git a/main.go b/main.go @@ -8,7 +8,7 @@ import ( "flag" "log" - "github.com/MTRNord/matrix-terraform-provider/internal/provider" + "github.com/MTRNord/terraform-provider-matrix/internal/provider" "github.com/hashicorp/terraform-plugin-framework/providerserver" ) @@ -38,8 +38,7 @@ func main() { flag.Parse() opts := providerserver.ServeOpts{ - // TODO: Update this string with the published name of your provider. - Address: "registry.terraform.io/hashicorp/scaffolding", + Address: "registry.terraform.io/MTRNord/matrix", Debug: debug, }