@@ -153,20 +153,23 @@ func assignAuthenticationCertificateAndKeyToConnection(keypair ClientCertificate
153
153
154
154
}
155
155
156
- func listServiceAccounts (serviceAccounts []ServiceAccount , connectionString ServerInfo ) {
156
+ func listServiceAccounts (serviceAccounts []ServiceAccount , connectionString ServerInfo , logToFile bool , outputFileName string ) {
157
157
println ("\n Available Service Accounts:" )
158
+ // Build a string of the service accounts, with the current one marked.
159
+ var output string
158
160
for i , account := range serviceAccounts {
159
161
if account .Name == connectionString .TokenName {
160
- fmt .Printf ("> [%d] %s\n " , i , account .Name )
162
+ output += fmt .Sprintf ("> [%d] %s\n " , i , account .Name )
161
163
} else {
162
- fmt .Printf (" [%d] %s\n " , i , account .Name )
164
+ output += fmt .Sprintf (" [%d] %s\n " , i , account .Name )
163
165
}
164
166
}
167
+ outputToUser (output , logToFile , outputFileName )
165
168
}
166
169
167
- func switchServiceAccounts (serviceAccounts []ServiceAccount , connectionString * ServerInfo ) {
170
+ func switchServiceAccounts (serviceAccounts []ServiceAccount , connectionString * ServerInfo , logToFile bool , outputFileName string ) {
168
171
var err error
169
- listServiceAccounts (serviceAccounts , * connectionString )
172
+ listServiceAccounts (serviceAccounts , * connectionString , logToFile , outputFileName )
170
173
println ("\n Enter service account number or exit to abort: " )
171
174
var tokNum int
172
175
var input string
@@ -187,9 +190,10 @@ func switchServiceAccounts(serviceAccounts []ServiceAccount, connectionString *S
187
190
return
188
191
}
189
192
190
- func displayServiceAccountTokenInteractive (serviceAccounts []ServiceAccount , connectionString * ServerInfo ) {
193
+ func displayServiceAccountTokenInteractive (serviceAccounts []ServiceAccount , connectionString * ServerInfo , logToFile bool , outputFileName string ) {
191
194
var err error
192
- listServiceAccounts (serviceAccounts , * connectionString )
195
+ listServiceAccounts (serviceAccounts , * connectionString , false , outputFileName )
196
+
193
197
println ("\n Enter service account number or exit to abort: " )
194
198
var tokNum int
195
199
var input string
0 commit comments