Skip to content

Add namespace root storage repository size

John Mason requested to merge jm-namespace-root-repo-size into master

This change is part 2 of gitlab-org/gitlab!121175 (merged)

Related to gitlab-org/gitlab#406527 (closed)

How to validate locally

I had a tough time getting my dependencies installed with the older version of ruby, so I used docker. Do the following steps in this project's root directory.

  1. Apply this patch to have docker image point to local GDK and print out namespace.root_repository_size
diff --git a/lib/chatops/commands/namespace.rb b/lib/chatops/commands/namespace.rb
index 35939ad..1aa70b3 100644
--- a/lib/chatops/commands/namespace.rb
+++ b/lib/chatops/commands/namespace.rb
@@ -86,6 +86,7 @@ module Chatops
       end
 
       def submit_namespace_details(namespace) # rubocop:disable Metrics/MethodLength
+        return puts "-------------> namespace.root_repository_size: #{namespace.root_repository_size}"
         Slack::Message
           .new(token: slack_token, channel: channel)
           .send(
diff --git a/lib/chatops/gitlab/client.rb b/lib/chatops/gitlab/client.rb
index 9e4fa29..ba65eae 100644
--- a/lib/chatops/gitlab/client.rb
+++ b/lib/chatops/gitlab/client.rb
@@ -14,7 +14,7 @@ module Chatops
       # token - The API token to use for authentication.
       # host - The hostname to use.
       def initialize(token:, host: DEFAULT_HOST, httparty: {})
-        endpoint = "https://#{host}/api/v4"
+        endpoint = "http://host.docker.internal:3000/api/v4"
 
         @host = host
         @internal_client = ::Gitlab::Client
  1. Build docker image
docker build -t chatops  -f docker/chatops.Dockerfile .
  1. Create an API token from your local GDK

  2. Run chatops command with API token from previous step

docker run --rm -it chatops env GITLAB_TOKEN='your-token-here' CHAT_INPUT='find Flightjs' bundle exec ./bin/chatops namespace
  1. Verify namespace.root_repository_size is printed out
2023-05-30 20:40:03.030405 I [{:user=>nil}] Chatops -- Command to be executed -- {:name=>"namespace", :chat_input=>"find Flightjs", :split_chat_input=>["find", "Flightjs"]}
-------------> namespace.root_repository_size: 123
Edited by John Mason

Merge request reports

Loading