Skip to content

Commit

Permalink
Clean up some deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiX committed Jun 27, 2024
1 parent cb12ae4 commit c45fcef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.model.ItemGroup;
import hudson.security.ACL;
import hudson.util.Secret;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;

Expand All @@ -66,13 +65,13 @@ public class AmazonECSRegistryCredential extends BaseStandardCredentials
private final ItemGroup itemGroup;

public AmazonECSRegistryCredential(
CredentialsScope scope, @Nonnull String credentialsId, String description, ItemGroup itemGroup) {
this(scope, credentialsId, Regions.US_EAST_1, description, (ItemGroup<?>) itemGroup);
CredentialsScope scope, @NonNull String credentialsId, String description, ItemGroup itemGroup) {
this(scope, credentialsId, Regions.US_EAST_1, description, itemGroup);
}

public AmazonECSRegistryCredential(
@CheckForNull CredentialsScope scope,
@Nonnull String credentialsId,
@NonNull String credentialsId,
Regions region,
String description,
ItemGroup itemGroup) {
Expand All @@ -88,7 +87,7 @@ public AmazonECSRegistryCredential(
this.itemGroup = itemGroup;
}

@Nonnull
@NonNull
public String getCredentialsId() {
return credentialsId;
}
Expand All @@ -97,8 +96,8 @@ public String getCredentialsId() {
LOG.log(Level.FINE, "Looking for Amazon web credentials ID: {0} Region: {1}", new Object[] {
this.credentialsId, this.region
});
List<AmazonWebServicesCredentials> credentials = CredentialsProvider.lookupCredentials(
AmazonWebServicesCredentials.class, itemGroup, ACL.SYSTEM, Collections.EMPTY_LIST);
List<AmazonWebServicesCredentials> credentials = CredentialsProvider.lookupCredentialsInItemGroup(

Check warning on line 99 in src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredential.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 69-99 are not covered by tests
AmazonWebServicesCredentials.class, itemGroup, ACL.SYSTEM2);

if (LOG.isLoggable(Level.FINEST)) {
String fullStackTrace = org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(new Throwable());
Expand All @@ -120,14 +119,15 @@ public String getCredentialsId() {
return null;
}

@Nonnull
@NonNull
@Override
public String getDescription() {
String description = super.getDescription();
LOG.finest(description);
return description;
}

@Nonnull
@NonNull
@Override
public Secret getPassword() {
final AmazonWebServicesCredentials credentials = getCredentials();
Expand Down Expand Up @@ -167,13 +167,13 @@ public Secret getPassword() {
return Secret.fromString(authorizationData.get(0).getAuthorizationToken());
}

@Nonnull
@NonNull
@Override
public String getUsername() {
return "AWS";
}

@Nonnull
@NonNull
public String getEmail() {
return "[email protected]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
import com.cloudbees.jenkins.plugins.awscredentials.AmazonWebServicesCredentials;
import com.cloudbees.plugins.credentials.Credentials;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.cloudbees.plugins.credentials.domains.DomainRequirement;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.Extension;
import hudson.model.ItemGroup;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.acegisecurity.Authentication;
import org.springframework.security.core.Authentication;

/**
* This class automatically wraps existing {@link AmazonWebServicesCredentials} instances into a
Expand All @@ -50,19 +50,22 @@ public class AmazonECSRegistryCredentialsProvider extends CredentialsProvider {

private static final Logger LOG = Logger.getLogger(AmazonECSRegistryCredentialsProvider.class.getName());

@Nonnull
@NonNull
@Override
public <C extends Credentials> List<C> getCredentials(
@Nonnull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication) {
public <C extends Credentials> List<C> getCredentialsInItemGroup(
@NonNull Class<C> type,
@Nullable ItemGroup itemGroup,
@Nullable Authentication authentication,
@NonNull List<DomainRequirement> domainRequirements) {

if (!type.isAssignableFrom(AmazonECSRegistryCredential.class)) {
return ImmutableList.of();
return Collections.emptyList();
}

List<C> derived = Lists.newLinkedList();
List<C> derived = new LinkedList<>();

final List<AmazonWebServicesCredentials> list = lookupCredentials(
AmazonWebServicesCredentials.class, itemGroup, authentication, Collections.EMPTY_LIST);
final List<AmazonWebServicesCredentials> list = lookupCredentialsInItemGroup(

Check warning on line 67 in src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredentialsProvider.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 62-67 are not covered by tests
AmazonWebServicesCredentials.class, itemGroup, authentication, domainRequirements);

for (AmazonWebServicesCredentials credentials : list) {
LOG.log(
Expand Down

0 comments on commit c45fcef

Please sign in to comment.