<commit_before>// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
// Licensed under the Mozilla Public License v2.0

package oci

import (
	"fmt"
	"strconv"
	"testing"

	"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
	"github.com/hashicorp/terraform-plugin-sdk/terraform"

	"github.com/terraform-providers/terraform-provider-oci/httpreplay"
)

var (
	DevopsSingleStageDeploymentRequiredOnlyResource = DevopsSingleStageDeploymentResourceDependencies +
		generateResourceFromRepresentationMap("oci_devops_deployment", "test_deployment", Required, Create, devopsSingleStageDeploymentRepresentation)

	DevopsSingleStageDeploymentResourceConfig = DevopsSingleStageDeploymentResourceDependencies +
		generateResourceFromRepresentationMap("oci_devops_deployment", "test_deployment", Optional, Update, devopsSingleStageDeploymentRepresentation)

	devopsSingleStageDeploymentSingularDataSourceRepresentation = map[string]interface{}{
		"deployment_id": Representation{repType: Required, create: `${oci_devops_deployment.test_deployment.id}`},
	}

	deployOkeSingleStageRepresentation = map[string]interface{}{
		"deploy_pipeline_id":                      Representation{repType: Required, create: `${oci_devops_deploy_pipeline.test_deploy_pipeline.id}`},
		"deploy_stage_predecessor_collection":     RepresentationGroup{Required, deployStageDeployStagePredecessorCollectionRepresentation},
		"deploy_stage_type":                       Representation{repType: Required, create: `OKE_DEPLOYMENT`},
		"defined_tags":                            Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"description":                             Representation{repType: Optional, create: `description`, update: `description2`},
		"display_name":                            Representation{repType: Optional, create: `displayName`, update: `displayName2`},
		"freeform_tags":                           Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
		"oke_cluster_deploy_environment_id":       Representation{repType: Required, create: `${oci_devops_deploy_environment.test_deploy_kubernetes_environment.id}`},
		"kubernetes_manifest_deploy_artifact_ids": Representation{repType: Required, create: []string{`${oci_devops_deploy_artifact.test_deploy_inline_artifact.id}`}},
		"namespace":                               Representation{repType: Optional, create: `helloworld-demo`},
		"rollback_policy":                         RepresentationGroup{Optional, deployStageRollbackPolicyRepresentation},
	}

	deployOkeEnvironmentRepresentation = map[string]interface{}{
		"deploy_environment_type": Representation{repType: Required, create: `OKE_CLUSTER`},
		"project_id":              Representation{repType: Required, create: `${oci_devops_project.test_project.id}`},
		"cluster_id":              Representation{repType: Required, create: `ocid1.cluster.oc1.phx.aaaaaaaaqu6xnflkdfghjvcp3dw7qwliqygtfmdw3yvbapudjcwkwfecjxxq`}, // TODO: Need to create via terraform
		"defined_tags":            Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"description":             Representation{repType: Optional, create: `description`, update: `description2`},
		"display_name":            Representation{repType: Optional, create: `displayName`, update: `displayName2`},
		"freeform_tags":           Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
	}

	deployGenericArtifactSingleStageRepresentation = map[string]interface{}{
		"argument_substitution_mode": Representation{repType: Required, create: `NONE`, update: `SUBSTITUTE_PLACEHOLDERS`},
		"deploy_artifact_source":     RepresentationGroup{Required, deployGenericArtifactDeployArtifactSingleStageSourceRepresentation},
		"deploy_artifact_type":       Representation{repType: Required, create: `KUBERNETES_MANIFEST`},
		"project_id":                 Representation{repType: Required, create: `${oci_devops_project.test_project.id}`},
		"defined_tags":               Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"description":                Representation{repType: Optional, create: `description`, update: `description2`},
		"display_name":               Representation{repType: Optional, create: `displayName`, update: `displayName2`},
		"freeform_tags":              Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
	}
	repository_id_single_stage                                         = "ocid1.artifactrepository.oc1.phx.0.amaaaaaansx72maaj7g2xjtiuffscp7jouvkpttxnbjxuxr6q45mt7b5lqfq" // TODO: Need to create via terraform
	deployGenericArtifactDeployArtifactSingleStageSourceRepresentation = map[string]interface{}{
		"deploy_artifact_source_type": Representation{repType: Required, create: `GENERIC_ARTIFACT`},
		"repository_id":               Representation{repType: Required, create: repository_id},
		"deploy_artifact_path":        Representation{repType: Required, create: artifact_path},
		"deploy_artifact_version":     Representation{repType: Required, create: version},
	}

	devopsSingleStageDeploymentDataSourceRepresentation = map[string]interface{}{
		"compartment_id":     Representation{repType: Optional, create: `${var.compartment_id}`},
		"deploy_pipeline_id": Representation{repType: Optional, create: `${oci_devops_deploy_pipeline.test_deploy_pipeline.id}`},
		"display_name":       Representation{repType: Optional, create: `displayName`},
		"id":                 Representation{repType: Optional, create: `${oci_devops_deployment.test_deployment.id}`},
		"project_id":         Representation{repType: Optional, create: `${oci_devops_project.test_project.id}`},
		"state":              Representation{repType: Optional, create: `Active`},
		"filter":             RepresentationGroup{Required, devopsSingleStageDeploymentDataSourceFilterRepresentation}}
	devopsSingleStageDeploymentDataSourceFilterRepresentation = map[string]interface{}{
		"name":   Representation{repType: Required, create: `id`},
		"values": Representation{repType: Required, create: []string{`${oci_devops_deployment.test_deployment.id}`}},
	}

	devopsSingleStageDeploymentRepresentation = map[string]interface{}{
		"deploy_pipeline_id": Representation{repType: Required, create: `${oci_devops_deploy_pipeline.test_deploy_pipeline.id}`},
		"deployment_type":    Representation{repType: Required, create: `SINGLE_STAGE_DEPLOYMENT`},
		"defined_tags":       Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"display_name":       Representation{repType: Optional, create: `displayName`},
		"freeform_tags":      Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
		"deploy_stage_id":    Representation{repType: Required, create: `${oci_devops_deploy_stage.test_deploy_stage.id}`},
		"lifecycle":          RepresentationGroup{Required, ignoreDefinedTagsDifferencesRepresentation},
	}

	deployLogRepresentation = map[string]interface{}{
		"display_name":       Representation{repType: Required, create: `displayName`, update: `displayName2`},
		"log_group_id":       Representation{repType: Required, create: `${oci_logging_log_group.test_log_group.id}`, update: `${oci_logging_log_group.test_update_log_group.id}`},
		"log_type":           Representation{repType: Required, create: `SERVICE`},
		"configuration":      RepresentationGroup{Required, devopLogConfigurationRepresentation},
		"defined_tags":       Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"freeform_tags":      Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
		"is_enabled":         Representation{repType: Optional, create: `true`},
		"retention_duration": Representation{repType: Optional, create: `30`},
		"lifecycle":          RepresentationGroup{Required, ignoreDefinedTagsDifferencesRepresentation},
	}

	ignoreDefinedTagsDifferencesRepresentation = map[string]interface{}{
		"ignore_changes": Representation{repType: Required, create: []string{`defined_tags`}},
	}

	DevopsSingleStageDeploymentResourceDependencies = generateResourceFromRepresentationMap("oci_devops_deploy_artifact", "test_deploy_inline_artifact", Required, Create, deployGenericArtifactSingleStageRepresentation) +<commit_msg>fix conflict variable in devops test<commit_after>// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
// Licensed under the Mozilla Public License v2.0

package oci

import (
	"fmt"
	"strconv"
	"testing"

	"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
	"github.com/hashicorp/terraform-plugin-sdk/terraform"

	"github.com/terraform-providers/terraform-provider-oci/httpreplay"
)

var (
	DevopsSingleStageDeploymentRequiredOnlyResource = DevopsSingleStageDeploymentResourceDependencies +
		generateResourceFromRepresentationMap("oci_devops_deployment", "test_deployment", Required, Create, devopsSingleStageDeploymentRepresentation)

	DevopsSingleStageDeploymentResourceConfig = DevopsSingleStageDeploymentResourceDependencies +
		generateResourceFromRepresentationMap("oci_devops_deployment", "test_deployment", Optional, Update, devopsSingleStageDeploymentRepresentation)

	devopsSingleStageDeploymentSingularDataSourceRepresentation = map[string]interface{}{
		"deployment_id": Representation{repType: Required, create: `${oci_devops_deployment.test_deployment.id}`},
	}

	deployOkeSingleStageRepresentation = map[string]interface{}{
		"deploy_pipeline_id":                      Representation{repType: Required, create: `${oci_devops_deploy_pipeline.test_deploy_pipeline.id}`},
		"deploy_stage_predecessor_collection":     RepresentationGroup{Required, deployStageDeployStagePredecessorCollectionRepresentation},
		"deploy_stage_type":                       Representation{repType: Required, create: `OKE_DEPLOYMENT`},
		"defined_tags":                            Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"description":                             Representation{repType: Optional, create: `description`, update: `description2`},
		"display_name":                            Representation{repType: Optional, create: `displayName`, update: `displayName2`},
		"freeform_tags":                           Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
		"oke_cluster_deploy_environment_id":       Representation{repType: Required, create: `${oci_devops_deploy_environment.test_deploy_kubernetes_environment.id}`},
		"kubernetes_manifest_deploy_artifact_ids": Representation{repType: Required, create: []string{`${oci_devops_deploy_artifact.test_deploy_inline_artifact.id}`}},
		"namespace":                               Representation{repType: Optional, create: `helloworld-demo`},
		"rollback_policy":                         RepresentationGroup{Optional, deployStageRollbackPolicyRepresentation},
	}

	deployOkeEnvironmentRepresentation = map[string]interface{}{
		"deploy_environment_type": Representation{repType: Required, create: `OKE_CLUSTER`},
		"project_id":              Representation{repType: Required, create: `${oci_devops_project.test_project.id}`},
		"cluster_id":              Representation{repType: Required, create: `ocid1.cluster.oc1.phx.aaaaaaaaqu6xnflkdfghjvcp3dw7qwliqygtfmdw3yvbapudjcwkwfecjxxq`}, // TODO: Need to create via terraform
		"defined_tags":            Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"description":             Representation{repType: Optional, create: `description`, update: `description2`},
		"display_name":            Representation{repType: Optional, create: `displayName`, update: `displayName2`},
		"freeform_tags":           Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
	}

	deployGenericArtifactSingleStageRepresentation = map[string]interface{}{
		"argument_substitution_mode": Representation{repType: Required, create: `NONE`, update: `SUBSTITUTE_PLACEHOLDERS`},
		"deploy_artifact_source":     RepresentationGroup{Required, deployGenericArtifactDeployArtifactSingleStageSourceRepresentation},
		"deploy_artifact_type":       Representation{repType: Required, create: `KUBERNETES_MANIFEST`},
		"project_id":                 Representation{repType: Required, create: `${oci_devops_project.test_project.id}`},
		"defined_tags":               Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"description":                Representation{repType: Optional, create: `description`, update: `description2`},
		"display_name":               Representation{repType: Optional, create: `displayName`, update: `displayName2`},
		"freeform_tags":              Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
	}
	repository_id_single_stage                                         = "ocid1.artifactrepository.oc1.phx.0.amaaaaaansx72maaj7g2xjtiuffscp7jouvkpttxnbjxuxr6q45mt7b5lqfq" // TODO: Need to create via terraform
	deployGenericArtifactDeployArtifactSingleStageSourceRepresentation = map[string]interface{}{
		"deploy_artifact_source_type": Representation{repType: Required, create: `GENERIC_ARTIFACT`},
		"repository_id":               Representation{repType: Required, create: repository_id},
		"deploy_artifact_path":        Representation{repType: Required, create: artifact_path},
		"deploy_artifact_version":     Representation{repType: Required, create: version},
	}

	devopsSingleStageDeploymentDataSourceRepresentation = map[string]interface{}{
		"compartment_id":     Representation{repType: Optional, create: `${var.compartment_id}`},
		"deploy_pipeline_id": Representation{repType: Optional, create: `${oci_devops_deploy_pipeline.test_deploy_pipeline.id}`},
		"display_name":       Representation{repType: Optional, create: `displayName`},
		"id":                 Representation{repType: Optional, create: `${oci_devops_deployment.test_deployment.id}`},
		"project_id":         Representation{repType: Optional, create: `${oci_devops_project.test_project.id}`},
		"state":              Representation{repType: Optional, create: `Active`},
		"filter":             RepresentationGroup{Required, devopsSingleStageDeploymentDataSourceFilterRepresentation}}
	devopsSingleStageDeploymentDataSourceFilterRepresentation = map[string]interface{}{
		"name":   Representation{repType: Required, create: `id`},
		"values": Representation{repType: Required, create: []string{`${oci_devops_deployment.test_deployment.id}`}},
	}

	devopsSingleStageDeploymentRepresentation = map[string]interface{}{
		"deploy_pipeline_id": Representation{repType: Required, create: `${oci_devops_deploy_pipeline.test_deploy_pipeline.id}`},
		"deployment_type":    Representation{repType: Required, create: `SINGLE_STAGE_DEPLOYMENT`},
		"defined_tags":       Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"display_name":       Representation{repType: Optional, create: `displayName`},
		"freeform_tags":      Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
		"deploy_stage_id":    Representation{repType: Required, create: `${oci_devops_deploy_stage.test_deploy_stage.id}`},
		"lifecycle":          RepresentationGroup{Required, ignoreDefinedTagsDifferencesRepresentation},
	}

	deployLogRepresentation = map[string]interface{}{
		"display_name":       Representation{repType: Required, create: `displayName`, update: `displayName2`},
		"log_group_id":       Representation{repType: Required, create: `${oci_logging_log_group.test_log_group.id}`, update: `${oci_logging_log_group.test_update_log_group.id}`},
		"log_type":           Representation{repType: Required, create: `SERVICE`},
		"configuration":      RepresentationGroup{Required, devopLogConfigurationRepresentation},
		"defined_tags":       Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"freeform_tags":      Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
		"is_enabled":         Representation{repType: Optional, create: `true`},
		"retention_duration": Representation{repType: Optional, create: `30`},
		"lifecycle":          RepresentationGroup{Required, ignoreDefinedTagsDifferencesRepresentation},
	}

	DevopsSingleStageDeploymentResourceDependencies = generateResourceFromRepresentationMap("oci_devops_deploy_artifact", "test_deploy_inline_artifact", Required, Create, deployGenericArtifactSingleStageRepresentation) +
{'fraction_non_alphanumeric': 0.1278885723330168, 'fraction_numerical': 0.006120080194154268, 'mean_word_length': 6.201747720364741, 'pattern_counts': {'":': 133, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3005816', 'n_tokens_mistral': 5718, 'n_tokens_neox': 5528, 'n_words': 822}