Skip to content

Commit

Permalink
Isaac/mc schema fixes (#715)
Browse files Browse the repository at this point in the history
* propagate an error

* The collection returned by data sources must not be optional

* Add more optionals

---------

Co-authored-by: Matthew Casperson <matthewcasperson@gmail.com>
  • Loading branch information
IsaacCalligeros95 and mcasperson authored Aug 8, 2024
1 parent 7c81ce9 commit 3a8a027
Show file tree
Hide file tree
Showing 26 changed files with 29 additions and 22 deletions.
5 changes: 4 additions & 1 deletion octopusdeploy/data_source_tenants.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ func dataSourceTenantsRead(ctx context.Context, d *schema.ResourceData, meta int
flattenedTenants = append(flattenedTenants, flattenTenant(tenant))
}

d.Set("tenants", flattenedTenants)
if err := d.Set("tenants", flattenedTenants); err != nil {
return diag.FromErr(err)
}

d.SetId("Tenants " + time.Now().UTC().String())

return nil
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy/schema_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func getAccountResourceDataSchema() map[string]*schema.Schema {
Description: "A list of accounts that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Type: schema.TypeList,
Optional: false,
},
"id": getDataSchemaID(),
"space_id": getQuerySpaceID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func getAzureCloudServiceDeploymentTargetDataSchema() map[string]*schema.Schema
Computed: true,
Description: "A list of Azure cloud service deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func getAzureServiceFabricClusterDeploymentTargetDataSchema() map[string]*schema
Computed: true,
Description: "A list of Azure service fabric cluster deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_azure_web_app_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func getAzureWebAppDeploymentTargetDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of Azure web app deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func getCertificateDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of certificates that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
"first_result": getQueryFirstResult(),
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func getChannelDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A channel that matches the specified filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
"ids": getQueryIDs(),
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_cloud_region_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func getCloudRegionDeploymentTargetDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of cloud region deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func getDeploymentTargetDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
"environments": getQueryEnvironments(),
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_kubernetes_agent_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func getKubernetesAgentDeploymentTargetDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of kubernetes agent deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func getKubernetesClusterDeploymentTargetDataSchema() map[string]*schema.Schema
Computed: true,
Description: "A list of Kubernetes cluster deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func getListeningTentacleDeploymentTargetDataSchema() map[string]*schema.Schema
Computed: true,
Description: "A list of listening tentacle deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_machine_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func getMachinePolicyDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of machine policies that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
"partial_name": getQueryPartialName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func getOfflinePackageDropDeploymentTargetDataSchema() map[string]*schema.Schema
Computed: true,
Description: "A list of offline package drop deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_polling_tentacle_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func getPollingTentacleDeploymentTargetDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of polling tentacle deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_script_modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func getScriptModuleDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of script modules that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
"partial_name": getQueryPartialName(),
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_ssh_connection_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func getSSHConnectionDeploymentTargetDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of SSH connection deployment targets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
}

Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_tag_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func getTagSetDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of tag sets that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
"take": getQueryTake(),
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func getTeamDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of teams that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
}
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func getTenantDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of tenants that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
"take": getQueryTake(),
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func getUserDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of users that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
}
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_user_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func getUserRoleDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of user roles that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
}
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func getWorkerPoolDataSchema() map[string]*schema.Schema {
Computed: true,
Description: "A list of worker pools that match the filter(s).",
Elem: &schema.Resource{Schema: dataSchema},
Optional: true,
Optional: false,
Type: schema.TypeList,
},
}
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy_framework/schemas/gitCredential.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func GetGitCredentialDataSourceSchema() map[string]datasourceSchema.Attribute {
"take": util.GetQueryTakeDatasourceSchema(),
"git_credentials": datasourceSchema.ListNestedAttribute{
Computed: true,
Optional: false,
Description: "A list of Git Credentials that match the filter(s).",
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: GetGitCredentialAttributes(),
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy_framework/schemas/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func GetDatasourceLifecycleSchema() datasourceSchema.Schema {
"take": util.GetQueryTakeDatasourceSchema(),
"lifecycles": datasourceSchema.ListNestedAttribute{
Computed: true,
Optional: false,
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: map[string]datasourceSchema.Attribute{
"id": util.GetIdDatasourceSchema(),
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy_framework/schemas/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func getProjectsDataSourceAttribute() datasourceSchema.ListNestedAttribute {
return datasourceSchema.ListNestedAttribute{
Description: "A list of projects that match the filter(s).",
Computed: true,
Optional: false,
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: map[string]datasourceSchema.Attribute{
"allow_deployments_to_no_targets": util.DataSourceBool().Computed().Deprecated("Allow deployments to be created when there are no targets.").Build(),
Expand Down

0 comments on commit 3a8a027

Please sign in to comment.