Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress non-functional difference of URI value #850

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func resourceKubernetesAgentDeploymentTarget() *schema.Resource {
Description: "This resource manages Kubernetes agent deployment targets in Octopus Deploy.",
Importer: getImporter(),
ReadContext: resourceKubernetesAgentDeploymentTargetRead,
Schema: getKubernetesAgentDeploymentTargetSchema(),
Schema: getKubernetesAgentDeploymentTargetSchemaForResource(),
UpdateContext: resourceKubernetesAgentDeploymentTargetUpdate,
}
}
Expand Down
28 changes: 21 additions & 7 deletions octopusdeploy/schema_kubernetes_agent_deployment_target.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package octopusdeploy

import (
"net/url"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"net/url"
"strings"
)

func expandKubernetesAgentDeploymentTarget(kubernetesAgent *schema.ResourceData) *machines.DeploymentTarget {
Expand Down Expand Up @@ -75,7 +75,19 @@ func flattenKubernetesAgentDeploymentTarget(deploymentTarget *machines.Deploymen
return flattenedDeploymentTarget
}

func getKubernetesAgentDeploymentTargetSchema() map[string]*schema.Schema {
func getKubernetesAgentDeploymentTargetSchemaForDataSource() map[string]*schema.Schema {
return getKubernetesAgentDeploymentTargetSchema(nil)
}

func getKubernetesAgentDeploymentTargetSchemaForResource() map[string]*schema.Schema {
uriDiffSuppress := func(k, old, new string, d *schema.ResourceData) bool {
return strings.EqualFold(old, new)
}

return getKubernetesAgentDeploymentTargetSchema(uriDiffSuppress)
}

func getKubernetesAgentDeploymentTargetSchema(uriDiffSuppress schema.SchemaDiffSuppressFunc) map[string]*schema.Schema {
return map[string]*schema.Schema{
"id": getIDSchema(),
"space_id": getSpaceIDSchema(),
Expand Down Expand Up @@ -116,9 +128,11 @@ func getKubernetesAgentDeploymentTargetSchema() map[string]*schema.Schema {
Type: schema.TypeString,
},
"uri": {
Description: "The URI of the Kubernetes agent's used by the server to queue messages. This is the same subscription uri that was used when installing the agent.",
Required: true,
Type: schema.TypeString,
Description: "The URI of the Kubernetes agent's used by the server to queue messages. This is the same subscription uri that was used when installing the agent.",
Required: true,
Type: schema.TypeString,
DiffSuppressFunc: uriDiffSuppress,
DiffSuppressOnRefresh: uriDiffSuppress != nil,
},
"default_namespace": {
Description: "Optional default namespace that will be used when using Kubernetes deployment steps, can be overrides within step configurations.",
Expand Down Expand Up @@ -168,7 +182,7 @@ func getKubernetesAgentDeploymentTargetSchema() map[string]*schema.Schema {
}

func getKubernetesAgentDeploymentTargetDataSchema() map[string]*schema.Schema {
dataSchema := getKubernetesAgentDeploymentTargetSchema()
dataSchema := getKubernetesAgentDeploymentTargetSchemaForDataSource()
setDataSchema(&dataSchema)

deploymentTargetDataSchema := getDeploymentTargetDataSchema()
Expand Down
Loading