From 903ddcd9e01e8ba281e5c08b4265457f6440a3c9 Mon Sep 17 00:00:00 2001 From: kurochan Date: Sun, 29 Oct 2023 03:48:46 +0900 Subject: [PATCH] `application`: bug: remove unsupported parameters --- internal/provider/resource_application.go | 25 +++---------------- .../provider/resource_application_test.go | 8 +----- internal/provider/resource_piped.go | 4 +-- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/internal/provider/resource_application.go b/internal/provider/resource_application.go index 1d74662..3d7b3b3 100644 --- a/internal/provider/resource_application.go +++ b/internal/provider/resource_application.go @@ -25,6 +25,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/hashicorp/terraform-plugin-log/tflog" api "github.com/pipe-cd/pipecd/pkg/app/server/service/apiservice" "github.com/pipe-cd/pipecd/pkg/model" @@ -56,8 +57,6 @@ type ( applicationResourceGitModel struct { RepositoryID types.String `tfsdk:"repository_id"` - Remote types.String `tfsdk:"remote"` - Branch types.String `tfsdk:"branch"` Path types.String `tfsdk:"path"` Filename types.String `tfsdk:"filename"` } @@ -85,8 +84,6 @@ func (a *ApplicationResource) ImportState(ctx context.Context, req resource.Impo Description: types.StringValue(getResp.Application.Description), Git: applicationResourceGitModel{ RepositoryID: types.StringValue(getResp.Application.GitPath.Repo.Id), - Remote: types.StringValue(getResp.Application.GitPath.Repo.Remote), - Branch: types.StringValue(getResp.Application.GitPath.Repo.Branch), Path: types.StringValue(getResp.Application.GitPath.Path), Filename: types.StringValue(getResp.Application.GitPath.ConfigFilename), }, @@ -161,18 +158,6 @@ func (a *ApplicationResource) Schema(_ context.Context, _ resource.SchemaRequest stringplanmodifier.RequiresReplace(), }, }, - "remote": schema.StringAttribute{ - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "branch": schema.StringAttribute{ - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, "path": schema.StringAttribute{ Description: "The relative path from the root of repository to the application directory.", Required: true, @@ -195,9 +180,7 @@ func (a *ApplicationResource) Schema(_ context.Context, _ resource.SchemaRequest func (a *applicationResourceModel) application() *model.Application { git := &model.ApplicationGitPath{ Repo: &model.ApplicationGitRepository{ - Id: a.Git.RepositoryID.ValueString(), - Remote: a.Git.Remote.ValueString(), - Branch: a.Git.Branch.ValueString(), + Id: a.Git.RepositoryID.ValueString(), }, Path: a.Git.Path.ValueString(), ConfigFilename: a.Git.Filename.ValueString(), @@ -254,6 +237,8 @@ func (a *ApplicationResource) Create(ctx context.Context, req resource.CreateReq return } + tflog.Debug(ctx, "AddApplication response", map[string]interface{}{"response_fields": getResp}) + state := applicationResourceModel{ ID: types.StringValue(addResp.ApplicationId), Name: types.StringValue(getResp.Application.Name), @@ -263,8 +248,6 @@ func (a *ApplicationResource) Create(ctx context.Context, req resource.CreateReq Description: types.StringValue(getResp.Application.Description), Git: applicationResourceGitModel{ RepositoryID: types.StringValue(getResp.Application.GitPath.Repo.Id), - Remote: types.StringValue(getResp.Application.GitPath.Repo.Remote), - Branch: types.StringValue(getResp.Application.GitPath.Repo.Branch), Path: types.StringValue(getResp.Application.GitPath.Path), Filename: types.StringValue(getResp.Application.GitPath.ConfigFilename), }, diff --git a/internal/provider/resource_application_test.go b/internal/provider/resource_application_test.go index 798481f..0d50ff9 100644 --- a/internal/provider/resource_application_test.go +++ b/internal/provider/resource_application_test.go @@ -32,9 +32,7 @@ func TestAccResourceApplication(t *testing.T) { appGit := &model.ApplicationGitPath{ Repo: &model.ApplicationGitRepository{ - Id: "repo_id", - Remote: "repo_remote", - Branch: "main", + Id: "repo_id", }, Path: "path/to/config", ConfigFilename: "testapp.pipecd.yaml", @@ -87,8 +85,6 @@ func TestAccResourceApplication(t *testing.T) { resource.TestCheckResourceAttr("pipecd_application.test", "platform_provider", "test_provider"), resource.TestCheckResourceAttr("pipecd_application.test", "description", "test description"), resource.TestCheckResourceAttr("pipecd_application.test", "git.repository_id", "repo_id"), - resource.TestCheckResourceAttr("pipecd_application.test", "git.remote", "repo_remote"), - resource.TestCheckResourceAttr("pipecd_application.test", "git.branch", "main"), resource.TestCheckResourceAttr("pipecd_application.test", "git.path", "path/to/config"), resource.TestCheckResourceAttr("pipecd_application.test", "git.filename", "testapp.pipecd.yaml"), ), @@ -107,8 +103,6 @@ resource "pipecd_application" "test" { description = "test description" git = { repository_id = "repo_id" - remote = "repo_remote" - branch = "main" path = "path/to/config" filename = "testapp.pipecd.yaml" } diff --git a/internal/provider/resource_piped.go b/internal/provider/resource_piped.go index 185a380..7bb02c5 100644 --- a/internal/provider/resource_piped.go +++ b/internal/provider/resource_piped.go @@ -148,7 +148,7 @@ func (p *PipedResource) Create(ctx context.Context, req resource.CreateRequest, Description: types.StringValue(piped.Desc), APIKey: types.StringValue(registerResp.Key), } - diags = resp.State.Set(ctx, plan) + diags = resp.State.Set(ctx, &plan) resp.Diagnostics.Append(diags...) } @@ -188,7 +188,7 @@ func (p *PipedResource) Update(ctx context.Context, req resource.UpdateRequest, return } - diags = resp.State.Set(ctx, plan) + diags = resp.State.Set(ctx, &plan) resp.Diagnostics.Append(diags...) }