diff --git a/README.md b/README.md index b64d96a..469aa35 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ The main configuration file is `provider.tf`, which defines the settings for the ```hcl terraform { required_providers { - sfr = { - source = "registry.terraform.io/pseudomonarchia/shopify-function-registry" + shopify = { + source = "registry.terraform.io/pseudomonarchia/terraform-provider-shopify" version = "0.0.1" } } } -provider "sfr" { +provider "shopify" { store_domain = ".myshopify.com" store_access_token = "" store_api_version = "2024-07" diff --git a/examples/data-sources/sfr_function/data-source.tf b/examples/data-sources/sfr_function/data-source.tf index 6fdc2a9..ca86bc6 100644 --- a/examples/data-sources/sfr_function/data-source.tf +++ b/examples/data-sources/sfr_function/data-source.tf @@ -1,14 +1,14 @@ -data "sfr_function" "example_discount" { +data "shopify_function" "example_discount" { app_title = "MyAPP" title = "Discount Automatic Extension" } -data "sfr_function" "example_payment" { +data "shopify_function" "example_payment" { app_title = "MyAPP" title = "Payment Customization Extension" } -data "sfr_function" "example_delivery" { +data "shopify_function" "example_delivery" { app_title = "MyAPP" title = "Delivery Customization Extension" } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 539eeeb..b6b2df6 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -1,13 +1,13 @@ terraform { required_providers { - sfr = { - source = "registry.terraform.io/pseudomonarchia/shopify-function-registry" + shopify = { + source = "registry.terraform.io/pseudomonarchia/terraform-provider-shopify" version = "0.0.1" } } } -provider "sfr" { +provider "shopify" { store_domain = ".myshopify.com" store_access_token = "" store_api_version = "2024-07" diff --git a/examples/resources/sfr_delivery/import.sh b/examples/resources/sfr_delivery/import.sh index 102842c..e913d16 100644 --- a/examples/resources/sfr_delivery/import.sh +++ b/examples/resources/sfr_delivery/import.sh @@ -1 +1 @@ -terraform import sfr_delivery.example , +terraform import shopify_delivery.example , diff --git a/examples/resources/sfr_delivery/resource.tf b/examples/resources/sfr_delivery/resource.tf index 1b4efa5..8f2d8bb 100644 --- a/examples/resources/sfr_delivery/resource.tf +++ b/examples/resources/sfr_delivery/resource.tf @@ -1,4 +1,4 @@ -resource "sfr_delivery" "example" { +resource "shopify_delivery" "example" { function_id = "" title = "Delivery Customization" enabled = true diff --git a/examples/resources/sfr_discount/import.sh b/examples/resources/sfr_discount/import.sh index 947da64..76acdfd 100644 --- a/examples/resources/sfr_discount/import.sh +++ b/examples/resources/sfr_discount/import.sh @@ -1 +1 @@ -terraform import sfr_discount.example , +terraform import shopify_discount.example , diff --git a/examples/resources/sfr_discount/resource.tf b/examples/resources/sfr_discount/resource.tf index 05a70b9..f3e5844 100644 --- a/examples/resources/sfr_discount/resource.tf +++ b/examples/resources/sfr_discount/resource.tf @@ -1,4 +1,4 @@ -resource "sfr_discount" "example" { +resource "shopify_discount" "example" { function_id = "" title = "Automatic Discount" starts_at = "2024-01-09T00:00:00Z" diff --git a/examples/resources/sfr_payment/import.sh b/examples/resources/sfr_payment/import.sh index 26a2719..7b23bcc 100644 --- a/examples/resources/sfr_payment/import.sh +++ b/examples/resources/sfr_payment/import.sh @@ -1 +1 @@ -terraform import sfr_payment.example , +terraform import shopify_payment.example , diff --git a/examples/resources/sfr_payment/resource.tf b/examples/resources/sfr_payment/resource.tf index 8eac503..59ed6cc 100644 --- a/examples/resources/sfr_payment/resource.tf +++ b/examples/resources/sfr_payment/resource.tf @@ -1,4 +1,4 @@ -resource "sfr_payment" "example" { +resource "shopify_payment" "example" { function_id = "" title = "Payment Customization" enabled = true diff --git a/go.mod b/go.mod index c7c9da7..1e4c622 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module shopify-function-registry +module github.com/pseudomonarchia/terraform-provider-shopify go 1.22.6 diff --git a/internal/provider/delivery_custom_resource.go b/internal/provider/delivery_custom_resource.go index ffb2332..5181876 100644 --- a/internal/provider/delivery_custom_resource.go +++ b/internal/provider/delivery_custom_resource.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "regexp" - "shopify-function-registry/internal/shopify" "strings" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" @@ -15,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/pseudomonarchia/terraform-provider-shopify/internal/shopify" ) var _ resource.Resource = (*deliveryCustomResource)(nil) diff --git a/internal/provider/delivery_custom_resource_test.go b/internal/provider/delivery_custom_resource_test.go index a9690d3..e96c45a 100644 --- a/internal/provider/delivery_custom_resource_test.go +++ b/internal/provider/delivery_custom_resource_test.go @@ -16,23 +16,23 @@ func TestAccDeliveryCustomResource(t *testing.T) { { Config: testAccDeliveryCustomResourceConfig("test_delivery", true), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("sfr_delivery.test", "title", "test_delivery"), - resource.TestCheckResourceAttr("sfr_delivery.test", "enabled", "true"), - resource.TestCheckResourceAttrSet("sfr_delivery.test", "id"), - resource.TestCheckResourceAttrSet("sfr_delivery.test", "function_id"), + resource.TestCheckResourceAttr("shopify_delivery.test", "title", "test_delivery"), + resource.TestCheckResourceAttr("shopify_delivery.test", "enabled", "true"), + resource.TestCheckResourceAttrSet("shopify_delivery.test", "id"), + resource.TestCheckResourceAttrSet("shopify_delivery.test", "function_id"), ), }, // 更新測試 { Config: testAccDeliveryCustomResourceConfig("updated_delivery", false), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("sfr_delivery.test", "title", "updated_delivery"), - resource.TestCheckResourceAttr("sfr_delivery.test", "enabled", "false"), + resource.TestCheckResourceAttr("shopify_delivery.test", "title", "updated_delivery"), + resource.TestCheckResourceAttr("shopify_delivery.test", "enabled", "false"), ), }, // 導入測試 { - ResourceName: "sfr_delivery.test", + ResourceName: "shopify_delivery.test", ImportState: true, ImportStateVerify: true, ImportStateIdFunc: testAccDeliveryCustomResourceImportStateIdFunc, @@ -44,7 +44,7 @@ func TestAccDeliveryCustomResource(t *testing.T) { func testAccDeliveryCustomResourceConfig(title string, enabled bool) string { return fmt.Sprintf( ` - resource "sfr_delivery" "test" { + resource "shopify_delivery" "test" { function_id = "00000000-0000-0000-0000-000000000000" title = %q enabled = %t @@ -56,9 +56,9 @@ func testAccDeliveryCustomResourceConfig(title string, enabled bool) string { } func testAccDeliveryCustomResourceImportStateIdFunc(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources["sfr_delivery.test"] + rs, ok := s.RootModule().Resources["shopify_delivery.test"] if !ok { - return "", fmt.Errorf("Resource not found: sfr_delivery.test") + return "", fmt.Errorf("Resource not found: shopify_delivery.test") } return fmt.Sprintf("%s,%s", rs.Primary.ID, rs.Primary.Attributes["function_id"]), nil diff --git a/internal/provider/discount_automatic_resource.go b/internal/provider/discount_automatic_resource.go index f1e63cc..ed23524 100644 --- a/internal/provider/discount_automatic_resource.go +++ b/internal/provider/discount_automatic_resource.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "regexp" - "shopify-function-registry/internal/shopify" "strings" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" @@ -15,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/pseudomonarchia/terraform-provider-shopify/internal/shopify" ) var _ resource.Resource = (*discountAutomaticResource)(nil) diff --git a/internal/provider/discount_automatic_resource_test.go b/internal/provider/discount_automatic_resource_test.go index a7f90fa..3bcaae1 100644 --- a/internal/provider/discount_automatic_resource_test.go +++ b/internal/provider/discount_automatic_resource_test.go @@ -21,31 +21,31 @@ func TestAccDiscountAutomaticResource(t *testing.T) { { Config: testAccDiscountAutomaticResourceConfig(startTime, endTime, true, false, true, false), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("sfr_discount.test", "title", "test_discount"), - resource.TestCheckResourceAttr("sfr_discount.test", "starts_at", startTime), - resource.TestCheckResourceAttr("sfr_discount.test", "ends_at", endTime), - resource.TestCheckResourceAttr("sfr_discount.test", "combines_with.order_discounts", "true"), - resource.TestCheckResourceAttr("sfr_discount.test", "combines_with.product_discounts", "false"), - resource.TestCheckResourceAttr("sfr_discount.test", "combines_with.shipping_discounts", "true"), - resource.TestCheckResourceAttrSet("sfr_discount.test", "id"), - resource.TestCheckResourceAttrSet("sfr_discount.test", "function_id"), + resource.TestCheckResourceAttr("shopify_discount.test", "title", "test_discount"), + resource.TestCheckResourceAttr("shopify_discount.test", "starts_at", startTime), + resource.TestCheckResourceAttr("shopify_discount.test", "ends_at", endTime), + resource.TestCheckResourceAttr("shopify_discount.test", "combines_with.order_discounts", "true"), + resource.TestCheckResourceAttr("shopify_discount.test", "combines_with.product_discounts", "false"), + resource.TestCheckResourceAttr("shopify_discount.test", "combines_with.shipping_discounts", "true"), + resource.TestCheckResourceAttrSet("shopify_discount.test", "id"), + resource.TestCheckResourceAttrSet("shopify_discount.test", "function_id"), ), }, // 更新測試 { Config: testAccDiscountAutomaticResourceConfig(updatedStartTime, "", false, true, false, true), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("sfr_discount.test", "title", "updated_discount"), - resource.TestCheckResourceAttr("sfr_discount.test", "starts_at", updatedStartTime), - resource.TestCheckResourceAttr("sfr_discount.test", "ends_at", ""), - resource.TestCheckResourceAttr("sfr_discount.test", "combines_with.order_discounts", "false"), - resource.TestCheckResourceAttr("sfr_discount.test", "combines_with.product_discounts", "true"), - resource.TestCheckResourceAttr("sfr_discount.test", "combines_with.shipping_discounts", "false"), + resource.TestCheckResourceAttr("shopify_discount.test", "title", "updated_discount"), + resource.TestCheckResourceAttr("shopify_discount.test", "starts_at", updatedStartTime), + resource.TestCheckResourceAttr("shopify_discount.test", "ends_at", ""), + resource.TestCheckResourceAttr("shopify_discount.test", "combines_with.order_discounts", "false"), + resource.TestCheckResourceAttr("shopify_discount.test", "combines_with.product_discounts", "true"), + resource.TestCheckResourceAttr("shopify_discount.test", "combines_with.shipping_discounts", "false"), ), }, // 導入測試 { - ResourceName: "sfr_discount.test", + ResourceName: "shopify_discount.test", ImportState: true, ImportStateVerify: true, ImportStateIdFunc: testAccDiscountAutomaticResourceImportStateIdFunc, @@ -67,7 +67,7 @@ func testAccDiscountAutomaticResourceConfig(startsAt, endsAt string, orderDiscou return fmt.Sprintf( ` - resource "sfr_discount" "test" { + resource "shopify_discount" "test" { function_id = "00000000-0000-0000-0000-000000000000" title = %q starts_at = %q @@ -89,9 +89,9 @@ func testAccDiscountAutomaticResourceConfig(startsAt, endsAt string, orderDiscou } func testAccDiscountAutomaticResourceImportStateIdFunc(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources["sfr_discount.test"] + rs, ok := s.RootModule().Resources["shopify_discount.test"] if !ok { - return "", fmt.Errorf("Resource not found: sfr_discount.test") + return "", fmt.Errorf("Resource not found: shopify_discount.test") } return fmt.Sprintf("%s,%s", rs.Primary.ID, rs.Primary.Attributes["function_id"]), nil diff --git a/internal/provider/function_datasource.go b/internal/provider/function_datasource.go index e1cccdf..345babc 100644 --- a/internal/provider/function_datasource.go +++ b/internal/provider/function_datasource.go @@ -3,7 +3,6 @@ package provider import ( "context" "fmt" - "shopify-function-registry/internal/shopify" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -11,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/pseudomonarchia/terraform-provider-shopify/internal/shopify" ) var _ datasource.DataSource = &FunctinDataSource{} diff --git a/internal/provider/function_datasource_test.go b/internal/provider/function_datasource_test.go index 9613ed0..b48f9e1 100644 --- a/internal/provider/function_datasource_test.go +++ b/internal/provider/function_datasource_test.go @@ -15,10 +15,10 @@ func TestAccFunctionDataSource(t *testing.T) { { Config: testAccFunctionDataSourceConfig(), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("data.sfr_function.test", "id"), - resource.TestCheckResourceAttr("data.sfr_function.test", "title", "test_function"), - resource.TestCheckResourceAttr("data.sfr_function.test", "app_title", "test_app"), - resource.TestCheckResourceAttrSet("data.sfr_function.test", "api_type"), + resource.TestCheckResourceAttrSet("data.shopify_function.test", "id"), + resource.TestCheckResourceAttr("data.shopify_function.test", "title", "test_function"), + resource.TestCheckResourceAttr("data.shopify_function.test", "app_title", "test_app"), + resource.TestCheckResourceAttrSet("data.shopify_function.test", "api_type"), ), }, }, @@ -27,7 +27,7 @@ func TestAccFunctionDataSource(t *testing.T) { func testAccFunctionDataSourceConfig() string { return ` - data "sfr_function" "test" { + data "shopify_function" "test" { title = "test_function" app_title = "test_app" } @@ -48,7 +48,7 @@ func TestAccFunctionDataSource_NotFound(t *testing.T) { func testAccFunctionDataSourceConfig_NotFound() string { return ` - data "sfr_function" "test" { + data "shopify_function" "test" { title = "non_existent_function" app_title = "non_existent_app" } diff --git a/internal/provider/payment_custom_resource.go b/internal/provider/payment_custom_resource.go index 925bd68..ddd3d14 100644 --- a/internal/provider/payment_custom_resource.go +++ b/internal/provider/payment_custom_resource.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "regexp" - "shopify-function-registry/internal/shopify" "strings" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" @@ -15,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/pseudomonarchia/terraform-provider-shopify/internal/shopify" ) var _ resource.Resource = (*paymentCustomResource)(nil) diff --git a/internal/provider/payment_custom_resource_test.go b/internal/provider/payment_custom_resource_test.go index 47f3be1..84afc8e 100644 --- a/internal/provider/payment_custom_resource_test.go +++ b/internal/provider/payment_custom_resource_test.go @@ -16,23 +16,23 @@ func TestAccPaymentCustomResource(t *testing.T) { { Config: testAccPaymentCustomResourceConfig("test_payment", true), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("sfr_payment.test", "title", "test_payment"), - resource.TestCheckResourceAttr("sfr_payment.test", "enabled", "true"), - resource.TestCheckResourceAttrSet("sfr_payment.test", "id"), - resource.TestCheckResourceAttrSet("sfr_payment.test", "function_id"), + resource.TestCheckResourceAttr("shopify_payment.test", "title", "test_payment"), + resource.TestCheckResourceAttr("shopify_payment.test", "enabled", "true"), + resource.TestCheckResourceAttrSet("shopify_payment.test", "id"), + resource.TestCheckResourceAttrSet("shopify_payment.test", "function_id"), ), }, // 更新測試 { Config: testAccPaymentCustomResourceConfig("updated_payment", false), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("sfr_payment.test", "title", "updated_payment"), - resource.TestCheckResourceAttr("sfr_payment.test", "enabled", "false"), + resource.TestCheckResourceAttr("shopify_payment.test", "title", "updated_payment"), + resource.TestCheckResourceAttr("shopify_payment.test", "enabled", "false"), ), }, // 導入測試 { - ResourceName: "sfr_payment.test", + ResourceName: "shopify_payment.test", ImportState: true, ImportStateVerify: true, ImportStateIdFunc: testAccPaymentCustomResourceImportStateIdFunc, @@ -44,7 +44,7 @@ func TestAccPaymentCustomResource(t *testing.T) { func testAccPaymentCustomResourceConfig(title string, enabled bool) string { return fmt.Sprintf( ` - resource "sfr_payment" "test" { + resource "shopify_payment" "test" { function_id = "00000000-0000-0000-0000-000000000000" title = %q enabled = %t @@ -56,9 +56,9 @@ func testAccPaymentCustomResourceConfig(title string, enabled bool) string { } func testAccPaymentCustomResourceImportStateIdFunc(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources["sfr_payment.test"] + rs, ok := s.RootModule().Resources["shopify_payment.test"] if !ok { - return "", fmt.Errorf("Resource not found: sfr_payment.test") + return "", fmt.Errorf("Resource not found: shopify_payment.test") } return fmt.Sprintf("%s,%s", rs.Primary.ID, rs.Primary.Attributes["function_id"]), nil diff --git a/internal/provider/provider.go b/internal/provider/provider.go index fe25c84..8e439ec 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -3,7 +3,6 @@ package provider import ( "context" "regexp" - "shopify-function-registry/internal/shopify" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -12,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/pseudomonarchia/terraform-provider-shopify/internal/shopify" ) var _ provider.Provider = (*funcProvider)(nil) @@ -39,7 +39,7 @@ func (p *funcProvider) Metadata( _ provider.MetadataRequest, resp *provider.MetadataResponse, ) { - resp.TypeName = "sfr" + resp.TypeName = "shopify" resp.Version = p.version } diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index a84ada9..e00bb14 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -10,7 +10,7 @@ import ( ) var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "sfr": providerserver.NewProtocol6WithError(New("test")()), + "shopify": providerserver.NewProtocol6WithError(New("test")()), } func TestAccProvider(t *testing.T) { @@ -19,7 +19,7 @@ func TestAccProvider(t *testing.T) { Steps: []resource.TestStep{ { Config: ` - provider "sfr" { + provider "shopify" { store_domain = "example.myshopify.com" store_access_token = "test_token" store_api_version = "2024-01" @@ -36,7 +36,7 @@ func TestAccProviderInvalidDomain(t *testing.T) { Steps: []resource.TestStep{ { Config: ` - provider "sfr" { + provider "shopify" { store_domain = "invalid-domain" store_access_token = "test_token" store_api_version = "2024-01" @@ -54,7 +54,7 @@ func TestAccProviderInvalidAPIVersion(t *testing.T) { Steps: []resource.TestStep{ { Config: ` - provider "sfr" { + provider "shopify" { store_domain = "example.myshopify.com" store_access_token = "test_token" store_api_version = "invalid-version" diff --git a/main.go b/main.go index 8624a40..4cf6122 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "flag" "log" - "shopify-function-registry/internal/provider" + "github.com/pseudomonarchia/terraform-provider-shopify/internal/provider" "github.com/hashicorp/terraform-plugin-framework/providerserver" ) @@ -18,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 sfr +//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name shopify var version = "0.0.1" @@ -29,7 +29,7 @@ func main() { flag.Parse() opts := providerserver.ServeOpts{ - Address: "registry.terraform.io/pseudomonarchia/shopify-function-registry", + Address: "registry.terraform.io/pseudomonarchia/terraform-provider-shopify", Debug: debug, }