@@ -42,6 +42,16 @@ func TestAccCodefreshPermissionConfig(t *testing.T) {
4242 resource .TestCheckResourceAttr (resourceName , "tags.1" , "production" ),
4343 ),
4444 },
45+ {
46+ Config : testAccCodefreshNoRelatedResourcePermissionConfig ("create" , "runtime-environment" , []string {"production" , "*" }),
47+ Check : resource .ComposeTestCheckFunc (
48+ testAccCheckCodefreshPermissionExists (resourceName ),
49+ resource .TestCheckResourceAttr (resourceName , "action" , "create" ),
50+ resource .TestCheckResourceAttr (resourceName , "resource" , "runtime-environment" ),
51+ resource .TestCheckResourceAttr (resourceName , "tags.0" , "*" ),
52+ resource .TestCheckResourceAttr (resourceName , "tags.1" , "production" ),
53+ ),
54+ },
4555 {
4656 ResourceName : resourceName ,
4757 ImportState : true ,
@@ -96,3 +106,26 @@ func testAccCodefreshPermissionConfig(action, resource, relatedResource string,
96106 }
97107` , escapeString (action ), escapeString (resource ), escapeString (relatedResource ), strings .Join (tagsEscaped [:], "," ))
98108}
109+
110+ func testAccCodefreshNoRelatedResourcePermissionConfig (action , resource string , tags []string ) string {
111+ escapeString := func (str string ) string {
112+ if str == "null" {
113+ return str // null means Terraform should ignore this field
114+ }
115+ return fmt .Sprintf (`"%s"` , str )
116+ }
117+ tagsEscaped := funk .Map (tags , escapeString ).([]string )
118+
119+ return fmt .Sprintf (`
120+ data "codefresh_team" "users" {
121+ name = "users"
122+ }
123+
124+ resource "codefresh_permission" "test" {
125+ team = data.codefresh_team.users.id
126+ action = %s
127+ resource = %s
128+ tags = [%s]
129+ }
130+ ` , escapeString (action ), escapeString (resource ), strings .Join (tagsEscaped [:], "," ))
131+ }
0 commit comments