Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-14 18:11:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-14 18:11:00 +0300
commit1ab98e892c57b409d5ac3d643fdebc93de5a08dc (patch)
tree37b81d604a3b0fece0b9ee6c59e106f923322ca2 /bin
parenta0d49dc011304985a8fd8a7ab337c003995c8ae1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'bin')
-rwxr-xr-xbin/diagnostic-reports-uploader29
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/diagnostic-reports-uploader b/bin/diagnostic-reports-uploader
new file mode 100755
index 00000000000..a19fe15dcb9
--- /dev/null
+++ b/bin/diagnostic-reports-uploader
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+require 'fog/google'
+
+require_relative '../lib/gitlab/memory/reports_uploader'
+require_relative '../lib/gitlab/memory/upload_and_cleanup_reports'
+require_relative '../lib/gitlab/memory/diagnostic_reports_logger'
+
+# Fail fast if the necessary ENV vars are not set.
+reports_path = ENV["GITLAB_DIAGNOSTIC_REPORTS_PATH"].to_s
+raise 'GITLAB_DIAGNOSTIC_REPORTS_PATH dir is missing' unless Dir.exist?(reports_path)
+
+gcs_key = ENV["GITLAB_GCP_KEY_PATH"].to_s
+raise "GCS keyfile not found: #{gcs_key}" unless File.exist?(gcs_key)
+
+gcs_project = ENV["GITLAB_DIAGNOSTIC_REPORTS_PROJECT"].to_s
+raise 'GITLAB_DIAGNOSTIC_REPORTS_PROJECT is missing' unless gcs_project && !gcs_project.empty?
+
+gcs_bucket = ENV["GITLAB_DIAGNOSTIC_REPORTS_BUCKET"].to_s
+raise 'GITLAB_DIAGNOSTIC_REPORTS_BUCKET is missing' unless gcs_bucket && !gcs_bucket.empty?
+
+rails_root = File.expand_path("..", __dir__)
+log_file = File.expand_path('log/diagnostic_reports_json.log', rails_root)
+logger = Gitlab::Memory::DiagnosticReportsLogger.new(log_file)
+
+uploader = Gitlab::Memory::ReportsUploader.new(gcs_key: gcs_key, gcs_project: gcs_project, gcs_bucket: gcs_bucket,
+ logger: logger)
+Gitlab::Memory::UploadAndCleanupReports.new(uploader: uploader, reports_path: reports_path, logger: logger).call