File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -134,14 +134,9 @@ func startAzureReport() {
134134 log .Infof ("searching for ServicePrincipal information" )
135135 authSettings , _ := auth .GetSettingsFromEnvironment ()
136136
137- if authSettings .GetMSI ().ClientID != "" {
138- spnInfo := log.Fields {
139- "clientId" : authSettings .GetMSI ().ClientID ,
140- }
141- log .WithFields (spnInfo ).Infof ("using ServicePrincipal in ENV vars" )
142- }
143-
137+ // spn detection
144138 if spnToken , err := authSettings .GetMSI ().ServicePrincipalToken (); err == nil {
139+ // msi detected
145140 if err := spnToken .EnsureFresh (); err != nil {
146141 log .Panic (err )
147142 }
@@ -170,6 +165,23 @@ func startAzureReport() {
170165 log .WithFields (spnInfo ).Info ("found MSI ServicePrincipal in auth token" )
171166 }
172167 }
168+ } else {
169+ // env settings
170+ spnInfo := log.Fields {}
171+
172+ if val := os .Getenv ("AZURE_CLIENT_ID" ); val != "" {
173+ spnInfo ["clientid" ] = val
174+ }
175+
176+ if val := os .Getenv ("AZURE_TENANT_ID" ); val != "" {
177+ spnInfo ["tenantid" ] = val
178+ }
179+
180+ if len (spnInfo ) > 0 {
181+ log .WithFields (spnInfo ).Infof ("using ServicePrincipal in ENV vars" )
182+ } else {
183+ log .WithFields (spnInfo ).Infof ("unable to detect ServicePrincipal" )
184+ }
173185 }
174186
175187 log .Infof ("starting Azure access report" )
You can’t perform that action at this time.
0 commit comments