@@ -108,6 +108,48 @@ func TestValidateExtraTags(t *testing.T) {
108108 }
109109}
110110
111+ func TestValidateExtraTagsWarnOnly (t * testing.T ) {
112+ testCases := []struct {
113+ name string
114+ tags map [string ]string
115+ expectedTags map [string ]string
116+ }{
117+ {
118+ name : "valid tags are preserved" ,
119+ tags : map [string ]string {
120+ "extra-tag-key" : "extra-tag-value" ,
121+ },
122+ expectedTags : map [string ]string {
123+ "extra-tag-key" : "extra-tag-value" ,
124+ },
125+ },
126+ {
127+ name : "reserved keys are removed" ,
128+ tags : map [string ]string {
129+ cloud .VolumeNameTagKey : "attacker-vol-name" ,
130+ cloud .SnapshotNameTagKey : "attacker-snap-name" ,
131+ ClusterNameTagKey : "attacker-cluster" ,
132+ "valid-key" : "valid-value" ,
133+ },
134+ expectedTags : map [string ]string {
135+ "valid-key" : "valid-value" ,
136+ },
137+ },
138+ }
139+
140+ for _ , tc := range testCases {
141+ t .Run (tc .name , func (t * testing.T ) {
142+ err := validateExtraTags (tc .tags , true )
143+ if err != nil {
144+ t .Fatalf ("unexpected error: %v" , err )
145+ }
146+ if ! reflect .DeepEqual (tc .tags , tc .expectedTags ) {
147+ t .Fatalf ("tags not equal\n got:\n %v\n expected:\n %v" , tc .tags , tc .expectedTags )
148+ }
149+ })
150+ }
151+ }
152+
111153func TestValidateMode (t * testing.T ) {
112154 testCases := []struct {
113155 name string
0 commit comments