Skip to content

Commit

Permalink
chore: updated documentation and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Dec 5, 2022
1 parent a112a99 commit b6fd340
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 40 deletions.
80 changes: 40 additions & 40 deletions internal/environments/extension_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

// ExpandJiraExtensionSettings deserializes the extension settings for Jira integration from its HCL representation.
// ExpandJiraExtensionSettings deserializes the environment extension settings for Jira integration from its HCL representation.
func ExpandJiraExtensionSettings(extensionSettings interface{}) extensions.ExtensionSettings {
values := extensionSettings.([]interface{})
valuesMap := values[0].(map[string]interface{})
Expand All @@ -18,7 +18,7 @@ func ExpandJiraExtensionSettings(extensionSettings interface{}) extensions.Exten
)
}

// ExpandJiraExtensionSettings deserializes the extension settings for Jira Service Management (JSM) integration from its HCL representation.
// ExpandJiraExtensionSettings deserializes the environment extension settings for Jira Service Management (JSM) integration from its HCL representation.
func ExpandJiraServiceManagementExtensionSettings(extensionSettings interface{}) extensions.ExtensionSettings {
values := extensionSettings.([]interface{})
valuesMap := values[0].(map[string]interface{})
Expand All @@ -27,7 +27,7 @@ func ExpandJiraServiceManagementExtensionSettings(extensionSettings interface{})
)
}

// ExpandJiraExtensionSettings deserializes the extension settings for ServiceNow integration from its HCL representation.
// ExpandJiraExtensionSettings deserializes the environment extension settings for ServiceNow integration from its HCL representation.
func ExpandServiceNowExtensionSettings(extensionSettings interface{}) extensions.ExtensionSettings {
values := extensionSettings.([]interface{})
valuesMap := values[0].(map[string]interface{})
Expand All @@ -36,7 +36,40 @@ func ExpandServiceNowExtensionSettings(extensionSettings interface{}) extensions
)
}

// GetJiraExtensionSettingsSchema returns the Terraform schema for Jira integration.
// ExpandJiraExtensionSettings serializes the environment extension settings for Jira integration into its HCL representation.
func FlattenJiraExtensionSettings(jiraExtensionSettings *environments.JiraExtensionSettings) []interface{} {
if jiraExtensionSettings == nil {
return nil
}

flattenedJiraExtensionSettings := make(map[string]interface{})
flattenedJiraExtensionSettings["environment_type"] = jiraExtensionSettings.JiraEnvironmentType
return []interface{}{flattenedJiraExtensionSettings}
}

// FlattenJiraServiceManagementExtensionSettings serializes the environment extension settings for Jira Service Management (JSM) integration into its HCL representation.
func FlattenJiraServiceManagementExtensionSettings(jiraServiceManagementExtensionSettings *environments.JiraServiceManagementExtensionSettings) []interface{} {
if jiraServiceManagementExtensionSettings == nil {
return nil
}

flattenedJiraServiceManagementExtensionSettings := make(map[string]interface{})
flattenedJiraServiceManagementExtensionSettings["is_enabled"] = jiraServiceManagementExtensionSettings.IsChangeControlled()
return []interface{}{flattenedJiraServiceManagementExtensionSettings}
}

// FlattenServiceNowExtensionSettings serializes the environment extension settings for ServiceNow integration into its HCL representation.
func FlattenServiceNowExtensionSettings(serviceNowExtensionSettings *environments.ServiceNowExtensionSettings) []interface{} {
if serviceNowExtensionSettings == nil {
return nil
}

flattenedServiceNowExtensionSettings := make(map[string]interface{})
flattenedServiceNowExtensionSettings["is_enabled"] = serviceNowExtensionSettings.IsChangeControlled()
return []interface{}{flattenedServiceNowExtensionSettings}
}

// GetJiraExtensionSettingsSchema returns the Terraform schema for Jira integration with environments.
func GetJiraExtensionSettingsSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"environment_type": {
Expand All @@ -54,7 +87,7 @@ func GetJiraExtensionSettingsSchema() map[string]*schema.Schema {
}
}

// GetJiraServiceManagementExtensionSettingsSchema returns the Terraform schema for Jira Service Management (JSM) integration.
// GetJiraServiceManagementExtensionSettingsSchema returns the Terraform schema for Jira Service Management (JSM) integration with environments.
func GetJiraServiceManagementExtensionSettingsSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"is_enabled": {
Expand All @@ -65,7 +98,7 @@ func GetJiraServiceManagementExtensionSettingsSchema() map[string]*schema.Schema
}
}

// GetJiraServiceManagementExtensionSettingsSchema returns the Terraform schema for ServiceNow integration.
// GetServiceNowExtensionSettingsSchema returns the Terraform schema for ServiceNow integration with environments.
func GetServiceNowExtensionSettingsSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"is_enabled": {
Expand All @@ -76,7 +109,7 @@ func GetServiceNowExtensionSettingsSchema() map[string]*schema.Schema {
}
}

