Skip to content

Commit

Permalink
Sort regions and update azure-commons (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Apr 2, 2021
1 parent edbebdf commit f22cf90
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<findbugs.excludeFilterFile>findbugs-exclude.xml</findbugs.excludeFilterFile>
<maven.javadoc.skip>true</maven.javadoc.skip>
<azure-credentials.version>1.6.1</azure-credentials.version>
<azure-commons.version>1.1.0</azure-commons.version>
<azure-commons.version>1.1.2</azure-commons.version>
<guava.version>24.1.1-jre</guava.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -1309,7 +1310,8 @@ public ListBoxModel doFillLocationItems(@RelativePath("..") @QueryParameter Stri
Set<String> locations = AzureClientHolder.getDelegate(azureCredentialsId)
.getVirtualMachineLocations(managementEndpoint != null ? managementEndpoint : envName);
if (locations != null) {
for (String location : locations) {
Set<String> sortedLocations = new TreeSet<>(locations);
for (String location : sortedLocations) {
model.add(location);
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/microsoft/azure/vmagent/AzureVMCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ public FormValidation doVerifyConfiguration(
@QueryParameter String resourceGroupReferenceType,
@QueryParameter String newResourceGroupName,
@QueryParameter String existingResourceGroupName) {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
Jenkins.get().checkPermission(Jenkins.ADMINISTER);

String resourceGroupName = getResourceGroupName(
resourceGroupReferenceType, newResourceGroupName, existingResourceGroupName);
Expand Down Expand Up @@ -1166,9 +1166,8 @@ public ListBoxModel doFillExistingResourceGroupNameItems(@QueryParameter String
}
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Cannot list resource group name: ", e);
} finally {
return model;
}
return model;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@
import com.microsoft.jenkins.azurecommons.core.credentials.TokenCredentialData;
import org.apache.commons.lang.StringUtils;

import java.util.logging.Logger;

public final class AzureClientUtil {

private static final Logger LOGGER = Logger.getLogger(AzureClientUtil.class.getName());

public static TokenCredentialData getToken(String credentialId) {
AzureBaseCredentials credential = AzureCredentialUtil.getCredential2(credentialId);
if (credential == null) {
Expand All @@ -56,15 +52,10 @@ public static Azure getClient(String credentialId, String subscriptionId) throws
}

public static Azure getClient(TokenCredentialData token) {
return AzureClientFactory.getClient(token, new AzureClientFactory.Configurer() {
@Override
public Azure.Configurable configure(Azure.Configurable configurable) {
return configurable
.withInterceptor(new AzureVMAgentPlugin.AzureTelemetryInterceptor())
.withUserAgent(AzureClientFactory.getUserAgent(Constants.PLUGIN_NAME,
AzureClientUtil.class.getPackage().getImplementationVersion()));
}
});
return AzureClientFactory.getClient(token, configurable -> configurable
.withInterceptor(new AzureVMAgentPlugin.AzureTelemetryInterceptor())
.withUserAgent(AzureClientFactory.getUserAgent(Constants.PLUGIN_NAME,
AzureClientUtil.class.getPackage().getImplementationVersion())));
}

private AzureClientUtil() {
Expand Down

0 comments on commit f22cf90

Please sign in to comment.