Skip to content

Commit 08a9011

Browse files
authored
Merge pull request #179 from kbst/fix-roleref-recreate
Handle roleRef changes with destroy and recreate plan fix #176
2 parents 8eea709 + 7507c53 commit 08a9011

File tree

8 files changed

+166
-28
lines changed

8 files changed

+166
-28
lines changed

go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/kbst/terraform-provider-kustomize
33
go 1.17
44

55
require (
6-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.12.0
6+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0
77
github.com/mitchellh/go-homedir v1.1.0
88
github.com/stretchr/testify v1.7.1
99
k8s.io/api v0.23.5
@@ -38,7 +38,7 @@ require (
3838
github.com/golang-jwt/jwt/v4 v4.4.0 // indirect
3939
github.com/golang/protobuf v1.5.2 // indirect
4040
github.com/google/gnostic v0.6.7 // indirect
41-
github.com/google/go-cmp v0.5.7 // indirect
41+
github.com/google/go-cmp v0.5.8 // indirect
4242
github.com/google/gofuzz v1.2.0 // indirect
4343
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
4444
github.com/googleapis/gnostic v0.5.5 // indirect
@@ -49,15 +49,15 @@ require (
4949
github.com/hashicorp/go-hclog v1.2.0 // indirect
5050
github.com/hashicorp/go-multierror v1.1.1 // indirect
5151
github.com/hashicorp/go-plugin v1.4.3 // indirect
52-
github.com/hashicorp/go-uuid v1.0.2 // indirect
52+
github.com/hashicorp/go-uuid v1.0.3 // indirect
5353
github.com/hashicorp/go-version v1.4.0 // indirect
54-
github.com/hashicorp/hc-install v0.3.1 // indirect
55-
github.com/hashicorp/hcl/v2 v2.11.1 // indirect
54+
github.com/hashicorp/hc-install v0.3.2 // indirect
55+
github.com/hashicorp/hcl/v2 v2.12.0 // indirect
5656
github.com/hashicorp/logutils v1.0.0 // indirect
57-
github.com/hashicorp/terraform-exec v0.16.0 // indirect
57+
github.com/hashicorp/terraform-exec v0.16.1 // indirect
5858
github.com/hashicorp/terraform-json v0.13.0 // indirect
59-
github.com/hashicorp/terraform-plugin-go v0.8.0 // indirect
60-
github.com/hashicorp/terraform-plugin-log v0.3.0 // indirect
59+
github.com/hashicorp/terraform-plugin-go v0.9.0 // indirect
60+
github.com/hashicorp/terraform-plugin-log v0.4.0 // indirect
6161
github.com/hashicorp/terraform-registry-address v0.0.0-20220131103327-5c1c5e123275 // indirect
6262
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
6363
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
@@ -70,7 +70,7 @@ require (
7070
github.com/mitchellh/copystructure v1.2.0 // indirect
7171
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
7272
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
73-
github.com/mitchellh/mapstructure v1.4.3 // indirect
73+
github.com/mitchellh/mapstructure v1.5.0 // indirect
7474
github.com/mitchellh/reflectwalk v1.0.2 // indirect
7575
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
7676
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -95,7 +95,7 @@ require (
9595
google.golang.org/appengine v1.6.7 // indirect
9696
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e // indirect
9797
google.golang.org/grpc v1.45.0 // indirect
98-
google.golang.org/protobuf v1.27.1 // indirect
98+
google.golang.org/protobuf v1.28.0 // indirect
9999
gopkg.in/inf.v0 v0.9.1 // indirect
100100
gopkg.in/yaml.v2 v2.4.0 // indirect
101101
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect

go.sum

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
9494
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
9595
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
9696
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
97-
github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE=
9897
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
9998
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
10099
github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
@@ -293,8 +292,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
293292
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
294293
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
295294
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
296-
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
297295
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
296+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
297+
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
298298
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
299299
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
300300
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
@@ -366,36 +366,38 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX
366366
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
367367
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
368368
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
369-
github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE=
370-
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
369+
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
370+
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
371371
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
372372
github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
373373
github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4=
374374
github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
375375
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
376376
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
377377
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
378-
github.com/hashicorp/hc-install v0.3.1 h1:VIjllE6KyAI1A244G8kTaHXy+TL5/XYzvrtFi8po/Yk=
379378
github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak=
379+
github.com/hashicorp/hc-install v0.3.2 h1:oiQdJZvXmkNcRcEOOfM5n+VTsvNjWQeOjfAoO6dKSH8=
380+
github.com/hashicorp/hc-install v0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgEGqEz0V4jisHs=
380381
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
381382
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
382-
github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc=
383-
github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
383+
github.com/hashicorp/hcl/v2 v2.12.0 h1:PsYxySWpMD4KPaoJLnsHwtK5Qptvj/4Q6s0t4sUxZf4=
384+
github.com/hashicorp/hcl/v2 v2.12.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
384385
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
385386
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
386387
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
387388
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
388389
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
389-
github.com/hashicorp/terraform-exec v0.16.0 h1:XUh9pJPcbfZsuhReVvmRarQTaiiCnYogFCCjOvEYuug=
390-
github.com/hashicorp/terraform-exec v0.16.0/go.mod h1:wB5JHmjxZ/YVNZuv9npAXKmz5pGyxy8PSi0GRR0+YjA=
390+
github.com/hashicorp/terraform-exec v0.16.1 h1:NAwZFJW2L2SaCBVZoVaH8LPImLOGbPLkSHy0IYbs2uE=
391+
github.com/hashicorp/terraform-exec v0.16.1/go.mod h1:aj0lVshy8l+MHhFNoijNHtqTJQI3Xlowv5EOsEaGO7M=
391392
github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY=
392393
github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk=
393-
github.com/hashicorp/terraform-plugin-go v0.8.0 h1:MvY43PcDj9VlBjYifBWCO/6j1wf106xU8d5Tob/WRs0=
394-
github.com/hashicorp/terraform-plugin-go v0.8.0/go.mod h1:E3GuvfX0Pz2Azcl6BegD6t51StXsVZMOYQoGO8mkHM0=
395-
github.com/hashicorp/terraform-plugin-log v0.3.0 h1:NPENNOjaJSVX0f7JJTl4f/2JKRPQ7S2ZN9B4NSqq5kA=
394+
github.com/hashicorp/terraform-plugin-go v0.9.0 h1:FvLY/3z4SNVatPZdoFcyrlNbCar+WyyOTv5X4Tp+WZc=
395+
github.com/hashicorp/terraform-plugin-go v0.9.0/go.mod h1:EawBkgjBWNf7jiKnVoyDyF39OSV+u6KUX+Y73EPj3oM=
396396
github.com/hashicorp/terraform-plugin-log v0.3.0/go.mod h1:EjueSP/HjlyFAsDqt+okpCPjkT4NDynAe32AeDC4vps=
397-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.12.0 h1:rjJxyLUVA180BG0ZXTOree4x2RVvo2jigdYoT2rw5j0=
398-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.12.0/go.mod h1:TPjMXvpPNWagHzYOmVPzzRRIBTuaLVukR+esL08tgzg=
397+
github.com/hashicorp/terraform-plugin-log v0.4.0 h1:F3eVnm8r2EfQCe2k9blPIiF/r2TT01SHijXnS7bujvc=
398+
github.com/hashicorp/terraform-plugin-log v0.4.0/go.mod h1:9KclxdunFownr4pIm1jdmwKRmE4d6HVG2c9XDq47rpg=
399+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0 h1:9fjPgCenJqnbjo95SDcbJ+YdLyEC1N35cwKWcRWhJTQ=
400+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0/go.mod h1:hLa0sTiySU/AWEgV2GxJh0/pQIqcCmm30IPja9N9lTg=
399401
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co=
400402
github.com/hashicorp/terraform-registry-address v0.0.0-20220131103327-5c1c5e123275 h1:x/8cnK295F9NK18FXxsJxU1bz2PusWH52DDDsuao+88=
401403
github.com/hashicorp/terraform-registry-address v0.0.0-20220131103327-5c1c5e123275/go.mod h1:bdLC+qQlJIBHKbCMA6GipcuaKjmjcvZlnVdpU583z3Y=
@@ -497,8 +499,8 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu
497499
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
498500
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
499501
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
500-
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
501-
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
502+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
503+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
502504
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
503505
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
504506
github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
@@ -1139,6 +1141,7 @@ google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ5
11391141
google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M=
11401142
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
11411143
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
1144+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY=
11421145
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
11431146
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
11441147
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -1151,8 +1154,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
11511154
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
11521155
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
11531156
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1154-
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
11551157
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1158+
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
1159+
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
11561160
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
11571161
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
11581162
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

kustomize/resource_kustomization.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func kustomizationResourceCreate(d *schema.ResourceData, m interface{}) error {
9191
// wait for service account to exist
9292
// https://github.com/kubernetes/kubernetes/issues/109401
9393
if (u.GetKind() == "Secret") &&
94-
(u.UnstructuredContent()["type"].(string) == string(k8scorev1.SecretTypeServiceAccountToken)) {
94+
(u.UnstructuredContent()["type"].(string) == string(k8scorev1.SecretTypeServiceAccountToken)) {
9595

9696
annotations := u.GetAnnotations()
9797
for k, v := range annotations {
@@ -263,6 +263,12 @@ func kustomizationResourceDiff(ctx context.Context, d *schema.ResourceDiff, m in
263263
return nil
264264
}
265265

266+
// if cause is cannot change roleRef force a delete and re-create plan
267+
if k8serrors.HasStatusCause(err, k8smetav1.CauseTypeFieldValueInvalid) && strings.HasSuffix(msg, ": cannot change roleRef") == true {
268+
d.ForceNew("manifest")
269+
return nil
270+
}
271+
266272
}
267273
}
268274

kustomize/resource_kustomization_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,72 @@ resource "kustomization_resource" "ss" {
379379
`
380380
}
381381

382+
//
383+
//
384+
// Update_Recreate_RoleRef Test
385+
func TestAccResourceKustomization_updateRecreateRoleRef(t *testing.T) {
386+
387+
resource.Test(t, resource.TestCase{
388+
Providers: testAccProviders,
389+
Steps: []resource.TestStep{
390+
//
391+
//
392+
// Applying initial role and rolebinding
393+
{
394+
Config: testAccResourceKustomizationConfig_updateRecreateRoleRefInitial("test_kustomizations/update_recreate_roleref/initial"),
395+
Check: resource.ComposeAggregateTestCheckFunc(
396+
resource.TestCheckResourceAttrSet("kustomization_resource.ns", "id"),
397+
resource.TestCheckResourceAttrSet("kustomization_resource.r", "id"),
398+
resource.TestCheckResourceAttrSet("kustomization_resource.rb", "id"),
399+
),
400+
},
401+
//
402+
//
403+
// Applying changed roleRef
404+
{
405+
Config: testAccResourceKustomizationConfig_updateRecreateRoleRefModified("test_kustomizations/update_recreate_roleref/modified"),
406+
Check: resource.ComposeAggregateTestCheckFunc(
407+
resource.TestCheckResourceAttrSet("kustomization_resource.ns", "id"),
408+
resource.TestCheckResourceAttrSet("kustomization_resource.r", "id"),
409+
resource.TestCheckResourceAttrSet("kustomization_resource.rb", "id"),
410+
),
411+
},
412+
},
413+
})
414+
}
415+
416+
func testAccResourceKustomizationConfig_updateRecreateRoleRefInitial(path string) string {
417+
return testAccDataSourceKustomizationConfig_basic(path, false) + `
418+
resource "kustomization_resource" "ns" {
419+
manifest = data.kustomization_build.test.manifests["_/Namespace/_/test-update-recreate-roleref"]
420+
}
421+
422+
resource "kustomization_resource" "r" {
423+
manifest = data.kustomization_build.test.manifests["rbac.authorization.k8s.io/Role/test-update-recreate-roleref/test-initial"]
424+
}
425+
426+
resource "kustomization_resource" "rb" {
427+
manifest = data.kustomization_build.test.manifests["rbac.authorization.k8s.io/RoleBinding/test-update-recreate-roleref/test"]
428+
}
429+
`
430+
}
431+
432+
func testAccResourceKustomizationConfig_updateRecreateRoleRefModified(path string) string {
433+
return testAccDataSourceKustomizationConfig_basic(path, false) + `
434+
resource "kustomization_resource" "ns" {
435+
manifest = data.kustomization_build.test.manifests["_/Namespace/_/test-update-recreate-roleref"]
436+
}
437+
438+
resource "kustomization_resource" "r" {
439+
manifest = data.kustomization_build.test.manifests["rbac.authorization.k8s.io/Role/test-update-recreate-roleref/test-modified"]
440+
}
441+
442+
resource "kustomization_resource" "rb" {
443+
manifest = data.kustomization_build.test.manifests["rbac.authorization.k8s.io/RoleBinding/test-update-recreate-roleref/test"]
444+
}
445+
`
446+
}
447+
382448
//
383449
//
384450
// Upgrade_API_Version Test
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
namespace: test-update-recreate-roleref
5+
6+
resources:
7+
- namespace.yaml
8+
- rbac.yaml
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: test-update-recreate-roleref
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
namespace: test-update-recreate-roleref
5+
name: test-initial
6+
rules:
7+
- apiGroups: [""]
8+
resources: ["configmaps"]
9+
verbs: ["get", "watch", "list"]
10+
---
11+
apiVersion: rbac.authorization.k8s.io/v1
12+
kind: RoleBinding
13+
metadata:
14+
name: test
15+
namespace: test-update-recreate-roleref
16+
subjects:
17+
- kind: ServiceAccount
18+
name: default
19+
namespace: test-update-recreate-roleref
20+
roleRef:
21+
kind: Role #this must be Role or ClusterRole
22+
name: test-initial
23+
apiGroup: rbac.authorization.k8s.io
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
namespace: test-update-recreate-roleref
5+
6+
resources:
7+
- ../initial
8+
9+
patches:
10+
- patch: |
11+
- op: replace
12+
path: /metadata/name
13+
value: test-modified
14+
target:
15+
group: "rbac.authorization.k8s.io"
16+
version: v1
17+
kind: Role
18+
name: test-initial
19+
- patch: |
20+
- op: replace
21+
path: /roleRef/name
22+
value: test-modified
23+
target:
24+
group: "rbac.authorization.k8s.io"
25+
version: v1
26+
kind: RoleBinding
27+
name: test

0 commit comments

Comments
 (0)