From ffe713cadc14854f039c29cc704baddb39f7a4f0 Mon Sep 17 00:00:00 2001 From: chris-malloy Date: Thu, 9 Jul 2020 15:54:34 -0400 Subject: [PATCH] Adding policy text to ecr_repository model. --- lib/awspec/helper/finder/ecr.rb | 4 ++++ lib/awspec/type/ecr_repository.rb | 4 ++++ spec/type/ecr_repository_spec.rb | 1 + 3 files changed, 9 insertions(+) diff --git a/lib/awspec/helper/finder/ecr.rb b/lib/awspec/helper/finder/ecr.rb index 1a62663d7..f01465e95 100644 --- a/lib/awspec/helper/finder/ecr.rb +++ b/lib/awspec/helper/finder/ecr.rb @@ -5,6 +5,10 @@ def find_ecr_repository(repository_name) res = ecr_client.describe_repositories(repository_names: [repository_name]) res.repositories.first if res.repositories.count == 1 end + + def get_policy_text(repository_name) + res = ecr_client.get_repository_policy(repository_name: repository_name)[:policy_text] + end end end end diff --git a/lib/awspec/type/ecr_repository.rb b/lib/awspec/type/ecr_repository.rb index c45d0f678..ecf5c9b0b 100644 --- a/lib/awspec/type/ecr_repository.rb +++ b/lib/awspec/type/ecr_repository.rb @@ -14,5 +14,9 @@ def resource_via_client def id @id ||= resource_via_client.repository_name if resource_via_client end + + def policy_text + @policy_text ||= get_policy_text(@display_name) + end end end diff --git a/spec/type/ecr_repository_spec.rb b/spec/type/ecr_repository_spec.rb index a22ae9739..be6f59dcc 100644 --- a/spec/type/ecr_repository_spec.rb +++ b/spec/type/ecr_repository_spec.rb @@ -7,4 +7,5 @@ its(:registry_id) { should eq '123456789012' } its(:repository_name) { should eq 'my-ecr-repository' } its(:repository_arn) { should eq 'arn:aws:ecr:us-east-1:123456789012:repository/my-ecr-repository' } + its(:policy_text) { should eq 'RepositoryPolicyText' } end