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

Expose shared IPv4 address through app data source #231

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/data-sources/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ data "fly_app" "example" {
- `hostname` (String)
- `id` (String) The ID of this resource.
- `ipaddresses` (List of String)
- `sharedipaddress` (String)
- `status` (String)
36 changes: 22 additions & 14 deletions graphql/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions graphql/genqlient.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ query GetFullApp($name: String) {
status
}
}
sharedIpAddress
ipAddresses {
nodes {
address
Expand Down
1 change: 1 addition & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ type App implements Node {
# Returns the last _n_ elements from the list.
last: Int
): IPAddressConnection!
sharedIpAddress: String

# This object's unique key
key: String!
Expand Down
37 changes: 21 additions & 16 deletions internal/provider/app_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ func (d *appDataSourceType) Configure(_ context.Context, req datasource.Configur
}

type appDataSourceOutput struct {
Name types.String `tfsdk:"name"`
AppUrl types.String `tfsdk:"appurl"`
Hostname types.String `tfsdk:"hostname"`
Id types.String `tfsdk:"id"`
Status types.String `tfsdk:"status"`
Deployed types.Bool `tfsdk:"deployed"`
Healthchecks []string `tfsdk:"healthchecks"`
Ipaddresses []string `tfsdk:"ipaddresses"`
Currentrelease types.String `tfsdk:"currentrelease"`
Name types.String `tfsdk:"name"`
AppUrl types.String `tfsdk:"appurl"`
Hostname types.String `tfsdk:"hostname"`
Id types.String `tfsdk:"id"`
Status types.String `tfsdk:"status"`
Deployed types.Bool `tfsdk:"deployed"`
Healthchecks []string `tfsdk:"healthchecks"`
Ipaddresses []string `tfsdk:"ipaddresses"`
Sharedipaddress types.String `tfsdk:"sharedipaddress"`
Currentrelease types.String `tfsdk:"currentrelease"`
}

func (d *appDataSourceType) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
Expand Down Expand Up @@ -81,6 +82,9 @@ func (d *appDataSourceType) Schema(_ context.Context, _ datasource.SchemaRequest
Computed: true,
ElementType: types.StringType,
},
"sharedipaddress": schema.StringAttribute{
Computed: true,
},
"currentrelease": schema.StringAttribute{
Computed: true,
},
Expand All @@ -107,13 +111,14 @@ func (d *appDataSourceType) Read(ctx context.Context, req datasource.ReadRequest
}

a := appDataSourceOutput{
Name: data.Name,
AppUrl: types.StringValue(queryresp.App.AppUrl),
Hostname: types.StringValue(queryresp.App.Hostname),
Id: types.StringValue(queryresp.App.Id),
Status: types.StringValue(queryresp.App.Status),
Deployed: types.BoolValue(queryresp.App.Deployed),
Currentrelease: types.StringValue(queryresp.App.CurrentRelease.Id),
Name: data.Name,
AppUrl: types.StringValue(queryresp.App.AppUrl),
Hostname: types.StringValue(queryresp.App.Hostname),
Id: types.StringValue(queryresp.App.Id),
Status: types.StringValue(queryresp.App.Status),
Deployed: types.BoolValue(queryresp.App.Deployed),
Sharedipaddress: types.StringValue(queryresp.App.SharedIpAddress),
Currentrelease: types.StringValue(queryresp.App.CurrentRelease.Id),
}

for _, s := range queryresp.App.HealthChecks.Nodes {
Expand Down