Skip to content

Commit

Permalink
more refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
HuyPhanNguyen committed Jul 29, 2024
1 parent 86fe5c0 commit 75ca37e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions octopusdeploy_framework/schemas/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ func getOptionalComputedStringAttribute() resourceSchema.StringAttribute {
}

func getOptionalComputedBoolAttribute(description string) resourceSchema.BoolAttribute {
attr := resourceSchema.BoolAttribute{
attribute := resourceSchema.BoolAttribute{
Optional: true,
Computed: true,
}
if description != "" {
attr.Description = description
attribute.Description = description
}
return attr
return attribute
}

func getOptionalStringAttribute(description string) resourceSchema.StringAttribute {
Expand Down Expand Up @@ -57,6 +57,14 @@ func getResourceOptionalStringListAttribute(description string) resourceSchema.L
return attr
}

func getResourceOptionalStringSetAttribute(description string) resourceSchema.SetAttribute {
return resourceSchema.SetAttribute{
Description: description,
ElementType: types.StringType,
Optional: true,
}
}

func GetProjectResourceSchema() resourceSchema.Schema {
return resourceSchema.Schema{
Description: "This resource manages projects in Octopus Deploy.",
Expand Down Expand Up @@ -109,7 +117,7 @@ func GetProjectResourceSchema() resourceSchema.Schema {
"url": getOptionalStringAttribute("The URL associated with these version control settings."),
"base_path": getOptionalStringAttribute("The base path associated with these version control settings."),
"default_branch": getOptionalStringAttribute("The default branch associated with these version control settings."),
"protected_branches": getResourceOptionalStringListAttribute("A list of protected branch patterns."),
"protected_branches": getResourceOptionalStringSetAttribute("A list of protected branch patterns."),
},
},
Description: "Provides Git-related persistence settings for a version-controlled project.",
Expand All @@ -121,7 +129,7 @@ func GetProjectResourceSchema() resourceSchema.Schema {
"url": getOptionalStringAttribute("The URL associated with these version control settings."),
"base_path": getOptionalStringAttribute("The base path associated with these version control settings."),
"default_branch": getOptionalStringAttribute("The default branch associated with these version control settings."),
"protected_branches": getResourceOptionalStringListAttribute("A list of protected branch patterns."),
"protected_branches": getResourceOptionalStringSetAttribute("A list of protected branch patterns."),
},
},
Description: "Provides Git-related persistence settings for a version-controlled project.",
Expand All @@ -134,7 +142,7 @@ func GetProjectResourceSchema() resourceSchema.Schema {
"password": util.GetPasswordResourceSchema(false),
"base_path": getOptionalStringAttribute("The base path associated with these version control settings."),
"default_branch": getOptionalStringAttribute("The default branch associated with these version control settings."),
"protected_branches": getResourceOptionalStringListAttribute("A list of protected branch patterns."),
"protected_branches": getResourceOptionalStringSetAttribute("A list of protected branch patterns."),
},
},
Description: "Provides Git-related persistence settings for a version-controlled project.",
Expand Down

0 comments on commit 75ca37e

Please sign in to comment.