diff --git a/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/empty_state.vue b/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/empty_state.vue index 3a672e4a23fbc667b7ac9753998478d899e5f810..7de85f1551793aec851e2f4a4315d2983d4e90ee 100644 --- a/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/empty_state.vue +++ b/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/empty_state.vue @@ -27,13 +27,13 @@ export default { <template> <gl-empty-state :svg-path="$options.EmptyAdminAppsSvg" - :title="s__('GoogleCloudPlatformService|Connect to Google Cloud')" + :title="s__('GoogleCloud|Connect to Google Cloud')" > <template #description> <gl-sprintf :message=" s__( - 'GoogleCloudPlatformService|Connect to Google Cloud with workload identity federation. Select %{strongStart}Guided setup%{strongEnd} if you can manage workload identity federation in Google Cloud. %{linkStart}What are the required permissions?%{linkEnd}', + 'GoogleCloud|Connect to Google Cloud with workload identity federation. Select %{strongStart}Guided setup%{strongEnd} if you can manage workload identity federation in Google Cloud. %{linkStart}What are the required permissions?%{linkEnd}', ) " > @@ -54,13 +54,13 @@ export default { <template #actions> <div class="gl-display-flex gl-gap-3"> <gl-button variant="confirm" @click="show($options.STATE_GUIDED)">{{ - s__('GoogleCloudPlatformService|Guided setup') + s__('GoogleCloud|Guided setup') }}</gl-button> <gl-button @click="show($options.STATE_MANUAL)">{{ - s__('GoogleCloudPlatformService|Manual setup') + s__('GoogleCloud|Manual setup') }}</gl-button> <invite-members-trigger - :display-text="s__('GoogleCloudPlatformService|Invite member to set up')" + :display-text="s__('GoogleCloud|Invite member to set up')" trigger-source="google_cloud_artifact_registry_setup" /> </div> diff --git a/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/form.vue b/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/form.vue index c9ebc0b9d6cd727ff6e6fcd66d5cd65cbaa6ccec..bd8e36498b7142dabbb115a9a145c8871eaadaf1 100644 --- a/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/form.vue +++ b/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/form.vue @@ -33,12 +33,12 @@ export default { <div> <connection /> - <h4 class="gl-mt-0">{{ s__('GoogleCloudPlatformService|Google Cloud project') }}</h4> + <h4 class="gl-mt-0">{{ s__('GoogleCloud|Google Cloud project') }}</h4> <p> <gl-sprintf :message=" s__( - 'GoogleCloudPlatformService|Identify the Google Cloud project with the workload identity pool and provider. %{linkStart}Where are my project ID and project number?%{linkEnd}', + 'GoogleCloud|Identify the Google Cloud project with the workload identity pool and provider. %{linkStart}Where are my project ID and project number?%{linkEnd}', ) " > @@ -59,11 +59,11 @@ export default { class="gl-border-b gl-mb-6 gl-sm-display-flex gl-flex-direction-row gl-gap-5" /> - <h4 class="gl-mt-0">{{ s__('GoogleCloudPlatformService|Workload identity federation') }}</h4> + <h4 class="gl-mt-0">{{ s__('GoogleCloud|Workload identity federation') }}</h4> <p> {{ s__( - 'GoogleCloudPlatformService|Connect to Google Cloud with workload identity federation for secure access without accounts or keys.', + 'GoogleCloud|Connect to Google Cloud with workload identity federation for secure access without accounts or keys.', ) }} </p> diff --git a/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/guided_setup.vue b/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/guided_setup.vue index e8286b4ddd1e51e189ea470b22d408ab64cedaec..6176df8d99d904948be4b2fe1a217d81db7cb8bc 100644 --- a/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/guided_setup.vue +++ b/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/guided_setup.vue @@ -34,12 +34,12 @@ curl --request GET \\ <template> <div> - <h3>{{ s__('GoogleCloudPlatformService|Guided setup') }}</h3> + <h3>{{ s__('GoogleCloud|Guided setup') }}</h3> <p> <gl-sprintf :message=" s__( - 'GoogleCloudPlatformService|%{linkStart}Switch to the manual setup%{linkEnd} if you cannot manage workload identity federation in Google Cloud. %{link2Start}What are the required permissions?%{link2End}', + 'GoogleCloud|%{linkStart}Switch to the manual setup%{linkEnd} if you cannot manage workload identity federation in Google Cloud. %{link2Start}What are the required permissions?%{link2End}', ) " > @@ -59,13 +59,11 @@ curl --request GET \\ </gl-sprintf> </p> - <h4>{{ s__('GoogleCloudPlatformService|Instructions') }}</h4> + <h4>{{ s__('GoogleCloud|Instructions') }}</h4> <p> <gl-sprintf :message=" - s__( - 'GoogleCloudPlatformService|Before you begin, %{linkStart}install the Google Cloud CLI%{linkEnd}.', - ) + s__('GoogleCloud|Before you begin, %{linkStart}install the Google Cloud CLI%{linkEnd}.') " > <template #link="{ content }"> @@ -82,7 +80,7 @@ curl --request GET \\ <p> {{ s__( - 'GoogleCloudPlatformService|Run the following command to set up and connect to your Google Cloud project with workload identity federation.', + 'GoogleCloud|Run the following command to set up and connect to your Google Cloud project with workload identity federation.', ) }} </p> @@ -91,7 +89,7 @@ curl --request GET \\ <gl-sprintf :message=" s__( - 'GoogleCloudPlatformService|Replace %{codeStart}your_access_token%{codeEnd} with a %{linkStart}new personal access token%{linkEnd} with the %{strongStart}api%{strongEnd} scope. This token sets up your Google Cloud IAM integration in GitLab.', + 'GoogleCloud|Replace %{codeStart}your_access_token%{codeEnd} with a %{linkStart}new personal access token%{linkEnd} with the %{strongStart}api%{strongEnd} scope. This token sets up your Google Cloud IAM integration in GitLab.', ) " > @@ -112,7 +110,7 @@ curl --request GET \\ <gl-sprintf :message=" s__( - 'GoogleCloudPlatformService|Replace %{codeStart}your_google_cloud_project_id%{codeEnd} with your Google Cloud project ID. To improve security, use a dedicated project for identity management, separate from resources and CI/CD projects. %{linkStart}Where’s my project ID?%{linkEnd}', + 'GoogleCloud|Replace %{codeStart}your_google_cloud_project_id%{codeEnd} with your Google Cloud project ID. To improve security, use a dedicated project for identity management, separate from resources and CI/CD projects. %{linkStart}Where’s my project ID?%{linkEnd}', ) " > @@ -129,7 +127,7 @@ curl --request GET \\ </template> </gl-sprintf> </li> - <li>{{ s__('GoogleCloudPlatformService|You might be prompted to sign in to Google.') }}</li> + <li>{{ s__('GoogleCloud|You might be prompted to sign in to Google.') }}</li> </ul> <div class="position-relative"> <code-block-highlighted @@ -148,7 +146,7 @@ curl --request GET \\ <gl-sprintf :message=" s__( - 'GoogleCloudPlatformService|After Google Cloud workload identity federation has been set up, select %{strongStart}Continue%{strongEnd}.', + 'GoogleCloud|After Google Cloud workload identity federation has been set up, select %{strongStart}Continue%{strongEnd}.', ) " > diff --git a/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/manual_setup.vue b/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/manual_setup.vue index f70887a1f15f6d71264c29ebfa5e216ea76c1ed6..d85937e38c5d31e783dead29937376930e0378ec 100644 --- a/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/manual_setup.vue +++ b/ee/app/assets/javascripts/integrations/edit/components/google_cloud_iam/manual_setup.vue @@ -16,12 +16,12 @@ export default { <template> <div> - <h3>{{ s__('GoogleCloudPlatformService|Manual setup') }}</h3> + <h3>{{ s__('GoogleCloud|Manual setup') }}</h3> <p> <gl-sprintf :message=" s__( - 'GoogleCloudPlatformService|%{linkStart}Switch to the guided setup%{linkEnd} if you can manage workload identity federation in Google Cloud. %{link2Start}What are the required permissions?%{link2End}', + 'GoogleCloud|%{linkStart}Switch to the guided setup%{linkEnd} if you can manage workload identity federation in Google Cloud. %{link2Start}What are the required permissions?%{link2End}', ) " > @@ -40,13 +40,13 @@ export default { </template> </gl-sprintf> </p> - <h4>{{ s__('GoogleCloudPlatformService|Instructions') }}</h4> + <h4>{{ s__('GoogleCloud|Instructions') }}</h4> <ol> <li> <gl-sprintf :message=" s__( - 'GoogleCloudPlatformService|Share the following information with someone that can manage Google Cloud workload identity federation. Or %{linkStart}invite them%{linkEnd} to set up.', + 'GoogleCloud|Share the following information with someone that can manage Google Cloud workload identity federation. Or %{linkStart}invite them%{linkEnd} to set up.', ) " > @@ -63,21 +63,19 @@ export default { </li> <ol type="a"> <li> - {{ s__('GoogleCloudPlatformService|The setup instructions page') }} + {{ s__('GoogleCloud|The setup instructions page') }} </li> <li> - {{ s__('GoogleCloudPlatformService|Your GitLab project ID') }} + {{ s__('GoogleCloud|Your GitLab project ID') }} </li> <li> - {{ - s__('GoogleCloudPlatformService|Your workload identify federation (WLIF) issuer URL.') - }} + {{ s__('GoogleCloud|Your workload identify federation (WLIF) issuer URL.') }} </li> </ol> <li> {{ s__( - 'GoogleCloudPlatformService|After Google Cloud workload identity federation has been set up, enter the details in the following form.', + 'GoogleCloud|After Google Cloud workload identity federation has been set up, enter the details in the following form.', ) }} </li> diff --git a/ee/app/graphql/resolvers/google_cloud/artifact_registry/artifact_resolver.rb b/ee/app/graphql/resolvers/google_cloud/artifact_registry/artifact_resolver.rb index 9999cb7c0b5785e3dbfe5d73e0df6c8a661e7bd2..e603af2dabe7ad11eb52d8485e91bab17eb5f948 100644 --- a/ee/app/graphql/resolvers/google_cloud/artifact_registry/artifact_resolver.rb +++ b/ee/app/graphql/resolvers/google_cloud/artifact_registry/artifact_resolver.rb @@ -7,7 +7,7 @@ class ArtifactResolver < BaseResolver include Gitlab::Graphql::Authorize::AuthorizeResource NO_ARTIFACT_REGISTRY_INTEGRATION_MESSAGE = - ::GoogleCloudPlatform::ArtifactRegistry::GetDockerImageService::ERROR_RESPONSES[ + ::GoogleCloud::ArtifactRegistry::GetDockerImageService::ERROR_RESPONSES[ :no_artifact_registry_integration ].message @@ -48,7 +48,7 @@ def ready?(google_cloud_project_id:, location:, repository:, image:, project_pat field: :artifact_registry_project_id, value: google_cloud_project_id, argument: :googleCloudProjectId, - field_title: s_('GoogleCloudPlatformService|Google Cloud project ID') + field_title: s_('GoogleCloud|Google Cloud project ID') ) validate_on_integration( @@ -56,7 +56,7 @@ def ready?(google_cloud_project_id:, location:, repository:, image:, project_pat field: :artifact_registry_location, value: location, argument: :location, - field_title: s_('GoogleCloudPlatformService|Repository location') + field_title: s_('GoogleCloud|Repository location') ) validate_on_integration( @@ -64,7 +64,7 @@ def ready?(google_cloud_project_id:, location:, repository:, image:, project_pat field: :artifact_registry_repository, value: repository, argument: :repository, - field_title: s_('GoogleCloudPlatformService|Repository name') + field_title: s_('GoogleCloud|Repository name') ) super @@ -74,7 +74,7 @@ def resolve(google_cloud_project_id:, location:, repository:, image:, project_pa name = "projects/#{google_cloud_project_id}/locations/#{location}/repositories/#{repository}/" \ "dockerImages/#{image}" - response = ::GoogleCloudPlatform::ArtifactRegistry::GetDockerImageService.new( + response = ::GoogleCloud::ArtifactRegistry::GetDockerImageService.new( current_user: current_user, project: find_project!(project_path), params: { diff --git a/ee/app/graphql/resolvers/google_cloud/artifact_registry/repository_artifacts_resolver.rb b/ee/app/graphql/resolvers/google_cloud/artifact_registry/repository_artifacts_resolver.rb index 566c09e6beefde7ed9b29b4ba9b334d9c09b93d6..54549de0c9e500cffbfbfd25f83d36b1d996642d 100644 --- a/ee/app/graphql/resolvers/google_cloud/artifact_registry/repository_artifacts_resolver.rb +++ b/ee/app/graphql/resolvers/google_cloud/artifact_registry/repository_artifacts_resolver.rb @@ -30,7 +30,7 @@ def resolve(first: nil, last: nil, before: nil, after: nil, sort: nil) # rubocop private def list_docker_images_service(params) - ::GoogleCloudPlatform::ArtifactRegistry::ListDockerImagesService.new( + ::GoogleCloud::ArtifactRegistry::ListDockerImagesService.new( project: project, current_user: current_user, params: { diff --git a/ee/app/models/integrations/google_cloud_platform/artifact_registry.rb b/ee/app/models/integrations/google_cloud_platform/artifact_registry.rb index 2819d54d270c7de98f61221cc39eed1f9149c0bc..c1c656cd50a839620f5a0d98ab38d7963c9eda43 100644 --- a/ee/app/models/integrations/google_cloud_platform/artifact_registry.rb +++ b/ee/app/models/integrations/google_cloud_platform/artifact_registry.rb @@ -30,20 +30,20 @@ class ArtifactRegistry < Integration field :artifact_registry_project_id, required: true, section: SECTION_TYPE_CONFIGURATION, - title: -> { s_('GoogleCloudPlatformService|Google Cloud project ID') }, - label_description: -> { s_('GoogleCloudPlatformService|Project with the Artifact Registry repository.') }, + title: -> { s_('GoogleCloud|Google Cloud project ID') }, + label_description: -> { s_('GoogleCloud|Project with the Artifact Registry repository.') }, help: -> { artifact_registry_project_id_help } field :artifact_registry_repositories, required: true, section: SECTION_TYPE_CONFIGURATION, - title: -> { s_('GoogleCloudPlatformService|Repository name') }, - help: -> { s_('GoogleCloudPlatformService|Repository must be Docker format and Standard mode.') } + title: -> { s_('GoogleCloud|Repository name') }, + help: -> { s_('GoogleCloud|Repository must be Docker format and Standard mode.') } field :artifact_registry_location, required: true, section: SECTION_TYPE_CONFIGURATION, - title: -> { s_('GoogleCloudPlatformService|Repository location') } + title: -> { s_('GoogleCloud|Repository location') } alias_method :artifact_registry_repository, :artifact_registry_repositories @@ -52,7 +52,7 @@ def self.title end def self.description - s_('GoogleCloudPlatformService|Manage your artifacts in Google Artifact Registry.') + s_('GoogleCloud|Manage your artifacts in Google Artifact Registry.') end def self.to_param @@ -105,7 +105,7 @@ def self.artifact_registry_project_id_help url = 'https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects' format( - s_('GoogleCloudPlatformService|To improve security, use a dedicated project for resources, separate from ' \ + s_('GoogleCloud|To improve security, use a dedicated project for resources, separate from ' \ 'CI/CD and identity management projects. %{link_start}Where’s my project ID? %{icon}%{link_end}'), link_start: format('<a target="_blank" rel="noopener noreferrer" href="%{url}">', url: url).html_safe, # rubocop:disable Rails/OutputSafety -- It is fine to call html_safe here link_end: '</a>'.html_safe, @@ -114,7 +114,7 @@ def self.artifact_registry_project_id_help end def test(data) - response = ::GoogleCloudPlatform::ArtifactRegistry::GetRepositoryService # rubocop:disable CodeReuse/ServiceClass -- the implementation is tied to existing strategy of testing an integration + response = ::GoogleCloud::ArtifactRegistry::GetRepositoryService # rubocop:disable CodeReuse/ServiceClass -- the implementation is tied to existing strategy of testing an integration .new(project: project, current_user: data[:current_user]).execute { success: response.success?, result: response.message } diff --git a/ee/app/models/integrations/google_cloud_platform/workload_identity_federation.rb b/ee/app/models/integrations/google_cloud_platform/workload_identity_federation.rb index 1e50197b0d422bfa1a549e3b925d969b38bdafc3..5c0426641cf49f7058b046f5ac41f42d0a74f8d5 100644 --- a/ee/app/models/integrations/google_cloud_platform/workload_identity_federation.rb +++ b/ee/app/models/integrations/google_cloud_platform/workload_identity_federation.rb @@ -31,13 +31,13 @@ class WorkloadIdentityFederation < Integration field :workload_identity_federation_project_id, required: true, section: SECTION_TYPE_CONFIGURATION, - title: -> { s_('GoogleCloudPlatformService|Project ID') }, + title: -> { s_('GoogleCloud|Project ID') }, description: -> { - s_('GoogleCloudPlatformService|Google Cloud project ID for the Workload Identity Federation.') + s_('GoogleCloud|Google Cloud project ID for the Workload Identity Federation.') }, help: -> { format( - s_('GoogleCloudPlatformService|Example: %{code_open}my-sample-project-191923%{code_close}'), + s_('GoogleCloud|Example: %{code_open}my-sample-project-191923%{code_close}'), { code_open: '<code>', code_close: '</code>' @@ -48,13 +48,13 @@ class WorkloadIdentityFederation < Integration field :workload_identity_federation_project_number, required: true, section: SECTION_TYPE_CONFIGURATION, - title: -> { s_('GoogleCloudPlatformService|Project number') }, + title: -> { s_('GoogleCloud|Project number') }, description: -> { - s_('GoogleCloudPlatformService|Google Cloud project number for the Workload Identity Federation.') + s_('GoogleCloud|Google Cloud project number for the Workload Identity Federation.') }, help: -> { format( - s_('GoogleCloudPlatformService|Example: %{code_open}314053285323%{code_close}'), + s_('GoogleCloud|Example: %{code_open}314053285323%{code_close}'), { code_open: '<code>', code_close: '</code>' @@ -65,24 +65,21 @@ class WorkloadIdentityFederation < Integration field :workload_identity_pool_id, required: true, section: SECTION_TYPE_CONFIGURATION, - title: -> { s_('GoogleCloudPlatformService|Pool ID') }, - description: -> { s_('GoogleCloudPlatformService|ID of the Workload Identity Pool.') } + title: -> { s_('GoogleCloud|Pool ID') }, + description: -> { s_('GoogleCloud|ID of the Workload Identity Pool.') } field :workload_identity_pool_provider_id, required: true, section: SECTION_TYPE_CONFIGURATION, - title: -> { s_('GoogleCloudPlatformService|Provider ID') }, - description: -> { s_('GoogleCloudPlatformService|ID of the Workload Identity Pool provider.') } + title: -> { s_('GoogleCloud|Provider ID') }, + description: -> { s_('GoogleCloud|ID of the Workload Identity Pool provider.') } def self.title - s_('GoogleCloudPlatformService|Google Cloud IAM') + s_('GoogleCloud|Google Cloud IAM') end def self.description - s_( - 'GoogleCloudPlatformService|' \ - 'Manage permissions for Google Cloud resources with Identity and Access Management (IAM).' - ) + s_('GoogleCloud|Manage permissions for Google Cloud resources with Identity and Access Management (IAM).') end def self.to_param @@ -102,7 +99,7 @@ def self.supported_events end def self.wlif_issuer_url(group_or_project) - "#{::GoogleCloudPlatform.glgo_base_url}/oidc/#{group_or_project.root_ancestor.path}" + "#{::GoogleCloud.glgo_base_url}/oidc/#{group_or_project.root_ancestor.path}" end # used when setting up WLIF pools diff --git a/ee/app/services/google_cloud_platform/artifact_registry/base_project_service.rb b/ee/app/services/google_cloud/artifact_registry/base_project_service.rb similarity index 92% rename from ee/app/services/google_cloud_platform/artifact_registry/base_project_service.rb rename to ee/app/services/google_cloud/artifact_registry/base_project_service.rb index 8f546853d01f415323ac434d3e4d08d9a2b2df30..b2ef7468c7b896154ebe0effe6f5d21658df8fff 100644 --- a/ee/app/services/google_cloud_platform/artifact_registry/base_project_service.rb +++ b/ee/app/services/google_cloud/artifact_registry/base_project_service.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud module ArtifactRegistry class BaseProjectService < ::BaseProjectService ERROR_RESPONSES = { @@ -52,7 +52,7 @@ def allowed? end def client - ::GoogleCloudPlatform::ArtifactRegistry::Client.new(wlif_integration: wlif_integration, user: current_user) + ::GoogleCloud::ArtifactRegistry::Client.new(wlif_integration: wlif_integration, user: current_user) end def wlif_integration @@ -65,10 +65,10 @@ def artifact_registry_integration def handling_client_errors yield - rescue ::GoogleCloudPlatform::AuthenticationError => e + rescue ::GoogleCloud::AuthenticationError => e log_error_with_project_id(message: e.message) ERROR_RESPONSES[:authentication_error] - rescue ::GoogleCloudPlatform::ApiError => e + rescue ::GoogleCloud::ApiError => e log_error_with_project_id(message: e.message) ERROR_RESPONSES[:api_error] end diff --git a/ee/app/services/google_cloud_platform/artifact_registry/get_docker_image_service.rb b/ee/app/services/google_cloud/artifact_registry/get_docker_image_service.rb similarity index 78% rename from ee/app/services/google_cloud_platform/artifact_registry/get_docker_image_service.rb rename to ee/app/services/google_cloud/artifact_registry/get_docker_image_service.rb index 2f902e92babe0650e4f1b59637bb02aacf8be09d..0c90955711cff9a54b1e08c6b85d33a6f86e3c18 100644 --- a/ee/app/services/google_cloud_platform/artifact_registry/get_docker_image_service.rb +++ b/ee/app/services/google_cloud/artifact_registry/get_docker_image_service.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud module ArtifactRegistry - class GetDockerImageService < ::GoogleCloudPlatform::ArtifactRegistry::BaseProjectService + class GetDockerImageService < ::GoogleCloud::ArtifactRegistry::BaseProjectService NO_NAME_ERROR_RESPONSE = ServiceResponse.error(message: 'Name parameter is blank') private diff --git a/ee/app/services/google_cloud_platform/artifact_registry/get_repository_service.rb b/ee/app/services/google_cloud/artifact_registry/get_repository_service.rb similarity index 60% rename from ee/app/services/google_cloud_platform/artifact_registry/get_repository_service.rb rename to ee/app/services/google_cloud/artifact_registry/get_repository_service.rb index 88b3e2a381ab0294805119b64dfc8a1cdb2c79e2..821b7c6fcab86e03140e61428fb2c2015d57eb9d 100644 --- a/ee/app/services/google_cloud_platform/artifact_registry/get_repository_service.rb +++ b/ee/app/services/google_cloud/artifact_registry/get_repository_service.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud module ArtifactRegistry - class GetRepositoryService < ::GoogleCloudPlatform::ArtifactRegistry::BaseProjectService + class GetRepositoryService < ::GoogleCloud::ArtifactRegistry::BaseProjectService private def call_client diff --git a/ee/app/services/google_cloud_platform/artifact_registry/list_docker_images_service.rb b/ee/app/services/google_cloud/artifact_registry/list_docker_images_service.rb similarity index 91% rename from ee/app/services/google_cloud_platform/artifact_registry/list_docker_images_service.rb rename to ee/app/services/google_cloud/artifact_registry/list_docker_images_service.rb index f72a55b740c2fd5e600ed9b5f83a25e0d4407ec4..83946ec735e5d6270118115295cdf97e2603b7e4 100644 --- a/ee/app/services/google_cloud_platform/artifact_registry/list_docker_images_service.rb +++ b/ee/app/services/google_cloud/artifact_registry/list_docker_images_service.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud module ArtifactRegistry - class ListDockerImagesService < ::GoogleCloudPlatform::ArtifactRegistry::BaseProjectService + class ListDockerImagesService < ::GoogleCloud::ArtifactRegistry::BaseProjectService VALID_ORDER_BY_COLUMNS = %w[name image_size_bytes upload_time build_time update_time media_type].freeze VALID_ORDER_BY_DIRECTIONS = %w[asc desc].freeze diff --git a/ee/app/services/google_cloud_platform/compute/base_service.rb b/ee/app/services/google_cloud/compute/base_service.rb similarity index 95% rename from ee/app/services/google_cloud_platform/compute/base_service.rb rename to ee/app/services/google_cloud/compute/base_service.rb index 99721bc4b6a7a889fecbdff0ee63d2974e7258a7..710d4b134dd39f160545a3a4b06e8878422ba15a 100644 --- a/ee/app/services/google_cloud_platform/compute/base_service.rb +++ b/ee/app/services/google_cloud/compute/base_service.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud module Compute class BaseService < ::BaseContainerService VALID_ORDER_BY_COLUMNS = %w[creationTimestamp name].freeze @@ -69,7 +69,7 @@ def valid_order_by?(value) end def client - ::GoogleCloudPlatform::Compute::Client.new( + ::GoogleCloud::Compute::Client.new( wlif_integration: wlif_integration, user: current_user, params: params.slice(:google_cloud_project_id).compact @@ -99,10 +99,10 @@ def page_token def handling_client_errors yield - rescue ::GoogleCloudPlatform::AuthenticationError => e + rescue ::GoogleCloud::AuthenticationError => e log_error_with_container_id(message: e.message) ERROR_RESPONSES[:google_cloud_authentication_error] - rescue ::GoogleCloudPlatform::ApiError => e + rescue ::GoogleCloud::ApiError => e log_error_with_container_id(message: e.message) ServiceResponse.error(message: "#{GCP_API_ERROR_MESSAGE}: #{e.message}") end diff --git a/ee/app/services/google_cloud_platform/compute/list_machine_types_service.rb b/ee/app/services/google_cloud/compute/list_machine_types_service.rb similarity index 89% rename from ee/app/services/google_cloud_platform/compute/list_machine_types_service.rb rename to ee/app/services/google_cloud/compute/list_machine_types_service.rb index 85769540e15e2405c518378d43c31bebf4eec6b8..6c898d90d5cddc60e87a0296c9738d33d9189a3b 100644 --- a/ee/app/services/google_cloud_platform/compute/list_machine_types_service.rb +++ b/ee/app/services/google_cloud/compute/list_machine_types_service.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud module Compute - class ListMachineTypesService < ::GoogleCloudPlatform::Compute::BaseService + class ListMachineTypesService < ::GoogleCloud::Compute::BaseService MISSING_ZONE_ERROR_RESPONSE = ServiceResponse.error(message: 'Zone value must be provided').freeze def initialize(container:, current_user:, zone:, params: {}) diff --git a/ee/app/services/google_cloud_platform/compute/list_regions_service.rb b/ee/app/services/google_cloud/compute/list_regions_service.rb similarity index 80% rename from ee/app/services/google_cloud_platform/compute/list_regions_service.rb rename to ee/app/services/google_cloud/compute/list_regions_service.rb index 30b29acd5b4494b1b9fdf03d29f2bdbd65ad8179..70424cc845ba58d4fbac150185ffacd27e5700d3 100644 --- a/ee/app/services/google_cloud_platform/compute/list_regions_service.rb +++ b/ee/app/services/google_cloud/compute/list_regions_service.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud module Compute - class ListRegionsService < ::GoogleCloudPlatform::Compute::BaseService + class ListRegionsService < ::GoogleCloud::Compute::BaseService private def call_client diff --git a/ee/app/services/google_cloud_platform/compute/list_zones_service.rb b/ee/app/services/google_cloud/compute/list_zones_service.rb similarity index 80% rename from ee/app/services/google_cloud_platform/compute/list_zones_service.rb rename to ee/app/services/google_cloud/compute/list_zones_service.rb index a3934c3aa73e685e0c3e629f357ae494b80fd89b..8184c72ee84962d3ceb6c46a7835faef48409956 100644 --- a/ee/app/services/google_cloud_platform/compute/list_zones_service.rb +++ b/ee/app/services/google_cloud/compute/list_zones_service.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud module Compute - class ListZonesService < ::GoogleCloudPlatform::Compute::BaseService + class ListZonesService < ::GoogleCloud::Compute::BaseService private def call_client diff --git a/ee/app/views/shared/integrations/google_cloud_platform_workload_identity_federation/_help.html.haml b/ee/app/views/shared/integrations/google_cloud_platform_workload_identity_federation/_help.html.haml index 768a15500b090277ed6a39083dea8b05f2a54306..9dec07a25d6c92f43d9bd132c43067086799ec9f 100644 --- a/ee/app/views/shared/integrations/google_cloud_platform_workload_identity_federation/_help.html.haml +++ b/ee/app/views/shared/integrations/google_cloud_platform_workload_identity_federation/_help.html.haml @@ -1,7 +1,7 @@ .info-well .well-segment %p.gl-font-weight-bold - = s_('GoogleCloudPlatformService|Manage permissions for Google Cloud resources with Identity and Access Management (IAM). Simplify and secure your usage, without the need to manage accounts or keys.') + = s_('GoogleCloud|Manage permissions for Google Cloud resources with Identity and Access Management (IAM). Simplify and secure your usage, without the need to manage accounts or keys.') %p - tag_pair_docs = tag_pair(link_to('', help_page_path('ci/gitlab_google_cloud_integration/index'), target: '_blank', rel: 'noopener noreferrer'), :link_start, :link_end) - = safe_format(s_('GoogleCloudPlatformService|%{link_start}Explore Google Cloud integration with GitLab%{link_end}, for CI/CD and more.'), tag_pair_docs) + = safe_format(s_('GoogleCloud|%{link_start}Explore Google Cloud integration with GitLab%{link_end}, for CI/CD and more.'), tag_pair_docs) diff --git a/ee/lib/audit_events/strategies/base_google_cloud_logging_destination_strategy.rb b/ee/lib/audit_events/strategies/base_google_cloud_logging_destination_strategy.rb index 2c63f50f369e0c8222d7a6d7f3baab1f8951f5f8..21549dc2455fc78405282c427d6bb07f5014ed7e 100644 --- a/ee/lib/audit_events/strategies/base_google_cloud_logging_destination_strategy.rb +++ b/ee/lib/audit_events/strategies/base_google_cloud_logging_destination_strategy.rb @@ -4,7 +4,7 @@ module AuditEvents module Strategies class BaseGoogleCloudLoggingDestinationStrategy < ExternalDestinationStrategy def initialize(audit_operation, audit_event) - @logger = GoogleCloud::LoggingService::Logger.new + @logger = AuditEvents::GoogleCloud::LoggingService::Logger.new super(audit_operation, audit_event) end diff --git a/ee/lib/ee/gitlab/ci/yaml_processor.rb b/ee/lib/ee/gitlab/ci/yaml_processor.rb index 87149f68333ebd943b75de9fd359cb32ff5843f4..5487fc3a6d770b18bb03d656bda5346eed34aa88 100644 --- a/ee/lib/ee/gitlab/ci/yaml_processor.rb +++ b/ee/lib/ee/gitlab/ci/yaml_processor.rb @@ -20,7 +20,7 @@ def validate_job_identity!(name, job) return if job[:identity].blank? unless google_cloud_support_saas_feature? - error!("#{name} job: #{s_('GoogleCloudPlatformService|The google_cloud_support feature is not available')}") + error!("#{name} job: #{s_('GoogleCloud|The google_cloud_support feature is not available')}") end unless google_cloud_support_feature_flag? @@ -30,13 +30,13 @@ def validate_job_identity!(name, job) integration = project.google_cloud_platform_workload_identity_federation_integration if integration.nil? - error!("#{name} job: #{s_('GoogleCloudPlatformService|The Google Cloud Identity and Access Management ' \ + error!("#{name} job: #{s_('GoogleCloud|The Google Cloud Identity and Access Management ' \ 'integration is not configured for this project')}") end return if integration.active? - error!("#{name} job: #{s_('GoogleCloudPlatformService|The Google Cloud Identity and Access Management ' \ + error!("#{name} job: #{s_('GoogleCloud|The Google Cloud Identity and Access Management ' \ 'integration is not enabled for this project')}") end diff --git a/ee/lib/gitlab/ci/google_cloud/generate_build_environment_variables_service.rb b/ee/lib/gitlab/ci/google_cloud/generate_build_environment_variables_service.rb index ea9fcc59f3a3eb409b9d7aef739e6ba5bab7dba3..cd027449fcd9a688df2d2be18c95f66e40253511 100644 --- a/ee/lib/gitlab/ci/google_cloud/generate_build_environment_variables_service.rb +++ b/ee/lib/gitlab/ci/google_cloud/generate_build_environment_variables_service.rb @@ -13,7 +13,7 @@ def initialize(build) def execute return [] unless @integration&.active - config_json = ::GoogleCloudPlatform.credentials( + config_json = ::GoogleCloud.credentials( identity_provider_resource_name: @integration.identity_provider_resource_name, encoded_jwt: encoded_jwt ).to_json @@ -30,7 +30,7 @@ def execute def encoded_jwt JwtV2.for_build( @build, - aud: ::GoogleCloudPlatform::GLGO_BASE_URL, + aud: ::GoogleCloud::GLGO_BASE_URL, target_audience: @integration.identity_provider_resource_name ) end diff --git a/ee/lib/google_cloud_platform.rb b/ee/lib/google_cloud.rb similarity index 97% rename from ee/lib/google_cloud_platform.rb rename to ee/lib/google_cloud.rb index 3aaf984b0504c5c4e3e35b9cf5bca346a0887bef..c5c478ecb50df889a64034e84c58ff33d752a040 100644 --- a/ee/lib/google_cloud_platform.rb +++ b/ee/lib/google_cloud.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud GLGO_BASE_URL = if Gitlab.staging? 'https://glgo.staging.runway.gitlab.net' else diff --git a/ee/lib/google_cloud_platform/artifact_registry/client.rb b/ee/lib/google_cloud/artifact_registry/client.rb similarity index 90% rename from ee/lib/google_cloud_platform/artifact_registry/client.rb rename to ee/lib/google_cloud/artifact_registry/client.rb index e39bf5a8d5eece89a563254b1ed77882d64234f3..1efe00ca9ccc7e45154e546fee4f6ed9df6702f3 100644 --- a/ee/lib/google_cloud_platform/artifact_registry/client.rb +++ b/ee/lib/google_cloud/artifact_registry/client.rb @@ -2,9 +2,9 @@ require 'google/cloud/artifact_registry/v1' -module GoogleCloudPlatform +module GoogleCloud module ArtifactRegistry - class Client < ::GoogleCloudPlatform::BaseClient + class Client < ::GoogleCloud::BaseClient include Gitlab::Utils::StrongMemoize DEFAULT_PAGE_SIZE = 10 @@ -39,9 +39,9 @@ def initialize(wlif_integration:, user:) # # Possible exceptions: # - # +GoogleCloudPlatform::AuthenticationError+ if an error occurs during the + # +GoogleCloud::AuthenticationError+ if an error occurs during the # authentication. - # +GoogleCloudPlatform::ApiError+ if an error occurs when interacting with the + # +GoogleCloud::ApiError+ if an error occurs when interacting with the # Google Cloud API. def repository request = ::Google::Cloud::ArtifactRegistry::V1::GetRepositoryRequest.new(name: repository_full_name) @@ -73,9 +73,9 @@ def repository # # Possible exceptions: # - # +GoogleCloudPlatform::AuthenticationError+ if an error occurs during the + # +GoogleCloud::AuthenticationError+ if an error occurs during the # authentication. - # +GoogleCloudPlatform::ApiError+ if an error occurs when interacting with the + # +GoogleCloud::ApiError+ if an error occurs when interacting with the # Google Cloud API. def docker_images(page_size: nil, page_token: nil, order_by: nil) page_size = DEFAULT_PAGE_SIZE if page_size.blank? @@ -101,9 +101,9 @@ def docker_images(page_size: nil, page_token: nil, order_by: nil) # # Possible exceptions: # - # +GoogleCloudPlatform::AuthenticationError+ if an error occurs during the + # +GoogleCloud::AuthenticationError+ if an error occurs during the # authentication. - # +GoogleCloudPlatform::ApiError+ if an error occurs when interacting with the + # +GoogleCloud::ApiError+ if an error occurs when interacting with the # Google Cloud API. def docker_image(name:) request = ::Google::Cloud::ArtifactRegistry::V1::GetDockerImageRequest.new(name: name) diff --git a/ee/lib/google_cloud_platform/base_client.rb b/ee/lib/google_cloud/base_client.rb similarity index 92% rename from ee/lib/google_cloud_platform/base_client.rb rename to ee/lib/google_cloud/base_client.rb index fd9ca718dcdc812044037b556b7a981b218e60e0..4ab9e39cbbd8faca46acf008f928d629a2c54d31 100644 --- a/ee/lib/google_cloud_platform/base_client.rb +++ b/ee/lib/google_cloud/base_client.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud class BaseClient CLOUD_PLATFORM_SCOPE = 'https://www.googleapis.com/auth/cloud-platform' @@ -49,14 +49,14 @@ def initialize(wlif_integration:, user:, params: {}) delegate :identity_provider_resource_name, to: :wlif_integration, prefix: :google_cloud def credentials - ::GoogleCloudPlatform.credentials( + ::GoogleCloud.credentials( identity_provider_resource_name: google_cloud_identity_provider_resource_name, encoded_jwt: encoded_jwt ) end def encoded_jwt - jwt = ::GoogleCloudPlatform::Jwt.new( + jwt = ::GoogleCloud::Jwt.new( project: project, user: user, claims: { @@ -80,12 +80,12 @@ def handling_errors rescue RuntimeError => e if e.message.include?(GOOGLE_CLOUD_SUBJECT_TOKEN_ERROR_MESSAGE) || e.message.include?(GOOGLE_CLOUD_TOKEN_EXCHANGE_ERROR_MESSAGE) - raise ::GoogleCloudPlatform::AuthenticationError, e.message + raise ::GoogleCloud::AuthenticationError, e.message end raise rescue ::Google::Cloud::Error => e - raise ::GoogleCloudPlatform::ApiError, e.message + raise ::GoogleCloud::ApiError, e.message end end end diff --git a/ee/lib/google_cloud_platform/compute/client.rb b/ee/lib/google_cloud/compute/client.rb similarity index 91% rename from ee/lib/google_cloud_platform/compute/client.rb rename to ee/lib/google_cloud/compute/client.rb index 3e98aa75d03e7cfb216e51567577f836a77d48cf..43901c4c98e1d2c3f34cdf2494489870fff0500e 100644 --- a/ee/lib/google_cloud_platform/compute/client.rb +++ b/ee/lib/google_cloud/compute/client.rb @@ -2,9 +2,9 @@ require 'google/cloud/compute/v1' -module GoogleCloudPlatform +module GoogleCloud module Compute - class Client < ::GoogleCloudPlatform::BaseClient + class Client < ::GoogleCloud::BaseClient include Gitlab::Utils::StrongMemoize extend ::Gitlab::Utils::Override @@ -33,8 +33,8 @@ class Client < ::GoogleCloudPlatform::BaseClient # # Possible exceptions: # - # +GoogleCloudPlatform::AuthenticationError+ if an error occurs during the authentication. - # +GoogleCloudPlatform::ApiError+ if an error occurs when interacting with the + # +GoogleCloud::AuthenticationError+ if an error occurs during the authentication. + # +GoogleCloud::ApiError+ if an error occurs when interacting with the # Google Cloud API. def regions(filter: nil, max_results: 500, order_by: nil, page_token: nil) request = ::Google::Cloud::Compute::V1::ListRegionsRequest.new( @@ -72,8 +72,8 @@ def regions(filter: nil, max_results: 500, order_by: nil, page_token: nil) # # Possible exceptions: # - # +GoogleCloudPlatform::AuthenticationError+ if an error occurs during the authentication. - # +GoogleCloudPlatform::ApiError+ if an error occurs when interacting with the + # +GoogleCloud::AuthenticationError+ if an error occurs during the authentication. + # +GoogleCloud::ApiError+ if an error occurs when interacting with the # Google Cloud API. def zones(filter: nil, max_results: 500, order_by: nil, page_token: nil) request = ::Google::Cloud::Compute::V1::ListZonesRequest.new( @@ -112,8 +112,8 @@ def zones(filter: nil, max_results: 500, order_by: nil, page_token: nil) # # Possible exceptions: # - # +GoogleCloudPlatform::AuthenticationError+ if an error occurs during the authentication. - # +GoogleCloudPlatform::ApiError+ if an error occurs when interacting with the + # +GoogleCloud::AuthenticationError+ if an error occurs during the authentication. + # +GoogleCloud::ApiError+ if an error occurs when interacting with the # Google Cloud API. def machine_types(zone:, filter: nil, max_results: 500, order_by: nil, page_token: nil) request = ::Google::Cloud::Compute::V1::ListMachineTypesRequest.new( diff --git a/ee/lib/google_cloud_platform/jwt.rb b/ee/lib/google_cloud/jwt.rb similarity index 98% rename from ee/lib/google_cloud_platform/jwt.rb rename to ee/lib/google_cloud/jwt.rb index b12a9bba6ca32cc2124f0ef2a8d375ac52842ac1..2cf5b6d52fcf10f59dd161fa1ea3f3efabcdb6d3 100644 --- a/ee/lib/google_cloud_platform/jwt.rb +++ b/ee/lib/google_cloud/jwt.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module GoogleCloudPlatform +module GoogleCloud class Jwt < ::JSONWebToken::RSAToken extend ::Gitlab::Utils::Override diff --git a/ee/spec/features/groups/integrations/google_cloud_platform/user_activates_workload_identity_federation_spec.rb b/ee/spec/features/groups/integrations/google_cloud_platform/user_activates_workload_identity_federation_spec.rb index 6b21207b6d6c6b130cdc9d632492785464831ba6..60df6f98959973c86744a1ae7e4d6027482bbc13 100644 --- a/ee/spec/features/groups/integrations/google_cloud_platform/user_activates_workload_identity_federation_spec.rb +++ b/ee/spec/features/groups/integrations/google_cloud_platform/user_activates_workload_identity_federation_spec.rb @@ -13,19 +13,19 @@ it 'activates integration', :js do visit_group_integration(integration.title) - click_on s_('GoogleCloudPlatformService|Manual setup') + click_on s_('GoogleCloud|Manual setup') fill_in( - s_('GoogleCloudPlatformService|Project ID'), + s_('GoogleCloud|Project ID'), with: integration.workload_identity_federation_project_id) fill_in( - s_('GoogleCloudPlatformService|Project number'), + s_('GoogleCloud|Project number'), with: integration.workload_identity_federation_project_number) fill_in( - s_('GoogleCloudPlatformService|Pool ID'), + s_('GoogleCloud|Pool ID'), with: integration.workload_identity_pool_id) fill_in( - s_('GoogleCloudPlatformService|Provider ID'), + s_('GoogleCloud|Provider ID'), with: integration.workload_identity_pool_provider_id) click_save_integration diff --git a/ee/spec/features/projects/google_cloud/artifact_registry_spec.rb b/ee/spec/features/projects/google_cloud/artifact_registry_spec.rb index 10b367ebe87f8c70b60e751886b497512cb2a028..d79f8f77af6a8459b3cbf133ed95af9e04385620 100644 --- a/ee/spec/features/projects/google_cloud/artifact_registry_spec.rb +++ b/ee/spec/features/projects/google_cloud/artifact_registry_spec.rb @@ -22,11 +22,11 @@ let(:image) { 'ruby' } let(:digest) { 'sha256:4ca5c21b' } - let(:client_double) { instance_double('::GoogleCloudPlatform::ArtifactRegistry::Client') } + let(:client_double) { instance_double('::GoogleCloud::ArtifactRegistry::Client') } let(:page_token) { nil } let(:order_by) { 'update_time desc' } let(:page_size) { nil } - let(:default_page_size) { ::GoogleCloudPlatform::ArtifactRegistry::ListDockerImagesService::DEFAULT_PAGE_SIZE } + let(:default_page_size) { ::GoogleCloud::ArtifactRegistry::ListDockerImagesService::DEFAULT_PAGE_SIZE } let(:next_page_token) { 'next_page_token' } let(:name) do "projects/#{artifact_registry_integration.artifact_registry_project_id}/" \ @@ -56,7 +56,7 @@ before do stub_saas_features(google_cloud_support: true) - allow(::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new) + allow(::GoogleCloud::ArtifactRegistry::Client).to receive(:new) .with(wlif_integration: wlif_integration, user: user) .and_return(client_double) diff --git a/ee/spec/features/projects/integrations/google_cloud_platform/user_activates_artifact_management_spec.rb b/ee/spec/features/projects/integrations/google_cloud_platform/user_activates_artifact_management_spec.rb index 0b1e63c71e139b6d7c0511e20e3abd8f13ffb56a..d03f0b6c2927733f4ee5867e31388a6c5fc85efa 100644 --- a/ee/spec/features/projects/integrations/google_cloud_platform/user_activates_artifact_management_spec.rb +++ b/ee/spec/features/projects/integrations/google_cloud_platform/user_activates_artifact_management_spec.rb @@ -9,7 +9,7 @@ let_it_be(:group) { create(:group, projects: [project], parent: parent_group) } let(:integration) { build_stubbed(:google_cloud_platform_artifact_registry_integration) } - let(:client_double) { instance_double('::GoogleCloudPlatform::ArtifactRegistry::Client') } + let(:client_double) { instance_double('::GoogleCloud::ArtifactRegistry::Client') } before_all do parent_group.add_owner(user) @@ -18,7 +18,7 @@ before do stub_saas_features(google_cloud_support: true) - allow(::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new) + allow(::GoogleCloud::ArtifactRegistry::Client).to receive(:new) .with(wlif_integration: an_instance_of(::Integrations::GoogleCloudPlatform::WorkloadIdentityFederation), user: user) .and_return(client_double) @@ -34,11 +34,11 @@ expect(page).not_to have_link('View artifacts') - fill_in s_('GoogleCloudPlatformService|Google Cloud project ID'), + fill_in s_('GoogleCloud|Google Cloud project ID'), with: integration.artifact_registry_project_id - fill_in s_('GoogleCloudPlatformService|Repository location'), + fill_in s_('GoogleCloud|Repository location'), with: integration.artifact_registry_location - fill_in s_('GoogleCloudPlatformService|Repository name'), + fill_in s_('GoogleCloud|Repository name'), with: integration.artifact_registry_repositories click_test_then_save_integration(expect_test_to_fail: false) diff --git a/ee/spec/features/projects/integrations/google_cloud_platform/user_activates_workload_identity_federation_spec.rb b/ee/spec/features/projects/integrations/google_cloud_platform/user_activates_workload_identity_federation_spec.rb index 98cc0b5ebb400e847fcb98e12a5fdb54e9162cfa..bf1b5e5f3dd4d55408669dfbbdeda6fe9ef66092 100644 --- a/ee/spec/features/projects/integrations/google_cloud_platform/user_activates_workload_identity_federation_spec.rb +++ b/ee/spec/features/projects/integrations/google_cloud_platform/user_activates_workload_identity_federation_spec.rb @@ -13,19 +13,19 @@ it 'activates integration', :js do visit_project_integration(integration.title) - click_on s_('GoogleCloudPlatformService|Manual setup') + click_on s_('GoogleCloud|Manual setup') fill_in( - s_('GoogleCloudPlatformService|Project ID'), + s_('GoogleCloud|Project ID'), with: integration.workload_identity_federation_project_id) fill_in( - s_('GoogleCloudPlatformService|Project number'), + s_('GoogleCloud|Project number'), with: integration.workload_identity_federation_project_number) fill_in( - s_('GoogleCloudPlatformService|Pool ID'), + s_('GoogleCloud|Pool ID'), with: integration.workload_identity_pool_id) fill_in( - s_('GoogleCloudPlatformService|Provider ID'), + s_('GoogleCloud|Provider ID'), with: integration.workload_identity_pool_provider_id) click_save_integration diff --git a/ee/spec/lib/audit_events/external_destination_streamer_spec.rb b/ee/spec/lib/audit_events/external_destination_streamer_spec.rb index 6e1c6ced5e6df18bfa1bd99ac57af9947a88b6d1..509ad8ae158a7a035038cd0bfedfda41c724b15e 100644 --- a/ee/spec/lib/audit_events/external_destination_streamer_spec.rb +++ b/ee/spec/lib/audit_events/external_destination_streamer_spec.rb @@ -6,7 +6,7 @@ before do stub_licensed_features(external_audit_events: true) - allow_next_instance_of(::GoogleCloud::Authentication) do |instance| + allow_next_instance_of(::AuditEvents::GoogleCloud::Authentication) do |instance| allow(instance).to receive(:generate_access_token).and_return("sample-token") end end diff --git a/ee/spec/lib/gitlab/ci/yaml_processor_spec.rb b/ee/spec/lib/gitlab/ci/yaml_processor_spec.rb index 29f1647479586713d89c9da60484a6d27e1b71f0..387be9a7ce0a569531d906fcd898a248d7a0ce3c 100644 --- a/ee/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/ee/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -366,7 +366,7 @@ it 'returns error' do expect(result.errors).to include(a_string_including( - s_("GoogleCloudPlatformService|The google_cloud_support feature is not available"))) + s_("GoogleCloud|The google_cloud_support feature is not available"))) end end @@ -388,7 +388,7 @@ it 'returns error' do expect(result.errors).to include(a_string_including( - s_('GoogleCloudPlatformService|The Google Cloud Identity and Access Management integration is not ' \ + s_('GoogleCloud|The Google Cloud Identity and Access Management integration is not ' \ 'configured for this project'))) end end @@ -400,7 +400,7 @@ it 'returns error' do expect(result.errors).to include(a_string_including( - s_('GoogleCloudPlatformService|The Google Cloud Identity and Access Management integration is not enabled ' \ + s_('GoogleCloud|The Google Cloud Identity and Access Management integration is not enabled ' \ 'for this project'))) end end diff --git a/ee/spec/lib/google_cloud_platform/artifact_registry/client_spec.rb b/ee/spec/lib/google_cloud/artifact_registry/client_spec.rb similarity index 96% rename from ee/spec/lib/google_cloud_platform/artifact_registry/client_spec.rb rename to ee/spec/lib/google_cloud/artifact_registry/client_spec.rb index 6a30638aab05405fa1a0d276f39132f581154216..3a94c785dca35ffdbe68e97002019e9dc0c63fda 100644 --- a/ee/spec/lib/google_cloud_platform/artifact_registry/client_spec.rb +++ b/ee/spec/lib/google_cloud/artifact_registry/client_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform::ArtifactRegistry::Client, feature_category: :container_registry do +RSpec.describe GoogleCloud::ArtifactRegistry::Client, feature_category: :container_registry do let_it_be_with_reload(:project) { create(:project) } let_it_be(:rsa_key) { OpenSSL::PKey::RSA.generate(3072) } let_it_be(:rsa_key_data) { rsa_key.to_s } @@ -168,9 +168,9 @@ end def stub_authentication_requests - stub_request(:get, ::GoogleCloudPlatform::GLGO_TOKEN_ENDPOINT_URL) + stub_request(:get, ::GoogleCloud::GLGO_TOKEN_ENDPOINT_URL) .to_return(status: 200, body: ::Gitlab::Json.dump(token: 'token')) - stub_request(:post, ::GoogleCloudPlatform::STS_URL) + stub_request(:post, ::GoogleCloud::STS_URL) .to_return(status: 200, body: ::Gitlab::Json.dump(token: 'token')) end end diff --git a/ee/spec/lib/google_cloud_platform/compute/client_spec.rb b/ee/spec/lib/google_cloud/compute/client_spec.rb similarity index 97% rename from ee/spec/lib/google_cloud_platform/compute/client_spec.rb rename to ee/spec/lib/google_cloud/compute/client_spec.rb index 1e476cbf3ebe495aff388b6e5097ce75d2ea13b2..1c93813aa7e848e6d942f3c9bc9b57c86bbc88a1 100644 --- a/ee/spec/lib/google_cloud_platform/compute/client_spec.rb +++ b/ee/spec/lib/google_cloud/compute/client_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform::Compute::Client, feature_category: :fleet_visibility do +RSpec.describe GoogleCloud::Compute::Client, feature_category: :fleet_visibility do let_it_be(:project) { create(:project) } let_it_be(:rsa_key) { OpenSSL::PKey::RSA.generate(3072) } let_it_be(:rsa_key_data) { rsa_key.to_s } @@ -271,9 +271,9 @@ end def stub_authentication_requests - stub_request(:get, ::GoogleCloudPlatform::GLGO_TOKEN_ENDPOINT_URL) + stub_request(:get, ::GoogleCloud::GLGO_TOKEN_ENDPOINT_URL) .to_return(status: 200, body: ::Gitlab::Json.dump(token: 'token')) - stub_request(:post, ::GoogleCloudPlatform::STS_URL) + stub_request(:post, ::GoogleCloud::STS_URL) .to_return(status: 200, body: ::Gitlab::Json.dump(token: 'token')) end end diff --git a/ee/spec/lib/google_cloud_platform/jwt_spec.rb b/ee/spec/lib/google_cloud/jwt_spec.rb similarity index 97% rename from ee/spec/lib/google_cloud_platform/jwt_spec.rb rename to ee/spec/lib/google_cloud/jwt_spec.rb index 763b32ee9d193def27817f93fdb0ade5144766cf..1a08056c71527bda6a78f101e5704957742a0658 100644 --- a/ee/spec/lib/google_cloud_platform/jwt_spec.rb +++ b/ee/spec/lib/google_cloud/jwt_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform::Jwt, feature_category: :shared do +RSpec.describe GoogleCloud::Jwt, feature_category: :shared do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } diff --git a/ee/spec/lib/google_cloud_platform_spec.rb b/ee/spec/lib/google_cloud_spec.rb similarity index 91% rename from ee/spec/lib/google_cloud_platform_spec.rb rename to ee/spec/lib/google_cloud_spec.rb index 1cf395e055057c853cac212a959a3ef83596befb..a4f72480f5da85f33bb17227d5baffb35da9c797 100644 --- a/ee/spec/lib/google_cloud_platform_spec.rb +++ b/ee/spec/lib/google_cloud_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform, feature_category: :system_access do +RSpec.describe GoogleCloud, feature_category: :system_access do describe '.credentials' do subject(:credentials) do described_class.credentials( diff --git a/ee/spec/models/integrations/google_cloud_platform/artifact_registry_spec.rb b/ee/spec/models/integrations/google_cloud_platform/artifact_registry_spec.rb index ec41ab4d73be05985c75159f90a86c360264034d..8bde7f43caeb0e459b591cc4fdfffde0fdc89239 100644 --- a/ee/spec/models/integrations/google_cloud_platform/artifact_registry_spec.rb +++ b/ee/spec/models/integrations/google_cloud_platform/artifact_registry_spec.rb @@ -51,7 +51,7 @@ subject { described_class.description } it do - is_expected.to eq(s_('GoogleCloudPlatformService|Manage your artifacts in Google Artifact Registry.')) + is_expected.to eq(s_('GoogleCloud|Manage your artifacts in Google Artifact Registry.')) end end @@ -169,7 +169,7 @@ create(:google_cloud_platform_workload_identity_federation_integration, project: integration.project) end - let(:client_double) { instance_double('::GoogleCloudPlatform::ArtifactRegistry::Client') } + let(:client_double) { instance_double('::GoogleCloud::ArtifactRegistry::Client') } let(:user) { integration.project.first_owner } let(:data) { { current_user: user } } @@ -178,7 +178,7 @@ before do stub_saas_features(google_cloud_support: true) - allow(::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new) + allow(::GoogleCloud::ArtifactRegistry::Client).to receive(:new) .with(wlif_integration: wlif_integration, user: user).and_return(client_double) allow(client_double).to receive(:repository) @@ -190,7 +190,7 @@ context 'when the connection was not established' do before do allow(client_double).to receive(:repository) - .and_raise(::GoogleCloudPlatform::ApiError) + .and_raise(::GoogleCloud::ApiError) end it { is_expected.to eq(success: false, result: 'Unsuccessful Google Cloud API request') } diff --git a/ee/spec/models/integrations/google_cloud_platform/workload_identity_federation_spec.rb b/ee/spec/models/integrations/google_cloud_platform/workload_identity_federation_spec.rb index 7497e264cb564fbb4cd7ed3b229f4261894b48df..e88a871020b286bc176adc1d8fd442ea1c3fc327 100644 --- a/ee/spec/models/integrations/google_cloud_platform/workload_identity_federation_spec.rb +++ b/ee/spec/models/integrations/google_cloud_platform/workload_identity_federation_spec.rb @@ -47,7 +47,7 @@ describe '.title' do subject { described_class.title } - it { is_expected.to eq(s_('GoogleCloudPlatformService|Google Cloud IAM')) } + it { is_expected.to eq(s_('GoogleCloud|Google Cloud IAM')) } end describe '.description' do @@ -55,8 +55,7 @@ it do is_expected.to eq(s_( - 'GoogleCloudPlatformService|' \ - 'Manage permissions for Google Cloud resources with Identity and Access Management (IAM).' + 'GoogleCloud|Manage permissions for Google Cloud resources with Identity and Access Management (IAM).' )) end end diff --git a/ee/spec/requests/api/graphql/google_cloud/artifact_registry/docker_image_spec.rb b/ee/spec/requests/api/graphql/google_cloud/artifact_registry/docker_image_spec.rb index 527a5eef21bf0f7bd368c02dad072c483095dcba..ac1acea105ba9982a71659cb901841bd24ce57d5 100644 --- a/ee/spec/requests/api/graphql/google_cloud/artifact_registry/docker_image_spec.rb +++ b/ee/spec/requests/api/graphql/google_cloud/artifact_registry/docker_image_spec.rb @@ -27,7 +27,7 @@ let(:repository) { artifact_registry_integration.artifact_registry_repository } let(:image) { 'ruby' } let(:digest) { 'sha256:4ca5c21b' } - let(:client_double) { instance_double('::GoogleCloudPlatform::ArtifactRegistry::Client') } + let(:client_double) { instance_double('::GoogleCloud::ArtifactRegistry::Client') } let(:uri) do "#{location}-docker.pkg.dev/#{google_cloud_project_id}/" \ @@ -85,7 +85,7 @@ before do stub_saas_features(google_cloud_support: true) - allow(::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new) + allow(::GoogleCloud::ArtifactRegistry::Client).to receive(:new) .with(wlif_integration: wlif_integration, user: user) .and_return(client_double) diff --git a/ee/spec/requests/api/graphql/project/google_cloud/artifact_registry/docker_images_spec.rb b/ee/spec/requests/api/graphql/project/google_cloud/artifact_registry/docker_images_spec.rb index 11f51c5da533c5be67e2ca977f2687da90d0c5c0..8a03106ea1a1440686ab35569109d9884c4d32d4 100644 --- a/ee/spec/requests/api/graphql/project/google_cloud/artifact_registry/docker_images_spec.rb +++ b/ee/spec/requests/api/graphql/project/google_cloud/artifact_registry/docker_images_spec.rb @@ -25,11 +25,11 @@ let(:user) { project.first_owner } let(:image) { 'ruby' } let(:digest) { 'sha256:4ca5c21b' } - let(:client_double) { instance_double('::GoogleCloudPlatform::ArtifactRegistry::Client') } + let(:client_double) { instance_double('::GoogleCloud::ArtifactRegistry::Client') } let(:page_token) { nil } let(:order_by) { nil } let(:page_size) { nil } - let(:default_page_size) { ::GoogleCloudPlatform::ArtifactRegistry::ListDockerImagesService::DEFAULT_PAGE_SIZE } + let(:default_page_size) { ::GoogleCloud::ArtifactRegistry::ListDockerImagesService::DEFAULT_PAGE_SIZE } let(:next_page_token) { 'next_page_token' } let(:docker_image) do @@ -92,7 +92,7 @@ before do stub_saas_features(google_cloud_support: true) - allow(::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new) + allow(::GoogleCloud::ArtifactRegistry::Client).to receive(:new) .with(wlif_integration: wlif_integration, user: user ).and_return(client_double) diff --git a/ee/spec/services/ee/integrations/test/project_service_spec.rb b/ee/spec/services/ee/integrations/test/project_service_spec.rb index 05ac13267702e3fda6beb82cb1abbd7a793e6029..d0315195bf5a2201aac372f52f08516b055a1607 100644 --- a/ee/spec/services/ee/integrations/test/project_service_spec.rb +++ b/ee/spec/services/ee/integrations/test/project_service_spec.rb @@ -27,12 +27,12 @@ create(:google_cloud_platform_workload_identity_federation_integration, project: project) end - let(:client_double) { instance_double('::GoogleCloudPlatform::ArtifactRegistry::Client') } + let(:client_double) { instance_double('::GoogleCloud::ArtifactRegistry::Client') } before do stub_saas_features(google_cloud_support: true) - allow(::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new) + allow(::GoogleCloud::ArtifactRegistry::Client).to receive(:new) .with(wlif_integration: wlif_integration, user: user).and_return(client_double) allow(client_double).to receive(:repository) diff --git a/ee/spec/services/google_cloud_platform/artifact_registry/get_docker_image_service_spec.rb b/ee/spec/services/google_cloud/artifact_registry/get_docker_image_service_spec.rb similarity index 91% rename from ee/spec/services/google_cloud_platform/artifact_registry/get_docker_image_service_spec.rb rename to ee/spec/services/google_cloud/artifact_registry/get_docker_image_service_spec.rb index 5588f01564c84c8b0f95f05125c47bd9c999013f..582581fa5b49179a2ecdd36d4c1f91066474e1f8 100644 --- a/ee/spec/services/google_cloud_platform/artifact_registry/get_docker_image_service_spec.rb +++ b/ee/spec/services/google_cloud/artifact_registry/get_docker_image_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform::ArtifactRegistry::GetDockerImageService, feature_category: :container_registry do +RSpec.describe GoogleCloud::ArtifactRegistry::GetDockerImageService, feature_category: :container_registry do using RSpec::Parameterized::TableSyntax include_context 'for an artifact registry service' diff --git a/ee/spec/services/google_cloud_platform/artifact_registry/get_repository_service_spec.rb b/ee/spec/services/google_cloud/artifact_registry/get_repository_service_spec.rb similarity index 88% rename from ee/spec/services/google_cloud_platform/artifact_registry/get_repository_service_spec.rb rename to ee/spec/services/google_cloud/artifact_registry/get_repository_service_spec.rb index 5726d27c62c8c886aba8d3e736f9fad8cac79b85..2b381c19f8012363e5e0d0fc7a57348574f85ad8 100644 --- a/ee/spec/services/google_cloud_platform/artifact_registry/get_repository_service_spec.rb +++ b/ee/spec/services/google_cloud/artifact_registry/get_repository_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ::GoogleCloudPlatform::ArtifactRegistry::GetRepositoryService, feature_category: :container_registry do +RSpec.describe ::GoogleCloud::ArtifactRegistry::GetRepositoryService, feature_category: :container_registry do using RSpec::Parameterized::TableSyntax include_context 'for an artifact registry service' diff --git a/ee/spec/services/google_cloud_platform/artifact_registry/list_docker_images_service_spec.rb b/ee/spec/services/google_cloud/artifact_registry/list_docker_images_service_spec.rb similarity index 95% rename from ee/spec/services/google_cloud_platform/artifact_registry/list_docker_images_service_spec.rb rename to ee/spec/services/google_cloud/artifact_registry/list_docker_images_service_spec.rb index 7b8e19b14c59304cf67755f547bf27abc377e63a..a277f0cd720e45d9380ec78cad88b1caf9a14e1b 100644 --- a/ee/spec/services/google_cloud_platform/artifact_registry/list_docker_images_service_spec.rb +++ b/ee/spec/services/google_cloud/artifact_registry/list_docker_images_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform::ArtifactRegistry::ListDockerImagesService, feature_category: :container_registry do +RSpec.describe GoogleCloud::ArtifactRegistry::ListDockerImagesService, feature_category: :container_registry do using RSpec::Parameterized::TableSyntax include_context 'for an artifact registry service' diff --git a/ee/spec/services/google_cloud_platform/compute/list_machine_types_service_spec.rb b/ee/spec/services/google_cloud/compute/list_machine_types_service_spec.rb similarity index 96% rename from ee/spec/services/google_cloud_platform/compute/list_machine_types_service_spec.rb rename to ee/spec/services/google_cloud/compute/list_machine_types_service_spec.rb index 1fd962a27bc7f7b3a6f53017475aa49e7ea606c3..ae7e5053c051fbb4ec3f2b325728705401066fd0 100644 --- a/ee/spec/services/google_cloud_platform/compute/list_machine_types_service_spec.rb +++ b/ee/spec/services/google_cloud/compute/list_machine_types_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform::Compute::ListMachineTypesService, feature_category: :fleet_visibility do +RSpec.describe GoogleCloud::Compute::ListMachineTypesService, feature_category: :fleet_visibility do using RSpec::Parameterized::TableSyntax include_context 'for a compute service' diff --git a/ee/spec/services/google_cloud_platform/compute/list_regions_service_spec.rb b/ee/spec/services/google_cloud/compute/list_regions_service_spec.rb similarity index 95% rename from ee/spec/services/google_cloud_platform/compute/list_regions_service_spec.rb rename to ee/spec/services/google_cloud/compute/list_regions_service_spec.rb index 68772bca073ea446b0d713ca3ca11dae54305336..997a79268c64fbfc26180f780664452dc7f97ee6 100644 --- a/ee/spec/services/google_cloud_platform/compute/list_regions_service_spec.rb +++ b/ee/spec/services/google_cloud/compute/list_regions_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform::Compute::ListRegionsService, feature_category: :fleet_visibility do +RSpec.describe GoogleCloud::Compute::ListRegionsService, feature_category: :fleet_visibility do using RSpec::Parameterized::TableSyntax include_context 'for a compute service' diff --git a/ee/spec/services/google_cloud_platform/compute/list_zones_service_spec.rb b/ee/spec/services/google_cloud/compute/list_zones_service_spec.rb similarity index 95% rename from ee/spec/services/google_cloud_platform/compute/list_zones_service_spec.rb rename to ee/spec/services/google_cloud/compute/list_zones_service_spec.rb index 5922d78c0a8323e983c3769d547d1bf334abedd9..5cb302d13725be47734ec18e09aeeaa21d8f761d 100644 --- a/ee/spec/services/google_cloud_platform/compute/list_zones_service_spec.rb +++ b/ee/spec/services/google_cloud/compute/list_zones_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloudPlatform::Compute::ListZonesService, feature_category: :fleet_visibility do +RSpec.describe GoogleCloud::Compute::ListZonesService, feature_category: :fleet_visibility do using RSpec::Parameterized::TableSyntax include_context 'for a compute service' diff --git a/ee/spec/support/shared_contexts/google_cloud_platform/artifact_registry/services_shared_contexts.rb b/ee/spec/support/shared_contexts/google_cloud_platform/artifact_registry/services_shared_contexts.rb index a33e2e9cb6fab953be82ff8e8e33a77dc2ebb0b0..e51b28585c202105289baf11e439d4864c4062c2 100644 --- a/ee/spec/support/shared_contexts/google_cloud_platform/artifact_registry/services_shared_contexts.rb +++ b/ee/spec/support/shared_contexts/google_cloud_platform/artifact_registry/services_shared_contexts.rb @@ -19,10 +19,10 @@ let(:user) { project.owner } let(:params) { {} } let(:service) { described_class.new(project: project, current_user: user, params: params) } - let(:client_double) { instance_double('::GoogleCloudPlatform::ArtifactRegistry::Client') } + let(:client_double) { instance_double('::GoogleCloud::ArtifactRegistry::Client') } before do - allow(::GoogleCloudPlatform::ArtifactRegistry::Client).to receive(:new) + allow(::GoogleCloud::ArtifactRegistry::Client).to receive(:new) .with(wlif_integration: wlif_integration, user: user) .and_return(client_double) end diff --git a/ee/spec/support/shared_contexts/google_cloud_platform/compute/services_shared_contexts.rb b/ee/spec/support/shared_contexts/google_cloud_platform/compute/services_shared_contexts.rb index 9382453ea9e1890e81cd328081929f0718f27b99..8873399391ac769d5fb56b44dd137c36d4a67e40 100644 --- a/ee/spec/support/shared_contexts/google_cloud_platform/compute/services_shared_contexts.rb +++ b/ee/spec/support/shared_contexts/google_cloud_platform/compute/services_shared_contexts.rb @@ -7,7 +7,7 @@ end let(:user) { create(:user).tap { |user| project.add_owner(user) } } - let(:client_double) { instance_double('::GoogleCloudPlatform::Compute::Client') } + let(:client_double) { instance_double('::GoogleCloud::Compute::Client') } let(:service) { described_class.new(container: project, current_user: user, params: params) } let(:google_cloud_project_id) { nil } @@ -16,7 +16,7 @@ before do stub_saas_features(google_cloud_support: google_cloud_support) - allow(::GoogleCloudPlatform::Compute::Client).to receive(:new) + allow(::GoogleCloud::Compute::Client).to receive(:new) .with( wlif_integration: wlif_integration, user: user, diff --git a/ee/spec/support/shared_examples/google_cloud_platform/artifact_registry/services_shared_examples.rb b/ee/spec/support/shared_examples/google_cloud_platform/artifact_registry/services_shared_examples.rb index 6d5ec4893d752674302c24a3c8564b60f01958c1..23a524c0a966b648eaed66b0c8fc86bfbfc127bd 100644 --- a/ee/spec/support/shared_examples/google_cloud_platform/artifact_registry/services_shared_examples.rb +++ b/ee/spec/support/shared_examples/google_cloud_platform/artifact_registry/services_shared_examples.rb @@ -81,7 +81,7 @@ context 'when client raises AuthenticationError' do before do allow(client_double).to receive(client_method) - .and_raise(::GoogleCloudPlatform::AuthenticationError, 'boom') + .and_raise(::GoogleCloud::AuthenticationError, 'boom') end it_behaves_like 'returning an error service response', @@ -92,7 +92,7 @@ context 'when client raises ApiError' do before do allow(client_double).to receive(client_method) - .and_raise(::GoogleCloudPlatform::ApiError, 'boom') + .and_raise(::GoogleCloud::ApiError, 'boom') end it_behaves_like 'returning an error service response', diff --git a/ee/spec/support/shared_examples/google_cloud_platform/client_shared_examples.rb b/ee/spec/support/shared_examples/google_cloud_platform/client_shared_examples.rb index 7e5a20d8e995973d1ffcaa03f7345b0f40372701..4fc3447f0425070d2342c9e91698f4261eb7ccc8 100644 --- a/ee/spec/support/shared_examples/google_cloud_platform/client_shared_examples.rb +++ b/ee/spec/support/shared_examples/google_cloud_platform/client_shared_examples.rb @@ -12,12 +12,12 @@ it_behaves_like 'transforming the error', message: "test #{described_class::GOOGLE_CLOUD_SUBJECT_TOKEN_ERROR_MESSAGE} test", from_klass: RuntimeError, - to_klass: ::GoogleCloudPlatform::AuthenticationError + to_klass: ::GoogleCloud::AuthenticationError it_behaves_like 'transforming the error', message: "test #{described_class::GOOGLE_CLOUD_TOKEN_EXCHANGE_ERROR_MESSAGE} test", from_klass: RuntimeError, - to_klass: ::GoogleCloudPlatform::AuthenticationError + to_klass: ::GoogleCloud::AuthenticationError it_behaves_like 'transforming the error', message: "test", @@ -27,7 +27,7 @@ it_behaves_like 'transforming the error', message: "test", from_klass: ::Google::Cloud::Error, - to_klass: ::GoogleCloudPlatform::ApiError + to_klass: ::GoogleCloud::ApiError end RSpec.shared_examples 'handling google cloud client common validations' do diff --git a/ee/spec/support/shared_examples/google_cloud_platform/compute/services_shared_examples.rb b/ee/spec/support/shared_examples/google_cloud_platform/compute/services_shared_examples.rb index b4487d3df540ccec11f9da87e29bc10884c032f1..b8a26f240bcfda63ef1e68e5fed834334d1c6b90 100644 --- a/ee/spec/support/shared_examples/google_cloud_platform/compute/services_shared_examples.rb +++ b/ee/spec/support/shared_examples/google_cloud_platform/compute/services_shared_examples.rb @@ -49,7 +49,7 @@ context 'when client raises AuthenticationError' do before do - allow(client_double).to receive(client_method).and_raise(::GoogleCloudPlatform::AuthenticationError, 'boom') + allow(client_double).to receive(client_method).and_raise(::GoogleCloud::AuthenticationError, 'boom') end it_behaves_like 'returning an error service response', message: 'Unable to authenticate against Google Cloud' @@ -58,7 +58,7 @@ context 'when client raises ApiError' do before do - allow(client_double).to receive(client_method).and_raise(::GoogleCloudPlatform::ApiError, 'invalid arg') + allow(client_double).to receive(client_method).and_raise(::GoogleCloud::ApiError, 'invalid arg') end it_behaves_like 'returning an error service response', @@ -73,7 +73,7 @@ let(:extra_params) { { google_cloud_project_id: google_cloud_project_id } } it 'returns results by calling the specified project id' do - expect(::GoogleCloudPlatform::Compute::Client).to receive(:new) + expect(::GoogleCloud::Compute::Client).to receive(:new) .with(wlif_integration: wlif_integration, user: user, params: extra_params) do |**args| expect(args.dig(:params, :google_cloud_project_id)).to eq(google_cloud_project_id) diff --git a/ee/spec/support/shared_examples/lib/audit_events/strategies/google_cloud_logging_destination_strategy_shared_examples.rb b/ee/spec/support/shared_examples/lib/audit_events/strategies/google_cloud_logging_destination_strategy_shared_examples.rb index 5227f88d8c44a9b273d8f86e71d2e317d01fd91a..9c0f31c1944c2dc10a9758abcf06df6e7f9db2f4 100644 --- a/ee/spec/support/shared_examples/lib/audit_events/strategies/google_cloud_logging_destination_strategy_shared_examples.rb +++ b/ee/spec/support/shared_examples/lib/audit_events/strategies/google_cloud_logging_destination_strategy_shared_examples.rb @@ -18,7 +18,7 @@ subject(:track_and_stream) { instance.send(:track_and_stream, destination) } before do - allow_next_instance_of(GoogleCloud::LoggingService::Logger) do |instance| + allow_next_instance_of(AuditEvents::GoogleCloud::LoggingService::Logger) do |instance| allow(instance).to receive(:log).and_return(nil) end allow(instance).to receive(:request_body).and_return(request_body) @@ -27,7 +27,7 @@ it 'tracks audit event count and calls logger' do expect(instance).to receive(:track_audit_event_count) - allow_next_instance_of(GoogleCloud::LoggingService::Logger) do |logger| + allow_next_instance_of(AuditEvents::GoogleCloud::LoggingService::Logger) do |logger| expect(logger).to receive(:log).with(destination.client_email, destination.private_key, expected_log_entry) end diff --git a/lib/audit_events/google_cloud/authentication.rb b/lib/audit_events/google_cloud/authentication.rb new file mode 100644 index 0000000000000000000000000000000000000000..9f1d882cfb569fcc99eaf83ddd7eec3a7f6afe69 --- /dev/null +++ b/lib/audit_events/google_cloud/authentication.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module AuditEvents + module GoogleCloud + class Authentication + def initialize(scope:) + @scope = scope + end + + def generate_access_token(client_email, private_key) + credentials = Google::Auth::ServiceAccountCredentials.make_creds( + json_key_io: StringIO.new({ client_email: client_email, private_key: private_key }.to_json), + scope: @scope + ) + credentials.fetch_access_token!["access_token"] + rescue StandardError => e + ::Gitlab::ErrorTracking.track_exception(e, client_email: client_email) + nil + end + end + end +end diff --git a/lib/audit_events/google_cloud/logging_service/logger.rb b/lib/audit_events/google_cloud/logging_service/logger.rb new file mode 100644 index 0000000000000000000000000000000000000000..a3a936be2cb9e0c31dde73e81967f5fb9d7438ef --- /dev/null +++ b/lib/audit_events/google_cloud/logging_service/logger.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module AuditEvents + module GoogleCloud + module LoggingService + class Logger + WRITE_URL = "https://logging.googleapis.com/v2/entries:write" + SCOPE = "https://www.googleapis.com/auth/logging.write" + + def initialize + @auth = AuditEvents::GoogleCloud::Authentication.new(scope: SCOPE) + end + + def log(client_email, private_key, payload) + access_token = @auth.generate_access_token(client_email, private_key) + + return unless access_token + + headers = build_headers(access_token) + + post(WRITE_URL, body: payload, headers: headers) + end + + private + + def build_headers(access_token) + { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json' } + end + + def post(url, body:, headers:) + Gitlab::HTTP.post( + url, + body: body, + headers: headers + ) + rescue URI::InvalidURIError => e + Gitlab::ErrorTracking.log_exception(e) + rescue *Gitlab::HTTP::HTTP_ERRORS + end + end + end + end +end diff --git a/lib/google_cloud/authentication.rb b/lib/google_cloud/authentication.rb deleted file mode 100644 index 68dd0bdcccb47f9510ca137d6f8dbb04bf6310f2..0000000000000000000000000000000000000000 --- a/lib/google_cloud/authentication.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -module GoogleCloud - class Authentication - def initialize(scope:) - @scope = scope - end - - def generate_access_token(client_email, private_key) - credentials = Google::Auth::ServiceAccountCredentials.make_creds( - json_key_io: StringIO.new({ client_email: client_email, private_key: private_key }.to_json), - scope: @scope - ) - credentials.fetch_access_token!["access_token"] - rescue StandardError => e - ::Gitlab::ErrorTracking.track_exception(e, client_email: client_email) - nil - end - end -end diff --git a/lib/google_cloud/logging_service/logger.rb b/lib/google_cloud/logging_service/logger.rb deleted file mode 100644 index 2c6dd6ea73260e30121ba03e86f9706335b15e1b..0000000000000000000000000000000000000000 --- a/lib/google_cloud/logging_service/logger.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -module GoogleCloud - module LoggingService - class Logger - WRITE_URL = "https://logging.googleapis.com/v2/entries:write" - SCOPE = "https://www.googleapis.com/auth/logging.write" - - def initialize - @auth = GoogleCloud::Authentication.new(scope: SCOPE) - end - - def log(client_email, private_key, payload) - access_token = @auth.generate_access_token(client_email, private_key) - - return unless access_token - - headers = build_headers(access_token) - - post(WRITE_URL, body: payload, headers: headers) - end - - private - - def build_headers(access_token) - { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json' } - end - - def post(url, body:, headers:) - Gitlab::HTTP.post( - url, - body: body, - headers: headers - ) - rescue URI::InvalidURIError => e - Gitlab::ErrorTracking.log_exception(e) - rescue *Gitlab::HTTP::HTTP_ERRORS - end - end - end -end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 040d9c34d9b612eddb61f07f778f6e21537f4e59..006c1a797e5356ed7a0d9219c4236886593890be 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -24029,184 +24029,181 @@ msgstr "" msgid "GoogleArtifactRegistry|Your Google Cloud project must have specific Identity and Access Management (IAM) policies to use the Artifact Registry repository in this GitLab project." msgstr "" -msgid "GoogleCloudPlatformService|%{linkStart}Switch to the guided setup%{linkEnd} if you can manage workload identity federation in Google Cloud. %{link2Start}What are the required permissions?%{link2End}" +msgid "GoogleCloud|%{linkStart}Switch to the guided setup%{linkEnd} if you can manage workload identity federation in Google Cloud. %{link2Start}What are the required permissions?%{link2End}" msgstr "" -msgid "GoogleCloudPlatformService|%{linkStart}Switch to the manual setup%{linkEnd} if you cannot manage workload identity federation in Google Cloud. %{link2Start}What are the required permissions?%{link2End}" +msgid "GoogleCloud|%{linkStart}Switch to the manual setup%{linkEnd} if you cannot manage workload identity federation in Google Cloud. %{link2Start}What are the required permissions?%{link2End}" msgstr "" -msgid "GoogleCloudPlatformService|%{link_start}Explore Google Cloud integration with GitLab%{link_end}, for CI/CD and more." +msgid "GoogleCloud|%{link_start}Explore Google Cloud integration with GitLab%{link_end}, for CI/CD and more." msgstr "" -msgid "GoogleCloudPlatformService|After Google Cloud workload identity federation has been set up, enter the details in the following form." +msgid "GoogleCloud|After Google Cloud workload identity federation has been set up, enter the details in the following form." msgstr "" -msgid "GoogleCloudPlatformService|After Google Cloud workload identity federation has been set up, select %{strongStart}Continue%{strongEnd}." +msgid "GoogleCloud|After Google Cloud workload identity federation has been set up, select %{strongStart}Continue%{strongEnd}." msgstr "" -msgid "GoogleCloudPlatformService|Before you begin, %{linkStart}install the Google Cloud CLI%{linkEnd}." +msgid "GoogleCloud|Before you begin, %{linkStart}install the Google Cloud CLI%{linkEnd}." msgstr "" -msgid "GoogleCloudPlatformService|Connect to Google Cloud" -msgstr "" - -msgid "GoogleCloudPlatformService|Connect to Google Cloud with workload identity federation for secure access without accounts or keys." +msgid "GoogleCloud|Cancel" msgstr "" -msgid "GoogleCloudPlatformService|Connect to Google Cloud with workload identity federation. Select %{strongStart}Guided setup%{strongEnd} if you can manage workload identity federation in Google Cloud. %{linkStart}What are the required permissions?%{linkEnd}" +msgid "GoogleCloud|Configured region is linked to the selected branch or tag" msgstr "" -msgid "GoogleCloudPlatformService|Example: %{code_open}314053285323%{code_close}" +msgid "GoogleCloud|Connect to Google Cloud" msgstr "" -msgid "GoogleCloudPlatformService|Example: %{code_open}my-sample-project-191923%{code_close}" +msgid "GoogleCloud|Connect to Google Cloud with workload identity federation for secure access without accounts or keys." msgstr "" -msgid "GoogleCloudPlatformService|Google Cloud IAM" +msgid "GoogleCloud|Connect to Google Cloud with workload identity federation. Select %{strongStart}Guided setup%{strongEnd} if you can manage workload identity federation in Google Cloud. %{linkStart}What are the required permissions?%{linkEnd}" msgstr "" -msgid "GoogleCloudPlatformService|Google Cloud project" +msgid "GoogleCloud|Create service account" msgstr "" -msgid "GoogleCloudPlatformService|Google Cloud project ID" +msgid "GoogleCloud|Example: %{code_open}314053285323%{code_close}" msgstr "" -msgid "GoogleCloudPlatformService|Google Cloud project ID for the Workload Identity Federation." +msgid "GoogleCloud|Example: %{code_open}my-sample-project-191923%{code_close}" msgstr "" -msgid "GoogleCloudPlatformService|Google Cloud project number for the Workload Identity Federation." +msgid "GoogleCloud|Generated service account is linked to the selected branch or tag" msgstr "" -msgid "GoogleCloudPlatformService|Guided setup" +msgid "GoogleCloud|Google Artifact Management" msgstr "" -msgid "GoogleCloudPlatformService|ID of the Workload Identity Pool provider." +msgid "GoogleCloud|Google Cloud IAM" msgstr "" -msgid "GoogleCloudPlatformService|ID of the Workload Identity Pool." +msgid "GoogleCloud|Google Cloud project" msgstr "" -msgid "GoogleCloudPlatformService|Identify the Google Cloud project with the workload identity pool and provider. %{linkStart}Where are my project ID and project number?%{linkEnd}" +msgid "GoogleCloud|Google Cloud project ID" msgstr "" -msgid "GoogleCloudPlatformService|Instructions" +msgid "GoogleCloud|Google Cloud project ID for the Workload Identity Federation." msgstr "" -msgid "GoogleCloudPlatformService|Invite member to set up" +msgid "GoogleCloud|Google Cloud project number for the Workload Identity Federation." msgstr "" -msgid "GoogleCloudPlatformService|Manage permissions for Google Cloud resources with Identity and Access Management (IAM)." +msgid "GoogleCloud|Google OAuth2 token revocation request failed" msgstr "" -msgid "GoogleCloudPlatformService|Manage permissions for Google Cloud resources with Identity and Access Management (IAM). Simplify and secure your usage, without the need to manage accounts or keys." +msgid "GoogleCloud|Google OAuth2 token revocation requested" msgstr "" -msgid "GoogleCloudPlatformService|Manage your artifacts in Google Artifact Registry." +msgid "GoogleCloud|Guided setup" msgstr "" -msgid "GoogleCloudPlatformService|Manual setup" +msgid "GoogleCloud|I understand the responsibilities involved with managing service account keys" msgstr "" -msgid "GoogleCloudPlatformService|Pool ID" +msgid "GoogleCloud|ID of the Workload Identity Pool provider." msgstr "" -msgid "GoogleCloudPlatformService|Project ID" +msgid "GoogleCloud|ID of the Workload Identity Pool." msgstr "" -msgid "GoogleCloudPlatformService|Project number" +msgid "GoogleCloud|Identify the Google Cloud project with the workload identity pool and provider. %{linkStart}Where are my project ID and project number?%{linkEnd}" msgstr "" -msgid "GoogleCloudPlatformService|Project with the Artifact Registry repository." +msgid "GoogleCloud|Instructions" msgstr "" -msgid "GoogleCloudPlatformService|Provider ID" +msgid "GoogleCloud|Invite member to set up" msgstr "" -msgid "GoogleCloudPlatformService|Replace %{codeStart}your_access_token%{codeEnd} with a %{linkStart}new personal access token%{linkEnd} with the %{strongStart}api%{strongEnd} scope. This token sets up your Google Cloud IAM integration in GitLab." +msgid "GoogleCloud|Manage permissions for Google Cloud resources with Identity and Access Management (IAM)." msgstr "" -msgid "GoogleCloudPlatformService|Replace %{codeStart}your_google_cloud_project_id%{codeEnd} with your Google Cloud project ID. To improve security, use a dedicated project for identity management, separate from resources and CI/CD projects. %{linkStart}Where’s my project ID?%{linkEnd}" +msgid "GoogleCloud|Manage permissions for Google Cloud resources with Identity and Access Management (IAM). Simplify and secure your usage, without the need to manage accounts or keys." msgstr "" -msgid "GoogleCloudPlatformService|Repository location" +msgid "GoogleCloud|Manage your artifacts in Google Artifact Registry." msgstr "" -msgid "GoogleCloudPlatformService|Repository must be Docker format and Standard mode." +msgid "GoogleCloud|Manual setup" msgstr "" -msgid "GoogleCloudPlatformService|Repository name" +msgid "GoogleCloud|New service account is generated for the selected Google Cloud project" msgstr "" -msgid "GoogleCloudPlatformService|Run the following command to set up and connect to your Google Cloud project with workload identity federation." +msgid "GoogleCloud|Pool ID" msgstr "" -msgid "GoogleCloudPlatformService|Share the following information with someone that can manage Google Cloud workload identity federation. Or %{linkStart}invite them%{linkEnd} to set up." +msgid "GoogleCloud|Project ID" msgstr "" -msgid "GoogleCloudPlatformService|The Google Cloud Identity and Access Management integration is not configured for this project" +msgid "GoogleCloud|Project number" msgstr "" -msgid "GoogleCloudPlatformService|The Google Cloud Identity and Access Management integration is not enabled for this project" +msgid "GoogleCloud|Project with the Artifact Registry repository." msgstr "" -msgid "GoogleCloudPlatformService|The google_cloud_support feature is not available" +msgid "GoogleCloud|Provider ID" msgstr "" -msgid "GoogleCloudPlatformService|The setup instructions page" +msgid "GoogleCloud|Refs" msgstr "" -msgid "GoogleCloudPlatformService|To improve security, use a dedicated project for resources, separate from CI/CD and identity management projects. %{link_start}Where’s my project ID? %{icon}%{link_end}" +msgid "GoogleCloud|Replace %{codeStart}your_access_token%{codeEnd} with a %{linkStart}new personal access token%{linkEnd} with the %{strongStart}api%{strongEnd} scope. This token sets up your Google Cloud IAM integration in GitLab." msgstr "" -msgid "GoogleCloudPlatformService|Workload identity federation" +msgid "GoogleCloud|Replace %{codeStart}your_google_cloud_project_id%{codeEnd} with your Google Cloud project ID. To improve security, use a dedicated project for identity management, separate from resources and CI/CD projects. %{linkStart}Where’s my project ID?%{linkEnd}" msgstr "" -msgid "GoogleCloudPlatformService|You might be prompted to sign in to Google." +msgid "GoogleCloud|Repository location" msgstr "" -msgid "GoogleCloudPlatformService|Your GitLab project ID" +msgid "GoogleCloud|Repository must be Docker format and Standard mode." msgstr "" -msgid "GoogleCloudPlatformService|Your workload identify federation (WLIF) issuer URL." +msgid "GoogleCloud|Repository name" msgstr "" -msgid "GoogleCloud|Cancel" +msgid "GoogleCloud|Revoke authorizations" msgstr "" -msgid "GoogleCloud|Configured region is linked to the selected branch or tag" +msgid "GoogleCloud|Revoke authorizations granted to GitLab. This does not invalidate service accounts." msgstr "" -msgid "GoogleCloud|Create service account" +msgid "GoogleCloud|Run the following command to set up and connect to your Google Cloud project with workload identity federation." msgstr "" -msgid "GoogleCloud|Generated service account is linked to the selected branch or tag" +msgid "GoogleCloud|Share the following information with someone that can manage Google Cloud workload identity federation. Or %{linkStart}invite them%{linkEnd} to set up." msgstr "" -msgid "GoogleCloud|Google Artifact Management" +msgid "GoogleCloud|The Google Cloud Identity and Access Management integration is not configured for this project" msgstr "" -msgid "GoogleCloud|Google Cloud project" +msgid "GoogleCloud|The Google Cloud Identity and Access Management integration is not enabled for this project" msgstr "" -msgid "GoogleCloud|Google OAuth2 token revocation request failed" +msgid "GoogleCloud|The google_cloud_support feature is not available" msgstr "" -msgid "GoogleCloud|Google OAuth2 token revocation requested" +msgid "GoogleCloud|The setup instructions page" msgstr "" -msgid "GoogleCloud|I understand the responsibilities involved with managing service account keys" +msgid "GoogleCloud|To improve security, use a dedicated project for resources, separate from CI/CD and identity management projects. %{link_start}Where’s my project ID? %{icon}%{link_end}" msgstr "" -msgid "GoogleCloud|New service account is generated for the selected Google Cloud project" +msgid "GoogleCloud|Workload identity federation" msgstr "" -msgid "GoogleCloud|Refs" +msgid "GoogleCloud|You might be prompted to sign in to Google." msgstr "" -msgid "GoogleCloud|Revoke authorizations" +msgid "GoogleCloud|Your GitLab project ID" msgstr "" -msgid "GoogleCloud|Revoke authorizations granted to GitLab. This does not invalidate service accounts." +msgid "GoogleCloud|Your workload identify federation (WLIF) issuer URL." msgstr "" msgid "GooglePlayStore|Protected branches and tags only" diff --git a/spec/lib/google_cloud/authentication_spec.rb b/spec/lib/audit_events/google_cloud/authentication_spec.rb similarity index 95% rename from spec/lib/google_cloud/authentication_spec.rb rename to spec/lib/audit_events/google_cloud/authentication_spec.rb index 5c7f3e5115239b91b3e95207106f4517edb43c6f..e74103f673c6c8d9563bb0edeefe1528589b0d5a 100644 --- a/spec/lib/google_cloud/authentication_spec.rb +++ b/spec/lib/audit_events/google_cloud/authentication_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloud::Authentication, feature_category: :audit_events do +RSpec.describe AuditEvents::GoogleCloud::Authentication, feature_category: :audit_events do describe '#generate_access_token' do let_it_be(:client_email) { 'test@example.com' } let_it_be(:private_key) { 'private_key' } diff --git a/spec/lib/google_cloud/logging_service/logger_spec.rb b/spec/lib/audit_events/google_cloud/logging_service/logger_spec.rb similarity index 85% rename from spec/lib/google_cloud/logging_service/logger_spec.rb rename to spec/lib/audit_events/google_cloud/logging_service/logger_spec.rb index 31f8bb27ec546ba5615599110d22a5d3340f196d..161b9ce06e7eec8be5c033989b99a08a5dfd34fb 100644 --- a/spec/lib/google_cloud/logging_service/logger_spec.rb +++ b/spec/lib/audit_events/google_cloud/logging_service/logger_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe GoogleCloud::LoggingService::Logger, feature_category: :audit_events do +RSpec.describe AuditEvents::GoogleCloud::LoggingService::Logger, feature_category: :audit_events do let_it_be(:client_email) { 'test@example.com' } let_it_be(:private_key) { 'private_key' } let_it_be(:payload) { [{ logName: 'test-log' }.to_json] } @@ -16,7 +16,7 @@ describe '#log' do context 'when access token is available' do before do - allow_next_instance_of(GoogleCloud::Authentication) do |instance| + allow_next_instance_of(AuditEvents::GoogleCloud::Authentication) do |instance| allow(instance).to receive(:generate_access_token).with(client_email, private_key).and_return(access_token) end end @@ -48,7 +48,7 @@ let(:access_token) { nil } it 'does not call Gitlab::HTTP.post' do - allow_next_instance_of(GoogleCloud::Authentication) do |instance| + allow_next_instance_of(AuditEvents::GoogleCloud::Authentication) do |instance| allow(instance).to receive(:generate_access_token).with(client_email, private_key).and_return(access_token) end