@@ -159,3 +159,49 @@ func TestBuildAWSCustomNodeIPFamilies(t *testing.T) {
159159 t .Errorf ("actual did not match expected:\n %s\n " , diffString )
160160 }
161161}
162+
163+ func TestBuildAWSNLBSecurityGroupMode (t * testing.T ) {
164+ nlbSecurityGroupMode := "Managed"
165+ b := & CloudConfigBuilder {
166+ NodeupModelContext : & NodeupModelContext {
167+ BootConfig : & nodeup.BootConfig {
168+ CloudProvider : kops .CloudProviderAWS ,
169+ },
170+ NodeupConfig : & nodeup.Config {
171+ NLBSecurityGroupMode : & nlbSecurityGroupMode ,
172+ },
173+ HasAPIServer : true ,
174+ },
175+ }
176+ ctx := & fi.NodeupModelBuilderContext {
177+ Tasks : map [string ]fi.NodeupTask {},
178+ }
179+ if err := b .Build (ctx ); err != nil {
180+ t .Fatalf ("unexpected error from Build(): %v" , err )
181+ }
182+ var task * nodetasks.File
183+ for _ , v := range ctx .Tasks {
184+ if f , ok := v .(* nodetasks.File ); ok && f .Path == CloudConfigFilePath {
185+ task = f
186+ break
187+ }
188+ }
189+ if task == nil {
190+ t .Fatalf ("no File task found" )
191+ }
192+ r , err := task .Contents .Open ()
193+ if err != nil {
194+ t .Fatalf ("unexpected error from task.Contents.Open(): %v" , err )
195+ }
196+ awsCloudConfig , err := io .ReadAll (r )
197+ if err != nil {
198+ t .Fatalf ("unexpected error from ReadAll(): %v" , err )
199+ }
200+
201+ actual := string (awsCloudConfig )
202+ expected := "[global]\n NLBSecurityGroupMode = Managed\n "
203+ if actual != expected {
204+ diffString := diff .FormatDiff (expected , actual )
205+ t .Errorf ("actual did not match expected:\n %s\n " , diffString )
206+ }
207+ }
0 commit comments