com.amazonaws.services.ecr.AmazonECRClientBuilder Java Examples
The following examples show how to use
com.amazonaws.services.ecr.AmazonECRClientBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ECRListImagesStep.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override protected List<Map<String, String>> run() throws Exception { AmazonECR ecr = AWSClientFactory.create(AmazonECRClientBuilder.standard(), this.getContext()); ListImagesRequest request = new ListImagesRequest() .withRegistryId(this.step.getRegistryId()) .withRepositoryName(this.step.getRepositoryName()) .withFilter(this.step.getFilter()); List<ImageIdentifier> images = new LinkedList<>(); ListImagesResult result; do { result = ecr.listImages(request); images.addAll(result.getImageIds()); request.setNextToken(result.getNextToken()); } while (result.getNextToken() != null); return images.stream().map(image -> new HashMap<String, String>() { { put("imageTag", image.getImageTag()); put("imageDigest", image.getImageDigest()); } }).collect(Collectors.toList()); }
Example #2
Source File: ECRDeleteImagesStep.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override protected List<ImageIdentifier> run() throws Exception { AmazonECR ecr = AWSClientFactory.create(AmazonECRClientBuilder.standard(), this.getContext()); BatchDeleteImageResult result = ecr.batchDeleteImage(new BatchDeleteImageRequest() .withImageIds(new ArrayList<>(this.step.getImageIds())) .withRegistryId(this.step.getRegistryId()) .withRepositoryName(this.step.getRepositoryName()) ); if (!result.getFailures().isEmpty()) { TaskListener listener = this.getContext().get(TaskListener.class); listener.error("Unable to delete images:"); for (ImageFailure failure : result.getFailures()) { listener.error("%s %s %s", failure.getFailureCode(), failure.getFailureReason(), failure.getImageId()); } } return result.getImageIds(); }
Example #3
Source File: ECRLoginStep.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override protected String run() throws Exception { AmazonECR ecr = AWSClientFactory.create(AmazonECRClientBuilder.standard(), this.getContext()); GetAuthorizationTokenRequest request = new GetAuthorizationTokenRequest(); List<String> registryIds; if((registryIds = this.step.getRegistryIds()) != null) { request.setRegistryIds(registryIds); } GetAuthorizationTokenResult token = ecr.getAuthorizationToken(request); if (token.getAuthorizationData().size() != 1) { throw new RuntimeException("Did not get authorizationData from AWS"); } AuthorizationData authorizationData = token.getAuthorizationData().get(0); byte[] bytes = org.apache.commons.codec.binary.Base64.decodeBase64(authorizationData.getAuthorizationToken()); String data = new String(bytes, Charsets.UTF_8); String[] parts = data.split(":"); if (parts.length != 2) { throw new RuntimeException("Got invalid authorizationData from AWS"); } String emailString = this.step.getEmail() ? "-e none" : ""; return String.format("docker login -u %s -p %s %s %s", parts[0], parts[1], emailString, authorizationData.getProxyEndpoint()); }
Example #4
Source File: ECRSetRepositoryPolicyStep.java From pipeline-aws-plugin with Apache License 2.0 | 5 votes |
@Override protected SetRepositoryPolicyResult run() throws Exception { AmazonECR ecr = AWSClientFactory.create(AmazonECRClientBuilder.standard(), this.getContext()); SetRepositoryPolicyRequest request = new SetRepositoryPolicyRequest() .withRegistryId(this.step.getRegistryId()) .withRepositoryName(this.step.getRepositoryName()) .withPolicyText(this.step.getPolicyText()); // https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ecr/model/SetRepositoryPolicyResult.html SetRepositoryPolicyResult result = ecr.setRepositoryPolicy(request); return result; }
Example #5
Source File: AwsEcrAuthorizer.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Override public HttpHeaders getAuthorizationHeaders(ContainerImage containerImage, RegistryConfiguration registryConfiguration) { Assert.isTrue(registryConfiguration.getAuthorizationType() == this.getType(), "Incorrect type: " + registryConfiguration.getAuthorizationType()); AmazonECRClientBuilder ecrBuilder = AmazonECRClientBuilder.standard(); if (registryConfiguration.getExtra().containsKey(AWS_REGION)) { ecrBuilder.withRegion(registryConfiguration.getExtra().get(AWS_REGION)); } if (StringUtils.hasText(registryConfiguration.getUser()) && StringUtils.hasText(registryConfiguration.getSecret())) { // Expects that the 'user' == 'Access Key ID' and 'secret' == 'Secret Access Key' ecrBuilder.withCredentials(new AWSStaticCredentialsProvider( new BasicAWSCredentials(registryConfiguration.getUser(), registryConfiguration.getSecret()))); } AmazonECR client = ecrBuilder.build(); GetAuthorizationTokenRequest request = new GetAuthorizationTokenRequest(); if (registryConfiguration.getExtra().containsKey(REGISTRY_IDS)) { request.withRegistryIds(registryConfiguration.getExtra().get(REGISTRY_IDS).split(",")); } GetAuthorizationTokenResult response = client.getAuthorizationToken(request); String token = response.getAuthorizationData().iterator().next().getAuthorizationToken(); final HttpHeaders headers = new HttpHeaders(); headers.setBasicAuth(token); return headers; }
Example #6
Source File: AWSTokenRequestGenerator.java From docker-registry-artifact-plugin with Apache License 2.0 | 4 votes |
AWSTokenRequestGenerator(AwsSyncClientBuilder<AmazonECRClientBuilder, AmazonECR> builder) { this.builder = builder; }
Example #7
Source File: AWSTokenRequestGenerator.java From docker-registry-artifact-plugin with Apache License 2.0 | 4 votes |
AwsSyncClientBuilder<AmazonECRClientBuilder, AmazonECR> getBuilder() { return builder; }