Skip to content

Commit

Permalink
chore!: align config in both providers (#694)
Browse files Browse the repository at this point in the history
* aligned provider config

* prefer utility over custom for typename
  • Loading branch information
benPearce1 authored Jul 29, 2024
1 parent e4f0093 commit a861ac5
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions octopusdeploy/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ func Provider() *schema.Provider {
"address": {
DefaultFunc: schema.EnvDefaultFunc("OCTOPUS_URL", nil),
Description: "The endpoint of the Octopus REST API",
Required: true,
Optional: true,
Type: schema.TypeString,
},
"api_key": {
DefaultFunc: schema.EnvDefaultFunc("OCTOPUS_APIKEY", nil),
Description: "The API key to use with the Octopus REST API",
Required: true,
Optional: true,
Type: schema.TypeString,
},
"space_id": {
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/datasource_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewEnvironmentsDataSource() datasource.DataSource {
}

func (*environmentDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_environments"
resp.TypeName = util.GetTypeName("environments")
}

func (*environmentDataSource) Schema(_ context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/datasource_feeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewFeedsDataSource() datasource.DataSource {
}

func (*feedsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_feeds"
resp.TypeName = util.GetTypeName("feeds")
}

func (e *feedsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/datasource_project_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func getNestedGroupAttributes() map[string]attr.Type {
}

func (p *projectGroupsDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_project_groups"
resp.TypeName = util.GetTypeName("project_groups")
}

func (p *projectGroupsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
Expand Down
5 changes: 1 addition & 4 deletions octopusdeploy_framework/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type octopusDeployFrameworkProvider struct {
var _ provider.Provider = (*octopusDeployFrameworkProvider)(nil)
var _ provider.ProviderWithMetaSchema = (*octopusDeployFrameworkProvider)(nil)
var _ provider.ProviderWithFunctions
var ProviderTypeName = "octopusdeploy"

func NewOctopusDeployFrameworkProvider() *octopusDeployFrameworkProvider {
return &octopusDeployFrameworkProvider{}
Expand Down Expand Up @@ -87,16 +86,14 @@ func (p *octopusDeployFrameworkProvider) Resources(ctx context.Context) []func()
}
}

func (p *octopusDeployFrameworkProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) {
func (p *octopusDeployFrameworkProvider) Schema(_ context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"address": schema.StringAttribute{
//Required: true,
Optional: true,
Description: "The endpoint of the Octopus REST API",
},
"api_key": schema.StringAttribute{
//Required: true,
Optional: true,
Description: "The API key to use with the Octopus REST API",
},
Expand Down
3 changes: 2 additions & 1 deletion octopusdeploy_framework/resource_artifactory_generic_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand All @@ -23,7 +24,7 @@ func NewArtifactoryGenericFeedResource() resource.Resource {
}

func (r *artifactoryGenericFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_artifactory_generic_feed"
resp.TypeName = util.GetTypeName("artifactory_generic_feed")
}

func (r *artifactoryGenericFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand All @@ -22,7 +23,7 @@ func NewAwsElasticContainerRegistryFeedResource() resource.Resource {
}

func (r *awsElasticContainerRegistryFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_aws_elastic_container_registry"
resp.TypeName = util.GetTypeName("aws_elastic_container_registry")
}

func (r *awsElasticContainerRegistryFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewEnvironmentResource() resource.Resource {
}

func (r *environmentTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_environment"
resp.TypeName = util.GetTypeName("environment")
}

func (r *environmentTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down
3 changes: 2 additions & 1 deletion octopusdeploy_framework/resource_github_repository_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand All @@ -22,7 +23,7 @@ func NewGitHubRepositoryFeedResource() resource.Resource {
}

func (r *githubRepositoryFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_github_repository_feed"
resp.TypeName = util.GetTypeName("github_repository_feed")
}

func (r *githubRepositoryFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down
3 changes: 2 additions & 1 deletion octopusdeploy_framework/resource_helm_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand All @@ -23,7 +24,7 @@ func NewHelmFeedResource() resource.Resource {
}

func (r *helmFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_helm_feed"
resp.TypeName = util.GetTypeName("helm_feed")
}

func (r *helmFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down
3 changes: 2 additions & 1 deletion octopusdeploy_framework/resource_maven_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand All @@ -22,7 +23,7 @@ func NewMavenFeedResource() resource.Resource {
}

func (r *mavenFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_maven_feed"
resp.TypeName = util.GetTypeName("maven_feed")
}

func (r *mavenFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down
3 changes: 2 additions & 1 deletion octopusdeploy_framework/resource_nuget_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand All @@ -22,7 +23,7 @@ func NewNugetFeedResource() resource.Resource {
}

func (r *nugetFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_nuget_feed"
resp.TypeName = util.GetTypeName("nuget_feed")
}

func (r *nugetFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down
3 changes: 2 additions & 1 deletion octopusdeploy_framework/resource_project_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projectgroups"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand All @@ -20,7 +21,7 @@ func NewProjectGroupResource() resource.Resource {
}

func (r *projectGroupTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = ProviderTypeName + "_project_group"
resp.TypeName = util.GetTypeName("project_group")
}

func (r *projectGroupTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
Expand Down

0 comments on commit a861ac5

Please sign in to comment.