Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit 1354bfa

Browse files
committed
Fix org specifiers
1 parent 294bc70 commit 1354bfa

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

graphql/generated.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graphql/genqlient.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ query GetFullApp($name: String) {
44
network
55
organization {
66
id
7+
slug
78
}
89
autoscaling {
910
preferredRegion
@@ -47,6 +48,7 @@ mutation CreateAppMutation($name: String, $organizationId: ID!) {
4748
status
4849
organization {
4950
id
51+
slug
5052
}
5153
}
5254
}

internal/provider/app_resource.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ var _ tfsdk.ResourceWithImportState = flyAppResource{}
2222
type flyAppResourceType struct{}
2323

2424
type flyAppResourceData struct {
25-
Name types.String `tfsdk:"name"`
26-
Org types.String `tfsdk:"org"`
25+
Name types.String `tfsdk:"name"`
26+
Org types.String `tfsdk:"org"`
27+
OrgId types.String `tfsdk:"orgid"`
2728
}
2829

2930
func (ar flyAppResourceType) GetSchema(context.Context) (tfsdk.Schema, diag.Diagnostics) {
@@ -40,7 +41,12 @@ func (ar flyAppResourceType) GetSchema(context.Context) (tfsdk.Schema, diag.Diag
4041
"org": {
4142
Computed: true,
4243
Optional: true,
43-
MarkdownDescription: "Optional org ID to operate upon",
44+
MarkdownDescription: "Optional org slug to operate upon",
45+
Type: types.StringType,
46+
},
47+
"orgid": {
48+
Computed: true,
49+
MarkdownDescription: "readonly orgid",
4450
Type: types.StringType,
4551
},
4652
},
@@ -82,7 +88,7 @@ func (r flyAppResource) Create(ctx context.Context, req tfsdk.CreateResourceRequ
8288
resp.Diagnostics.AddError("Could not resolve organization", err.Error())
8389
return
8490
}
85-
data.Org.Value = org.Organization.Id
91+
data.OrgId.Value = org.Organization.Id
8692
}
8793

8894
mresp, err := graphql.CreateAppMutation(context.Background(), *r.provider.client, data.Name.Value, data.Org.Value)
@@ -92,8 +98,9 @@ func (r flyAppResource) Create(ctx context.Context, req tfsdk.CreateResourceRequ
9298
}
9399

94100
data = flyAppResourceData{
95-
Org: types.String{Value: mresp.CreateApp.App.Organization.Id},
96-
Name: types.String{Value: mresp.CreateApp.App.Name},
101+
Org: types.String{Value: mresp.CreateApp.App.Organization.Slug},
102+
OrgId: types.String{Value: mresp.CreateApp.App.Organization.Id},
103+
Name: types.String{Value: mresp.CreateApp.App.Name},
97104
}
98105

99106
diags = resp.State.Set(ctx, &data)
@@ -127,8 +134,9 @@ func (r flyAppResource) Read(ctx context.Context, req tfsdk.ReadResourceRequest,
127134
}
128135

129136
data = flyAppResourceData{
130-
Name: types.String{Value: query.App.Name},
131-
Org: types.String{Value: query.App.Organization.Id},
137+
Name: types.String{Value: query.App.Name},
138+
Org: types.String{Value: query.App.Organization.Slug},
139+
OrgId: types.String{Value: query.App.Organization.Id},
132140
}
133141

134142
diags = resp.State.Set(ctx, &data)

0 commit comments

Comments
 (0)