Skip to content

Commit 43e72a9

Browse files
authored
Merge pull request #4819 from Patryk-Stefanski/DiagnosticsUserManagedNilCheck
Check UserManaged is not nil in azure/converters/diagnostics
2 parents bccef17 + d8f1e9d commit 43e72a9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

azure/converters/diagnostics.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ func GetDiagnosticsProfile(diagnostics *infrav1.Diagnostics) *armcompute.Diagnos
3939
},
4040
}
4141
case infrav1.UserManagedDiagnosticsStorage:
42-
return &armcompute.DiagnosticsProfile{
43-
BootDiagnostics: &armcompute.BootDiagnostics{
44-
Enabled: ptr.To(true),
45-
StorageURI: &diagnostics.Boot.UserManaged.StorageAccountURI,
46-
},
42+
if diagnostics.Boot.UserManaged != nil {
43+
return &armcompute.DiagnosticsProfile{
44+
BootDiagnostics: &armcompute.BootDiagnostics{
45+
Enabled: ptr.To(true),
46+
StorageURI: &diagnostics.Boot.UserManaged.StorageAccountURI,
47+
},
48+
}
4749
}
4850
}
4951
}

azure/converters/diagnostics_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ func TestGetDiagnosticsProfile(t *testing.T) {
8181
},
8282
want: nil,
8383
},
84+
{
85+
name: "nil diagnostics boot user managed",
86+
diagnostics: &infrav1.Diagnostics{
87+
Boot: &infrav1.BootDiagnostics{
88+
StorageAccountType: infrav1.UserManagedDiagnosticsStorage,
89+
UserManaged: nil,
90+
},
91+
},
92+
want: nil,
93+
},
8494
}
8595
for _, tt := range tests {
8696
tt := tt

0 commit comments

Comments
 (0)