plugins/aws_ecr/lib/samson_aws_ecr/samson_plugin.rb
# aws credentials are only valid for a limited time, so we need to refresh them before pushing
aws credentials are only valid for a limited time, so we need to refresh them before pushing
aws credentials are only valid for a limited time so we need to refresh them before pushing
def refresh_credentials
        DockerRegistry.all.each do |registry|
          next if registry.credentials_expire_at&.> 1.hour.from_now
          next unless client = ecr_client(registry)
          authorization_data = client.get_authorization_token.authorization_data.first
          username, password = Base64.decode64(authorization_data.authorization_token).split(":", 2)
          registry.username = username
          registry.password = password
          registry.credentials_expire_at = authorization_data.expires_at || raise("NO EXPIRE FOUND")
        end
      rescue Aws::ECR::Errors::InvalidSignatureException
        raise Samson::Hooks::UserError, "Invalid AWS credentials"
      end
def refresh_credentials DockerRegistry . all . each do | registry | next if registry . credentials_expire_at &. > 1 . hour . from_now next unless client = ecr_client ( registry ) authorization_data = client . get_authorization_token . authorization_data . first username , password = Base64 . decode64 ( authorization_data . authorization_token ) . split ( ":" , 2 ) registry . username = username registry . password = password registry . credentials_expire_at = authorization_data . expires_at || raise ( "NO EXPIRE FOUND" ) end rescue Aws :: ECR :: Errors :: InvalidSignatureException raise Samson :: Hooks :: UserError , "Invalid AWS credentials" end
aws credentials are only valid for a limited time, so we need to refresh them before pushing
aws credentials are only valid for a limited time so we need to refresh them before pushing