Skip to content

Commit

Permalink
Merge pull request #27 from terraform-community-providers/token-bugfix
Browse files Browse the repository at this point in the history
Fix personal token header format
  • Loading branch information
pksunkara authored Oct 13, 2023
2 parents 1f89b29 + f7dd6b2 commit 11e975f
Show file tree
Hide file tree
Showing 9 changed files with 17,516 additions and 7,851 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.2.5

### Enhancements
* Add `allow_members_to_invite` to workspace settings

### Bug Fixes
* Fix issues with API token
* Fix issues with updating workspace settings

## 0.2.3

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions docs/resources/workspace_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ resource "linear_workspace_settings" "example" {

### Optional

- `allow_members_to_invite` (Boolean) Allow members to invite new members to the workspace. **Default** `true`.
- `enable_git_linkback_messages` (Boolean) Enable git linkbacks for private repositories. **Default** `true`.
- `enable_git_linkback_messages_public` (Boolean) Enable git linkbacks for public repositories. **Default** `false`.
- `enable_roadmap` (Boolean) Enable roadmap for the workspace. **Default** `false`.
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type authedTransport struct {
}

func (t *authedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Set("Authorization", "bearer "+t.token)
req.Header.Set("Authorization", t.token)

return t.wrapped.RoundTrip(req)
}
319 changes: 203 additions & 116 deletions internal/provider/generated.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions internal/provider/resource_team.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ query getTeam($key: String!) {
# @genqlient(for: "TeamCreateInput.organizationId", omitempty: true)
# @genqlient(for: "TeamCreateInput.defaultTemplateForMembersId", omitempty: true)
# @genqlient(for: "TeamCreateInput.defaultTemplateForNonMembersId", omitempty: true)
# @genqlient(for: "TeamCreateInput.defaultProjectTemplateId", omitempty: true)
# @genqlient(for: "TeamCreateInput.markedAsDuplicateWorkflowStateId", omitempty: true)
# @genqlient(for: "TeamCreateInput.autoCloseStateId", omitempty: true)
mutation createTeam(
Expand All @@ -67,12 +68,14 @@ mutation createTeam(
# @genqlient(for: "TeamUpdateInput.draftWorkflowStateId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.startWorkflowStateId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.reviewWorkflowStateId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.mergeableWorkflowStateId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.mergeWorkflowStateId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.defaultIssueStateId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.markedAsDuplicateWorkflowStateId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.autoCloseStateId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.defaultTemplateForMembersId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.defaultTemplateForNonMembersId", omitempty: true)
# @genqlient(for: "TeamUpdateInput.defaultProjectTemplateId", omitempty: true)
mutation updateTeam(
$input: TeamUpdateInput!,
$id: String!
Expand Down
21 changes: 17 additions & 4 deletions internal/provider/resource_workspace_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type WorkspaceSettingsResource struct {

type WorkspaceSettingsResourceModel struct {
Id types.String `tfsdk:"id"`
AllowMembersToInvite types.Bool `tfsdk:"allow_members_to_invite"`
EnableRoadmap types.Bool `tfsdk:"enable_roadmap"`
EnableGitLinkbackMessages types.Bool `tfsdk:"enable_git_linkback_messages"`
EnableGitLinkbackMessagesPublic types.Bool `tfsdk:"enable_git_linkback_messages_public"`
Expand All @@ -48,6 +49,12 @@ func (r *WorkspaceSettingsResource) Schema(ctx context.Context, req resource.Sch
stringplanmodifier.UseStateForUnknown(),
},
},
"allow_members_to_invite": schema.BoolAttribute{
MarkdownDescription: "Allow members to invite new members to the workspace. **Default** `true`.",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"enable_roadmap": schema.BoolAttribute{
MarkdownDescription: "Enable roadmap for the workspace. **Default** `false`.",
Optional: true,
Expand Down Expand Up @@ -99,7 +106,8 @@ func (r *WorkspaceSettingsResource) Create(ctx context.Context, req resource.Cre
return
}

input := UpdateOrganizationInput{
input := OrganizationUpdateInput{
AllowMembersToInvite: data.AllowMembersToInvite.ValueBool(),
RoadmapEnabled: data.EnableRoadmap.ValueBool(),
GitLinkbackMessagesEnabled: data.EnableGitLinkbackMessages.ValueBool(),
GitPublicLinkbackMessagesEnabled: data.EnableGitLinkbackMessagesPublic.ValueBool(),
Expand All @@ -115,6 +123,7 @@ func (r *WorkspaceSettingsResource) Create(ctx context.Context, req resource.Cre
organization := response.OrganizationUpdate.Organization

data.Id = types.StringValue(organization.Id)
data.AllowMembersToInvite = types.BoolValue(organization.AllowMembersToInvite)
data.EnableRoadmap = types.BoolValue(organization.RoadmapEnabled)
data.EnableGitLinkbackMessages = types.BoolValue(organization.GitLinkbackMessagesEnabled)
data.EnableGitLinkbackMessagesPublic = types.BoolValue(organization.GitPublicLinkbackMessagesEnabled)
Expand All @@ -141,6 +150,7 @@ func (r *WorkspaceSettingsResource) Read(ctx context.Context, req resource.ReadR
organization := response.Organization

data.Id = types.StringValue(organization.Id)
data.AllowMembersToInvite = types.BoolValue(organization.AllowMembersToInvite)
data.EnableRoadmap = types.BoolValue(organization.RoadmapEnabled)
data.EnableGitLinkbackMessages = types.BoolValue(organization.GitLinkbackMessagesEnabled)
data.EnableGitLinkbackMessagesPublic = types.BoolValue(organization.GitPublicLinkbackMessagesEnabled)
Expand All @@ -157,7 +167,8 @@ func (r *WorkspaceSettingsResource) Update(ctx context.Context, req resource.Upd
return
}

input := UpdateOrganizationInput{
input := OrganizationUpdateInput{
AllowMembersToInvite: data.AllowMembersToInvite.ValueBool(),
RoadmapEnabled: data.EnableRoadmap.ValueBool(),
GitLinkbackMessagesEnabled: data.EnableGitLinkbackMessages.ValueBool(),
GitPublicLinkbackMessagesEnabled: data.EnableGitLinkbackMessagesPublic.ValueBool(),
Expand All @@ -175,6 +186,7 @@ func (r *WorkspaceSettingsResource) Update(ctx context.Context, req resource.Upd
organization := response.OrganizationUpdate.Organization

data.Id = types.StringValue(organization.Id)
data.AllowMembersToInvite = types.BoolValue(organization.AllowMembersToInvite)
data.EnableRoadmap = types.BoolValue(organization.RoadmapEnabled)
data.EnableGitLinkbackMessages = types.BoolValue(organization.GitLinkbackMessagesEnabled)
data.EnableGitLinkbackMessagesPublic = types.BoolValue(organization.GitPublicLinkbackMessagesEnabled)
Expand All @@ -191,9 +203,10 @@ func (r *WorkspaceSettingsResource) Delete(ctx context.Context, req resource.Del
return
}

input := UpdateOrganizationInput{
input := OrganizationUpdateInput{
AllowMembersToInvite: true,
RoadmapEnabled: false,
GitLinkbackMessagesEnabled: false,
GitLinkbackMessagesEnabled: true,
GitPublicLinkbackMessagesEnabled: false,
}

Expand Down
27 changes: 15 additions & 12 deletions internal/provider/resource_workspace_settings.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fragment Organization on Organization {
id
allowMembersToInvite
roadmapEnabled
gitLinkbackMessagesEnabled
gitPublicLinkbackMessagesEnabled
Expand All @@ -11,19 +12,21 @@ query getWorkspaceSettings {
}
}

# @genqlient(for: "UpdateOrganizationInput.name", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.urlKey", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.logoUrl", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.gitBranchFormat", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.projectUpdatesReminderFrequency", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.projectUpdateRemindersDay", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.projectUpdateRemindersHour", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.reducedPersonalInformation", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.linearPreviewFlags", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.allowedAuthServices", omitempty: true)
# @genqlient(for: "UpdateOrganizationInput.oauthAppReview", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.name", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.urlKey", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.logoUrl", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.gitBranchFormat", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.projectUpdatesReminderFrequency", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.projectUpdateRemindersDay", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.projectUpdateRemindersHour", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.reducedPersonalInformation", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.linearPreviewFlags", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.allowedAuthServices", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.oauthAppReview", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.slaDayCount", omitempty: true)
# @genqlient(for: "OrganizationUpdateInput.slaEnabled", omitempty: true)
mutation updateWorkspaceSettings(
$input: UpdateOrganizationInput!,
$input: OrganizationUpdateInput!,
) {
organizationUpdate(input: $input) {
organization {
Expand Down
7 changes: 7 additions & 0 deletions internal/provider/resource_workspace_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func TestAccWorkspaceSettingsResourceDefault(t *testing.T) {
Config: testAccWorkspaceSettingsResourceConfigDefault(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestMatchResourceAttr("linear_workspace_settings.test", "id", uuidRegex()),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "allow_members_to_invite", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_roadmap", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages_public", "false"),
Expand All @@ -32,6 +33,7 @@ func TestAccWorkspaceSettingsResourceDefault(t *testing.T) {
Config: testAccWorkspaceSettingsResourceConfigDefault(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestMatchResourceAttr("linear_workspace_settings.test", "id", uuidRegex()),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "allow_members_to_invite", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_roadmap", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages_public", "false"),
Expand All @@ -42,6 +44,7 @@ func TestAccWorkspaceSettingsResourceDefault(t *testing.T) {
Config: testAccWorkspaceSettingsResourceConfigNonDefault(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestMatchResourceAttr("linear_workspace_settings.test", "id", uuidRegex()),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "allow_members_to_invite", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_roadmap", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages_public", "true"),
Expand All @@ -68,6 +71,7 @@ func TestAccWorkspaceSettingsResourceNonDefault(t *testing.T) {
Config: testAccWorkspaceSettingsResourceConfigNonDefault(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestMatchResourceAttr("linear_workspace_settings.test", "id", uuidRegex()),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "allow_members_to_invite", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_roadmap", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages_public", "true"),
Expand All @@ -84,6 +88,7 @@ func TestAccWorkspaceSettingsResourceNonDefault(t *testing.T) {
Config: testAccWorkspaceSettingsResourceConfigNonDefault(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestMatchResourceAttr("linear_workspace_settings.test", "id", uuidRegex()),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "allow_members_to_invite", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_roadmap", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages_public", "true"),
Expand All @@ -94,6 +99,7 @@ func TestAccWorkspaceSettingsResourceNonDefault(t *testing.T) {
Config: testAccWorkspaceSettingsResourceConfigDefault(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestMatchResourceAttr("linear_workspace_settings.test", "id", uuidRegex()),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "allow_members_to_invite", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_roadmap", "false"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages", "true"),
resource.TestCheckResourceAttr("linear_workspace_settings.test", "enable_git_linkback_messages_public", "false"),
Expand All @@ -120,6 +126,7 @@ resource "linear_workspace_settings" "test" {
func testAccWorkspaceSettingsResourceConfigNonDefault() string {
return `
resource "linear_workspace_settings" "test" {
allow_members_to_invite = false
enable_roadmap = true
enable_git_linkback_messages = false
enable_git_linkback_messages_public = true
Expand Down
Loading

0 comments on commit 11e975f

Please sign in to comment.