2017-05-11 16:39:54 +02:00
|
|
|
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
|
|
|
|
|
|
|
package ecr_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-07-23 09:51:42 +02:00
|
|
|
"strings"
|
2017-05-11 16:39:54 +02:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
2017-07-23 09:51:42 +02:00
|
|
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
2017-05-11 16:39:54 +02:00
|
|
|
"github.com/aws/aws-sdk-go/aws/session"
|
|
|
|
"github.com/aws/aws-sdk-go/service/ecr"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ time.Duration
|
2017-07-23 09:51:42 +02:00
|
|
|
var _ strings.Reader
|
|
|
|
var _ aws.Config
|
2017-05-11 16:39:54 +02:00
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
func parseTime(layout, value string) *time.Time {
|
|
|
|
t, err := time.Parse(layout, value)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
panic(err)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
2017-07-23 09:51:42 +02:00
|
|
|
return &t
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To delete multiple images
|
|
|
|
//
|
|
|
|
// This example deletes images with the tags precise and trusty in a repository called
|
|
|
|
// ubuntu in the default registry for an account.
|
|
|
|
func ExampleECR_BatchDeleteImage_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.BatchDeleteImageInput{
|
|
|
|
ImageIds: []*ecr.ImageIdentifier{
|
|
|
|
{
|
|
|
|
ImageTag: aws.String("precise"),
|
2017-05-11 16:39:54 +02:00
|
|
|
},
|
|
|
|
},
|
2017-07-23 09:51:42 +02:00
|
|
|
RepositoryName: aws.String("ubuntu"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.BatchDeleteImage(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryNotFoundException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To obtain multiple images in a single request
|
|
|
|
//
|
|
|
|
// This example obtains information for an image with a specified image digest ID from
|
|
|
|
// the repository named ubuntu in the current account.
|
|
|
|
func ExampleECR_BatchGetImage_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.BatchGetImageInput{
|
2017-05-11 16:39:54 +02:00
|
|
|
ImageIds: []*ecr.ImageIdentifier{
|
2017-07-23 09:51:42 +02:00
|
|
|
{
|
|
|
|
ImageTag: aws.String("precise"),
|
2017-05-11 16:39:54 +02:00
|
|
|
},
|
|
|
|
},
|
2017-07-23 09:51:42 +02:00
|
|
|
RepositoryName: aws.String("ubuntu"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.BatchGetImage(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryNotFoundException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To create a new repository
|
|
|
|
//
|
|
|
|
// This example creates a repository called nginx-web-app inside the project-a namespace
|
|
|
|
// in the default registry for an account.
|
|
|
|
func ExampleECR_CreateRepository_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.CreateRepositoryInput{
|
|
|
|
RepositoryName: aws.String("project-a/nginx-web-app"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.CreateRepository(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryAlreadyExistsException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryAlreadyExistsException, aerr.Error())
|
|
|
|
case ecr.ErrCodeLimitExceededException:
|
|
|
|
fmt.Println(ecr.ErrCodeLimitExceededException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To force delete a repository
|
|
|
|
//
|
|
|
|
// This example force deletes a repository named ubuntu in the default registry for
|
|
|
|
// an account. The force parameter is required if the repository contains images.
|
|
|
|
func ExampleECR_DeleteRepository_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.DeleteRepositoryInput{
|
|
|
|
Force: aws.Bool(true),
|
|
|
|
RepositoryName: aws.String("ubuntu"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.DeleteRepository(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryNotFoundException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryNotEmptyException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryNotEmptyException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To delete the policy associated with a repository
|
|
|
|
//
|
|
|
|
// This example deletes the policy associated with the repository named ubuntu in the
|
|
|
|
// current account.
|
|
|
|
func ExampleECR_DeleteRepositoryPolicy_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.DeleteRepositoryPolicyInput{
|
|
|
|
RepositoryName: aws.String("ubuntu"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.DeleteRepositoryPolicy(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryNotFoundException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryPolicyNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryPolicyNotFoundException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To describe all repositories in the current account
|
|
|
|
//
|
|
|
|
// The following example obtains a list and description of all repositories in the default
|
|
|
|
// registry to which the current user has access.
|
|
|
|
func ExampleECR_DescribeRepositories_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.DescribeRepositoriesInput{}
|
2017-05-11 16:39:54 +02:00
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.DescribeRepositories(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryNotFoundException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To obtain an authorization token
|
|
|
|
//
|
|
|
|
// This example gets an authorization token for your default registry.
|
|
|
|
func ExampleECR_GetAuthorizationToken_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.GetAuthorizationTokenInput{}
|
2017-05-11 16:39:54 +02:00
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.GetAuthorizationToken(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To get the current policy for a repository
|
|
|
|
//
|
|
|
|
// This example obtains the repository policy for the repository named ubuntu.
|
|
|
|
func ExampleECR_GetRepositoryPolicy_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.GetRepositoryPolicyInput{
|
|
|
|
RepositoryName: aws.String("ubuntu"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.GetRepositoryPolicy(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryNotFoundException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryPolicyNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryPolicyNotFoundException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To list all images in a repository
|
|
|
|
//
|
|
|
|
// This example lists all of the images in the repository named ubuntu in the default
|
|
|
|
// registry in the current account.
|
|
|
|
func ExampleECR_ListImages_shared00() {
|
|
|
|
svc := ecr.New(session.New())
|
|
|
|
input := &ecr.ListImagesInput{
|
|
|
|
RepositoryName: aws.String("ubuntu"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.ListImages(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case ecr.ErrCodeServerException:
|
|
|
|
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
|
|
|
|
case ecr.ErrCodeInvalidParameterException:
|
|
|
|
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
|
|
|
|
case ecr.ErrCodeRepositoryNotFoundException:
|
|
|
|
fmt.Println(ecr.ErrCodeRepositoryNotFoundException, aerr.Error())
|
|
|
|
default:
|
|
|
|
fmt.Println(aerr.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
|
|
// Message from an error.
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|