1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(registry) EE-806 add support for AWS ECR (#6165)

* feat(ecr) EE-806 add support for aws ecr

* feat(ecr) EE-806 fix wrong doc for Ecr Region

Co-authored-by: Simon Meng <simon.meng@portainer.io>
This commit is contained in:
cong meng 2021-12-01 13:18:57 +13:00 committed by GitHub
parent ff6185cc81
commit a86c7046df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 694 additions and 51 deletions

View file

@ -0,0 +1,49 @@
package registryutils
import (
portainer "github.com/portainer/portainer/api"
)
func isRegistryAssignedToNamespace(registry portainer.Registry, endpointID portainer.EndpointID, namespace string) (in bool){
for _, ns := range registry.RegistryAccesses[endpointID].Namespaces {
if ns == namespace {
return true
}
}
return
}
func RefreshEcrSecret(cli portainer.KubeClient, endpoint *portainer.Endpoint, dataStore portainer.DataStore, namespace string) (err error) {
registries, err := dataStore.Registry().Registries()
if err != nil {
return
}
for _, registry := range registries {
if registry.Type != portainer.EcrRegistry {
continue
}
if !isRegistryAssignedToNamespace(registry, endpoint.ID, namespace) {
continue
}
err = EnsureRegTokenValid(dataStore, &registry)
if err != nil {
return
}
err = cli.DeleteRegistrySecret(&registry, namespace)
if err != nil {
return
}
err = cli.CreateRegistrySecret(&registry, namespace)
if err != nil {
return
}
}
return
}