Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds exclude_projects option to exclude any global project #491

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/fog/compute/google.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Google < Fog::Service
:google_client,
:google_client_options,
:google_extra_global_projects,
:google_exclude_projects,
:google_key_location,
:google_key_string,
:google_json_key_location,
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/compute/google/mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ module Compute
class Google
class Mock
include Fog::Google::Shared
attr_reader :extra_global_projects
attr_reader :extra_global_projects, :exclude_projects

def initialize(options)
shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOGLE_COMPUTE_BASE_URL)
@extra_global_projects = options.fetch(:google_extra_global_projects, [])
@exclude_projects = options.fetch(:google_exclude_projects, [])
end

def self.data(api_version)
Expand Down
6 changes: 5 additions & 1 deletion lib/fog/compute/google/models/images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ def get_from_family(family, project = nil)

def all_projects
# Search own project before global projects
[service.project] + GLOBAL_PROJECTS + service.extra_global_projects
project_list = [service.project] + GLOBAL_PROJECTS + service.extra_global_projects
unless service.exclude_projects.empty?
project_list.delete_if { |project| service.exclude_projects.include?(project) }
end
project_list
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/compute/google/real.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Real
include Fog::Google::Shared

attr_accessor :client
attr_reader :compute, :extra_global_projects
attr_reader :compute, :extra_global_projects, :exclude_projects

def initialize(options)
shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOGLE_COMPUTE_BASE_URL)
Expand All @@ -16,6 +16,7 @@ def initialize(options)
apply_client_options(@compute, options)

@extra_global_projects = options[:google_extra_global_projects] || []
@exclude_projects = options[:google_exclude_projects] || []
end
end
end
Expand Down