@@ -801,71 +801,71 @@ resource "elasticstack_fleet_agent_policy" "test_policy" {
801801}
802802
803803func TestAccResourceAgentPolicyWithRequiredVersions (t * testing.T ) {
804- policyName := sdkacctest .RandStringFromCharSet (22 , sdkacctest .CharSetAlphaNum )
805-
806- resource .Test (t , resource.TestCase {
807- PreCheck : func () { acctest .PreCheck (t ) },
808- CheckDestroy : checkResourceAgentPolicyDestroy ,
809- ProtoV6ProviderFactories : acctest .Providers ,
810- Steps : []resource.TestStep {
811- {
812- SkipFunc : versionutils .CheckIfVersionIsUnsupported (minVersionAgentPolicy ),
813- Config : testAccResourceAgentPolicyCreateWithRequiredVersions (policyName ),
814- Check : resource .ComposeTestCheckFunc (
815- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "name" , fmt .Sprintf ("Policy %s" , policyName )),
816- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "namespace" , "default" ),
817- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.#" , "1" ),
818- resource .TestCheckTypeSetElemNestedAttrs ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.*" , map [string ]string {
819- "version" : "8.15.0" ,
820- "percentage" : "100" ,
821- }),
822- ),
823- },
824- {
825- SkipFunc : versionutils .CheckIfVersionIsUnsupported (minVersionAgentPolicy ),
826- Config : testAccResourceAgentPolicyUpdateRequiredVersionsPercentage (policyName ),
827- Check : resource .ComposeTestCheckFunc (
828- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "name" , fmt .Sprintf ("Policy %s" , policyName )),
829- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "namespace" , "default" ),
830- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.#" , "1" ),
831- resource .TestCheckTypeSetElemNestedAttrs ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.*" , map [string ]string {
832- "version" : "8.15.0" ,
833- "percentage" : "50" ,
834- }),
835- ),
836- },
837- {
838- SkipFunc : versionutils .CheckIfVersionIsUnsupported (minVersionAgentPolicy ),
839- Config : testAccResourceAgentPolicyAddRequiredVersion (policyName ),
840- Check : resource .ComposeTestCheckFunc (
841- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "name" , fmt .Sprintf ("Policy %s" , policyName )),
842- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "namespace" , "default" ),
843- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.#" , "2" ),
844- resource .TestCheckTypeSetElemNestedAttrs ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.*" , map [string ]string {
845- "version" : "8.15.0" ,
846- "percentage" : "50" ,
847- }),
848- resource .TestCheckTypeSetElemNestedAttrs ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.*" , map [string ]string {
849- "version" : "8.16.0" ,
850- "percentage" : "50" ,
851- }),
852- ),
853- },
854- {
855- SkipFunc : versionutils .CheckIfVersionIsUnsupported (minVersionAgentPolicy ),
856- Config : testAccResourceAgentPolicyRemoveRequiredVersions (policyName ),
857- Check : resource .ComposeTestCheckFunc (
858- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "name" , fmt .Sprintf ("Policy %s" , policyName )),
859- resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "namespace" , "default" ),
860- resource .TestCheckNoResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "required_versions" ),
861- ),
862- },
863- },
864- })
804+ policyName := sdkacctest .RandStringFromCharSet (22 , sdkacctest .CharSetAlphaNum )
805+
806+ resource .Test (t , resource.TestCase {
807+ PreCheck : func () { acctest .PreCheck (t ) },
808+ CheckDestroy : checkResourceAgentPolicyDestroy ,
809+ ProtoV6ProviderFactories : acctest .Providers ,
810+ Steps : []resource.TestStep {
811+ {
812+ SkipFunc : versionutils .CheckIfVersionIsUnsupported (minVersionAgentPolicy ),
813+ Config : testAccResourceAgentPolicyCreateWithRequiredVersions (policyName ),
814+ Check : resource .ComposeTestCheckFunc (
815+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "name" , fmt .Sprintf ("Policy %s" , policyName )),
816+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "namespace" , "default" ),
817+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.#" , "1" ),
818+ resource .TestCheckTypeSetElemNestedAttrs ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.*" , map [string ]string {
819+ "version" : "8.15.0" ,
820+ "percentage" : "100" ,
821+ }),
822+ ),
823+ },
824+ {
825+ SkipFunc : versionutils .CheckIfVersionIsUnsupported (minVersionAgentPolicy ),
826+ Config : testAccResourceAgentPolicyUpdateRequiredVersionsPercentage (policyName ),
827+ Check : resource .ComposeTestCheckFunc (
828+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "name" , fmt .Sprintf ("Policy %s" , policyName )),
829+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "namespace" , "default" ),
830+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.#" , "1" ),
831+ resource .TestCheckTypeSetElemNestedAttrs ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.*" , map [string ]string {
832+ "version" : "8.15.0" ,
833+ "percentage" : "50" ,
834+ }),
835+ ),
836+ },
837+ {
838+ SkipFunc : versionutils .CheckIfVersionIsUnsupported (minVersionAgentPolicy ),
839+ Config : testAccResourceAgentPolicyAddRequiredVersion (policyName ),
840+ Check : resource .ComposeTestCheckFunc (
841+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "name" , fmt .Sprintf ("Policy %s" , policyName )),
842+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "namespace" , "default" ),
843+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.#" , "2" ),
844+ resource .TestCheckTypeSetElemNestedAttrs ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.*" , map [string ]string {
845+ "version" : "8.15.0" ,
846+ "percentage" : "50" ,
847+ }),
848+ resource .TestCheckTypeSetElemNestedAttrs ("elasticstack_fleet_agent_policy.test_policy" , "required_versions.*" , map [string ]string {
849+ "version" : "8.16.0" ,
850+ "percentage" : "50" ,
851+ }),
852+ ),
853+ },
854+ {
855+ SkipFunc : versionutils .CheckIfVersionIsUnsupported (minVersionAgentPolicy ),
856+ Config : testAccResourceAgentPolicyRemoveRequiredVersions (policyName ),
857+ Check : resource .ComposeTestCheckFunc (
858+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "name" , fmt .Sprintf ("Policy %s" , policyName )),
859+ resource .TestCheckResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "namespace" , "default" ),
860+ resource .TestCheckNoResourceAttr ("elasticstack_fleet_agent_policy.test_policy" , "required_versions" ),
861+ ),
862+ },
863+ },
864+ })
865865}
866866
867867func testAccResourceAgentPolicyCreateWithRequiredVersions (id string ) string {
868- return fmt .Sprintf (`
868+ return fmt .Sprintf (`
869869provider "elasticstack" {
870870 elasticsearch {}
871871 kibana {}
@@ -893,7 +893,7 @@ data "elasticstack_fleet_enrollment_tokens" "test_policy" {
893893}
894894
895895func testAccResourceAgentPolicyUpdateRequiredVersionsPercentage (id string ) string {
896- return fmt .Sprintf (`
896+ return fmt .Sprintf (`
897897provider "elasticstack" {
898898 elasticsearch {}
899899 kibana {}
@@ -921,7 +921,7 @@ data "elasticstack_fleet_enrollment_tokens" "test_policy" {
921921}
922922
923923func testAccResourceAgentPolicyAddRequiredVersion (id string ) string {
924- return fmt .Sprintf (`
924+ return fmt .Sprintf (`
925925provider "elasticstack" {
926926 elasticsearch {}
927927 kibana {}
@@ -953,7 +953,7 @@ data "elasticstack_fleet_enrollment_tokens" "test_policy" {
953953}
954954
955955func testAccResourceAgentPolicyRemoveRequiredVersions (id string ) string {
956- return fmt .Sprintf (`
956+ return fmt .Sprintf (`
957957provider "elasticstack" {
958958 elasticsearch {}
959959 kibana {}
0 commit comments