diff --git a/examples/provider-install-verification/main.tf b/examples/provider-install-verification/main.tf index ccae2f5..2bc6fc9 100644 --- a/examples/provider-install-verification/main.tf +++ b/examples/provider-install-verification/main.tf @@ -7,7 +7,7 @@ terraform { } provider "ee-platform" { - teams_api = "http://localhost:8080" + platform_api = "localhost:8080" } data "ee-platform_teams" "all_teams" {} diff --git a/internal/client/teams.go b/internal/client/platform.go similarity index 79% rename from internal/client/teams.go rename to internal/client/platform.go index 496880e..aeb7a09 100644 --- a/internal/client/teams.go +++ b/internal/client/platform.go @@ -18,15 +18,15 @@ type Team struct { SnPaasOrg string `json:"snpaas_org"` } -type TeamsClient interface { +type PlatformClient interface { GetTeams() (Teams, error) } -type teamsClient struct { +type platformClient struct { teamsEndpoint string } -func (t teamsClient) GetTeams() (teams Teams, err error) { +func (t platformClient) GetTeams() (teams Teams, err error) { u, err := url.Parse(t.teamsEndpoint) if err != nil { return @@ -52,8 +52,8 @@ func (t teamsClient) GetTeams() (teams Teams, err error) { return } -func NewTeamsClient(teamsEndpoint string) TeamsClient { - return teamsClient{ +func NewPlatformClient(teamsEndpoint string) PlatformClient { + return platformClient{ teamsEndpoint: teamsEndpoint, } } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 9059c41..732ae93 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -43,14 +43,14 @@ func (p *eePlatformProvider) Metadata(_ context.Context, _ provider.MetadataRequ } type EEPlatformProviderModel struct { - TeamsApi types.String `tfsdk:"teams_api"` + TeamsApi types.String `tfsdk:"platform_api"` } func (p *eePlatformProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ MarkdownDescription: "Manage EE Platform resources with terraform", Attributes: map[string]schema.Attribute{ - "teams_api": schema.StringAttribute{ + "platform_api": schema.StringAttribute{ Optional: true, }, }, @@ -59,7 +59,7 @@ func (p *eePlatformProvider) Schema(_ context.Context, _ provider.SchemaRequest, // Configure prepares a EE Platform API client for data sources and resources. func (p *eePlatformProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { - teamsApi := os.Getenv("TEAMS_API") + teamsApi := os.Getenv("PLATFORM_API") var data EEPlatformProviderModel resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) @@ -70,13 +70,13 @@ func (p *eePlatformProvider) Configure(ctx context.Context, req provider.Configu } else { resp.Diagnostics.AddError( "Missing teams API endpoint", - "While configuring the provider, the teams API endpoint was not found in the TEAMS_API environment variable or provider configuration block teams_api attribute.", + "While configuring the provider, the teams API endpoint was not found in the PLATFORM_API environment variable or provider configuration block platform_api attribute.", ) return } } - resp.DataSourceData = client.NewTeamsClient(teamsApi) + resp.DataSourceData = client.NewPlatformClient(teamsApi) } // DataSources defines the data sources implemented in the provider. diff --git a/internal/provider/teams_data_source.go b/internal/provider/teams_data_source.go index c3db671..bb6fe43 100644 --- a/internal/provider/teams_data_source.go +++ b/internal/provider/teams_data_source.go @@ -24,7 +24,7 @@ func NewTeamsDataSource() datasource.DataSource { // teamsDataSource is the data source implementation. type teamsDataSource struct { - teamsClient client.TeamsClient + platformClient client.PlatformClient } // Metadata returns the data source type name. @@ -37,7 +37,7 @@ func (d *teamsDataSource) Configure(ctx context.Context, req datasource.Configur return } - teamsClient, ok := req.ProviderData.(client.TeamsClient) + platformClient, ok := req.ProviderData.(client.PlatformClient) if !ok { resp.Diagnostics.AddError( "Unexpected Data Source Configure Type", @@ -47,7 +47,7 @@ func (d *teamsDataSource) Configure(ctx context.Context, req datasource.Configur return } - d.teamsClient = teamsClient + d.platformClient = platformClient } // Schema defines the schema for the data source. @@ -92,7 +92,7 @@ func (d *teamsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, } func (d *teamsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - teams, err := d.teamsClient.GetTeams() + teams, err := d.platformClient.GetTeams() if err != nil { resp.Diagnostics.AddError("Unable to fetch teams", err.Error()) }