// SetExtensionSettings sets the Terraform state of a settings collection for extensions.
// SetExtensionSettings sets the Terraform state of environment settings collection for extensions.
func SetExtensionSettings(d *schema.ResourceData, extensionSettingsCollection []extensions.ExtensionSettings) error {
for _, extensionSettings := range extensionSettingsCollection {
switch extensionSettings.ExtensionID() {
Expand All @@ -103,36 +136,3 @@ func SetExtensionSettings(d *schema.ResourceData, extensionSettingsCollection []

return nil
}

// ExpandJiraExtensionSettings serializes the extension settings for Jira integration into its HCL representation.
func FlattenJiraExtensionSettings(jiraExtensionSettings *environments.JiraExtensionSettings) []interface{} {
if jiraExtensionSettings == nil {
return nil
}

flattenedJiraExtensionSettings := make(map[string]interface{})
flattenedJiraExtensionSettings["environment_type"] = jiraExtensionSettings.JiraEnvironmentType
return []interface{}{flattenedJiraExtensionSettings}
}

// FlattenJiraServiceManagementExtensionSettings serializes the extension settings for Jira Service Management (JSM) integration into its HCL representation.
func FlattenJiraServiceManagementExtensionSettings(jiraServiceManagementExtensionSettings *environments.JiraServiceManagementExtensionSettings) []interface{} {
if jiraServiceManagementExtensionSettings == nil {
return nil
}

flattenedJiraServiceManagementExtensionSettings := make(map[string]interface{})
flattenedJiraServiceManagementExtensionSettings["is_enabled"] = jiraServiceManagementExtensionSettings.IsChangeControlled()
return []interface{}{flattenedJiraServiceManagementExtensionSettings}
}

// FlattenServiceNowExtensionSettings serializes the extension settings for ServiceNow integration into its HCL representation.
func FlattenServiceNowExtensionSettings(serviceNowExtensionSettings *environments.ServiceNowExtensionSettings) []interface{} {
if serviceNowExtensionSettings == nil {
return nil
}

flattenedServiceNowExtensionSettings := make(map[string]interface{})
flattenedServiceNowExtensionSettings["is_enabled"] = serviceNowExtensionSettings.IsChangeControlled()
return []interface{}{flattenedServiceNowExtensionSettings}
}
7 changes: 7 additions & 0 deletions internal/projects/extension_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

// ExpandJiraExtensionSettings deserializes the project extension settings for Jira Service Management (JSM) integration from its HCL representation.
func ExpandJiraServiceManagementExtensionSettings(extensionSettings interface{}) extensions.ExtensionSettings {
values := extensionSettings.([]interface{})
valuesMap := values[0].(map[string]interface{})
Expand All @@ -19,6 +20,7 @@ func ExpandJiraServiceManagementExtensionSettings(extensionSettings interface{})
)
}

// ExpandJiraExtensionSettings deserializes the project extension settings for ServiceNow integration from its HCL representation.
func ExpandServiceNowExtensionSettings(extensionSettings interface{}) extensions.ExtensionSettings {
values := extensionSettings.([]interface{})
valuesMap := values[0].(map[string]interface{})
Expand All @@ -30,6 +32,7 @@ func ExpandServiceNowExtensionSettings(extensionSettings interface{}) extensions
)
}

// FlattenJiraServiceManagementExtensionSettings serializes the project extension settings for Jira Service Management (JSM) integration into its HCL representation.
func FlattenJiraServiceManagementExtensionSettings(jiraServiceManagementExtensionSettings *projects.JiraServiceManagementExtensionSettings) []interface{} {
if jiraServiceManagementExtensionSettings == nil {
return nil
Expand All @@ -42,6 +45,7 @@ func FlattenJiraServiceManagementExtensionSettings(jiraServiceManagementExtensio
return []interface{}{flattenedJiraServiceManagementExtensionSettings}
}

// FlattenServiceNowExtensionSettings serializes the project extension settings for ServiceNow integration into its HCL representation.
func FlattenServiceNowExtensionSettings(serviceNowExtensionSettings *projects.ServiceNowExtensionSettings) []interface{} {
if serviceNowExtensionSettings == nil {
return nil
Expand All @@ -55,6 +59,7 @@ func FlattenServiceNowExtensionSettings(serviceNowExtensionSettings *projects.Se
return []interface{}{flattenedServiceNowExtensionSettings}
}

// GetJiraServiceManagementExtensionSettingsSchema returns the Terraform schema for Jira Service Management (JSM) integration with projects.
func GetJiraServiceManagementExtensionSettingsSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"connection_id": {
Expand All @@ -77,6 +82,7 @@ func GetJiraServiceManagementExtensionSettingsSchema() map[string]*schema.Schema
}
}

// GetServiceNowExtensionSettingsSchema returns the Terraform schema for ServiceNow integration with projects.
func GetServiceNowExtensionSettingsSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"connection_id": {
Expand Down Expand Up @@ -104,6 +110,7 @@ func GetServiceNowExtensionSettingsSchema() map[string]*schema.Schema {
}
}

// SetExtensionSettings sets the Terraform state of project settings collection for extensions.
func SetExtensionSettings(d *schema.ResourceData, extensionSettingsCollection []extensions.ExtensionSettings) error {
for _, extensionSettings := range extensionSettingsCollection {
switch extensionSettings.ExtensionID() {
Expand Down

0 comments on commit b6fd340

Please sign in to comment.