mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 18:55:18 +01:00
Merge pull request #10453 from bitsf/ecr_delete_image_1.10
(cherry-pick): aws ecr delete image 1.10.x
This commit is contained in:
commit
96e2bbf12e
@ -271,3 +271,38 @@ func (a *adapter) createRepository(repository string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteManifest ...
|
||||||
|
func (a *adapter) DeleteManifest(repository, reference string) error {
|
||||||
|
// AWS doesn't implement standard OCI delete manifest API, so use it's sdk.
|
||||||
|
if a.registry.Credential == nil ||
|
||||||
|
len(a.registry.Credential.AccessKey) == 0 || len(a.registry.Credential.AccessSecret) == 0 {
|
||||||
|
return errors.New("no credential ")
|
||||||
|
}
|
||||||
|
cred := credentials.NewStaticCredentials(
|
||||||
|
a.registry.Credential.AccessKey,
|
||||||
|
a.registry.Credential.AccessSecret,
|
||||||
|
"")
|
||||||
|
if a.region == "" {
|
||||||
|
return errors.New("no region parsed")
|
||||||
|
}
|
||||||
|
config := &aws.Config{
|
||||||
|
Credentials: cred,
|
||||||
|
Region: &a.region,
|
||||||
|
HTTPClient: &http.Client{
|
||||||
|
Transport: registry.GetHTTPTransport(a.registry.Insecure),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if a.forceEndpoint != nil {
|
||||||
|
config.Endpoint = a.forceEndpoint
|
||||||
|
}
|
||||||
|
sess := session.Must(session.NewSession(config))
|
||||||
|
|
||||||
|
svc := awsecrapi.New(sess)
|
||||||
|
|
||||||
|
_, err := svc.BatchDeleteImage(&awsecrapi.BatchDeleteImageInput{
|
||||||
|
RepositoryName: &repository,
|
||||||
|
ImageIds: []*awsecrapi.ImageIdentifier{{ImageTag: &reference}},
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user