@@ -20,18 +20,21 @@ import (
2020
2121var (
2222 DeployHelmArtifactRequiredOnlyResource = DevopsDeployArtifactResourceDependencies +
23- acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Required , acctest .Create , deployHelmArtifactRepresentation )
23+ acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Required , acctest .Create , deployHelmChartArtifactRepresentation )
2424
2525 DeployHelmArtifactResourceConfig = DevopsDeployArtifactResourceDependencies +
26- acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Update , deployHelmArtifactRepresentation )
26+ acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Update , deployHelmChartArtifactRepresentation )
27+
28+ DeployHelmCommandSpecArtifactResourceConfig = DevopsDeployArtifactResourceDependencies +
29+ acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Required , acctest .Create , deployHelmCommandSpecArtifactRepresentation )
2730
2831 deployHelmArtifactSingularDataSourceRepresentation = map [string ]interface {}{
2932 "deploy_artifact_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_devops_deploy_artifact.test_deploy_artifact.id}` },
3033 }
3134
32- deployHelmArtifactRepresentation = map [string ]interface {}{
35+ deployHelmChartArtifactRepresentation = map [string ]interface {}{
3336 "argument_substitution_mode" : acctest.Representation {RepType : acctest .Required , Create : `NONE` , Update : `SUBSTITUTE_PLACEHOLDERS` },
34- "deploy_artifact_source" : acctest.RepresentationGroup {RepType : acctest .Required , Group : deployHelmArtifactDeployArtifactSourceRepresentation },
37+ "deploy_artifact_source" : acctest.RepresentationGroup {RepType : acctest .Required , Group : deployHelmChartArtifactDeployArtifactSourceRepresentation },
3538 "deploy_artifact_type" : acctest.Representation {RepType : acctest .Required , Create : `HELM_CHART` },
3639 "project_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_devops_project.test_project.id}` },
3740 "defined_tags" : acctest.Representation {RepType : acctest .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")}` },
@@ -41,10 +44,29 @@ var (
4144 "lifecycle" : acctest.RepresentationGroup {RepType : acctest .Required , Group : ignoreDefinedTagsDifferencesRepresentation },
4245 }
4346
44- deployHelmArtifactDeployArtifactSourceRepresentation = map [string ]interface {}{
47+ deployHelmChartArtifactDeployArtifactSourceRepresentation = map [string ]interface {}{
4548 "deploy_artifact_source_type" : acctest.Representation {RepType : acctest .Required , Create : `HELM_CHART` },
46- "chart_url" : acctest.Representation {RepType : acctest .Required , Create : utils .GetEnvSettingWithBlankDefault ("helm_chart_url_static_resource" ), Update : utils .GetEnvSettingWithBlankDefault ("helm_chart_url_update_static_resource" )},
47- "deploy_artifact_version" : acctest.Representation {RepType : acctest .Required , Create : utils .GetEnvSettingWithBlankDefault ("helm_deploy_artifact_version_static_resource" ), Update : utils .GetEnvSettingWithBlankDefault ("helm_deploy_artifact_version_update_static_resource" )},
49+ "chart_url" : acctest.Representation {RepType : acctest .Required , Create : utils .GetEnvSettingWithDefault ("helm_chart_url_static_resource" , "oci://us-ashburn-1.ocir.io/idkxrdu9epyt/helm-test-chart" ), Update : utils .GetEnvSettingWithDefault ("helm_chart_url_update_static_resource" , "oci://iad.ocir.io/ax022wvgmjpq/helm-charts-testing/helm-chart-nginx" )},
50+ "deploy_artifact_version" : acctest.Representation {RepType : acctest .Required , Create : utils .GetEnvSettingWithDefault ("helm_deploy_artifact_version_static_resource" , "0.0.1" ), Update : utils .GetEnvSettingWithDefault ("helm_deploy_artifact_version_update_static_resource" , "1.0.6" )},
51+ }
52+
53+ deployHelmCommandSpecArtifactRepresentation = map [string ]interface {}{
54+ "argument_substitution_mode" : acctest.Representation {RepType : acctest .Required , Create : `NONE` , Update : `SUBSTITUTE_PLACEHOLDERS` },
55+ "deploy_artifact_source" : acctest.RepresentationGroup {RepType : acctest .Required , Group : deployHelmCommandSpecArtifactDeployArtifactSourceRepresentation },
56+ "deploy_artifact_type" : acctest.Representation {RepType : acctest .Required , Create : `HELM_COMMAND_SPEC` },
57+ "project_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_devops_project.test_project.id}` },
58+ "defined_tags" : acctest.Representation {RepType : acctest .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")}` },
59+ "description" : acctest.Representation {RepType : acctest .Optional , Create : `description` , Update : `description2` },
60+ "display_name" : acctest.Representation {RepType : acctest .Optional , Create : `displayName` , Update : `displayName2` },
61+ "freeform_tags" : acctest.Representation {RepType : acctest .Optional , Create : map [string ]string {"bar-key" : "value" }, Update : map [string ]string {"Department" : "Accounting" }},
62+ "lifecycle" : acctest.RepresentationGroup {RepType : acctest .Required , Group : ignoreDefinedTagsDifferencesRepresentation },
63+ }
64+
65+ base64EncodeHelmCommandSpec = "aGVsbSBscyAtYQpoZWxtIHN0YXR1cyAtYQ=="
66+ deployHelmCommandSpecArtifactDeployArtifactSourceRepresentation = map [string ]interface {}{
67+ "deploy_artifact_source_type" : acctest.Representation {RepType : acctest .Required , Create : `INLINE` },
68+ "helm_artifact_source_type" : acctest.Representation {RepType : acctest .Required , Create : `INLINE` },
69+ "base64encoded_content" : acctest.Representation {RepType : acctest .Required , Create : base64EncodeHelmCommandSpec },
4870 }
4971)
5072
@@ -56,10 +78,10 @@ func TestDevopsDeployArtifactResource_helm(t *testing.T) {
5678 config := acctest .ProviderTestConfig ()
5779
5880 compartmentId := utils .GetEnvSettingWithBlankDefault ("compartment_ocid" )
59- chartUrl := utils .GetEnvSettingWithBlankDefault ("helm_chart_url_static_resource" )
60- artifactVersion := utils .GetEnvSettingWithBlankDefault ("helm_deploy_artifact_version_static_resource" )
61- chartUrlUpdated := utils .GetEnvSettingWithBlankDefault ("helm_chart_url_update_static_resource" )
62- artifactVersionUpdated := utils .GetEnvSettingWithBlankDefault ("helm_deploy_artifact_version_update_static_resource" )
81+ chartUrl := utils .GetEnvSettingWithDefault ("helm_chart_url_static_resource" , "oci://us-ashburn-1.ocir.io/idkxrdu9epyt/helm-test-chart " )
82+ artifactVersion := utils .GetEnvSettingWithDefault ("helm_deploy_artifact_version_static_resource" , "0.0.1 " )
83+ chartUrlUpdated := utils .GetEnvSettingWithDefault ("helm_chart_url_update_static_resource" , "oci://iad.ocir.io/ax022wvgmjpq/helm-charts-testing/helm-chart-nginx " )
84+ artifactVersionUpdated := utils .GetEnvSettingWithDefault ("helm_deploy_artifact_version_update_static_resource" , "1.0.6 " )
6385
6486 compartmentIdVariableStr := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId )
6587
@@ -70,13 +92,39 @@ func TestDevopsDeployArtifactResource_helm(t *testing.T) {
7092 var resId , resId2 string
7193 // Save TF content to Create resource with optional properties. This has to be exactly the same as the config part in the "Create with optionals" step in the test.
7294 acctest .SaveConfigContent (config + compartmentIdVariableStr + DevopsDeployArtifactResourceDependencies +
73- acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Create , deployHelmArtifactRepresentation ), "devops" , "deployArtifact" , t )
95+ acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Create , deployHelmChartArtifactRepresentation ), "devops" , "deployArtifact" , t )
7496
7597 acctest .ResourceTest (t , testAccCheckDevopsDeployArtifactDestroy , []resource.TestStep {
76- // verify Create
98+ /*
99+ // verify Create (Helm command Spec)
100+ {
101+ Config: config + compartmentIdVariableStr + DevopsDeployArtifactResourceDependencies +
102+ acctest.GenerateResourceFromRepresentationMap("oci_devops_deploy_artifact", "test_deploy_artifact", acctest.Required, acctest.Create, deployHelmCommandSpecArtifactRepresentation),
103+ Check: acctest.ComposeAggregateTestCheckFuncWrapper(
104+ resource.TestCheckResourceAttrSet(resourceName, "id"),
105+ resource.TestCheckResourceAttr(resourceName, "argument_substitution_mode", "NONE"),
106+ resource.TestCheckResourceAttr(resourceName, "deploy_artifact_source.#", "1"),
107+ resource.TestCheckResourceAttr(resourceName, "deploy_artifact_source.0.base64encoded_content", base64EncodeHelmCommandSpec),
108+ resource.TestCheckResourceAttr(resourceName, "deploy_artifact_source.0.deploy_artifact_source_type", "HELM_COMMAND_SPEC"),
109+ resource.TestCheckResourceAttr(resourceName, "deploy_artifact_source.0.helm_artifact_source_type", "INLINE"),
110+ resource.TestCheckResourceAttr(resourceName, "deploy_artifact_type", "HELM_COMMAND_SPEC"),
111+ resource.TestCheckResourceAttrSet(resourceName, "project_id"),
112+
113+ func(s *terraform.State) (err error) {
114+ resId, err = acctest.FromInstanceState(s, resourceName, "id")
115+ return err
116+ },
117+ ),
118+ },
119+ // delete before next Create
120+ {
121+ Config: config + compartmentIdVariableStr + DevopsDeployArtifactResourceDependencies,
122+ },
123+ */
124+ // verify Create (Helm Chart)
77125 {
78126 Config : config + compartmentIdVariableStr + DevopsDeployArtifactResourceDependencies +
79- acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Required , acctest .Create , deployHelmArtifactRepresentation ),
127+ acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Required , acctest .Create , deployHelmChartArtifactRepresentation ),
80128 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
81129 resource .TestCheckResourceAttrSet (resourceName , "id" ),
82130 resource .TestCheckResourceAttr (resourceName , "argument_substitution_mode" , "NONE" ),
@@ -101,7 +149,7 @@ func TestDevopsDeployArtifactResource_helm(t *testing.T) {
101149 // verify Create with optionals
102150 {
103151 Config : config + compartmentIdVariableStr + DevopsDeployArtifactResourceDependencies +
104- acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Create , deployHelmArtifactRepresentation ),
152+ acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Create , deployHelmChartArtifactRepresentation ),
105153 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
106154 resource .TestCheckResourceAttr (resourceName , "argument_substitution_mode" , "NONE" ),
107155 resource .TestCheckResourceAttrSet (resourceName , "compartment_id" ),
@@ -132,7 +180,7 @@ func TestDevopsDeployArtifactResource_helm(t *testing.T) {
132180 // verify updates to updatable parameters
133181 {
134182 Config : config + compartmentIdVariableStr + DevopsDeployArtifactResourceDependencies +
135- acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Update , deployHelmArtifactRepresentation ),
183+ acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Update , deployHelmChartArtifactRepresentation ),
136184 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
137185 resource .TestCheckResourceAttr (resourceName , "argument_substitution_mode" , "SUBSTITUTE_PLACEHOLDERS" ),
138186 resource .TestCheckResourceAttrSet (resourceName , "compartment_id" ),
@@ -162,7 +210,7 @@ func TestDevopsDeployArtifactResource_helm(t *testing.T) {
162210 Config : config +
163211 acctest .GenerateDataSourceFromRepresentationMap ("oci_devops_deploy_artifacts" , "test_deploy_artifacts" , acctest .Optional , acctest .Update , DevopsDevopsDeployArtifactDataSourceRepresentation ) +
164212 compartmentIdVariableStr + DevopsDeployArtifactResourceDependencies +
165- acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Update , deployHelmArtifactRepresentation ),
213+ acctest .GenerateResourceFromRepresentationMap ("oci_devops_deploy_artifact" , "test_deploy_artifact" , acctest .Optional , acctest .Update , deployHelmChartArtifactRepresentation ),
166214 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
167215 resource .TestCheckResourceAttr (datasourceName , "compartment_id" , compartmentId ),
168216 resource .TestCheckResourceAttrSet (datasourceName , "display_name" ),
0 commit comments