From 2ec72b74404ddfdc71c8ced26decffbb3f2dd1ef Mon Sep 17 00:00:00 2001 From: Gabriel Figueira Date: Tue, 28 May 2024 14:32:50 -0300 Subject: [PATCH 1/3] feat: Add token on header if have the envieroment --- Gemfile.lock | 3 ++- lib/chroma/api_operations/request.rb | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 968f8ed..af8da69 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -101,6 +101,7 @@ GEM PLATFORMS arm64-darwin-22 + x86_64-darwin-22 x86_64-linux DEPENDENCIES @@ -114,4 +115,4 @@ DEPENDENCIES webmock (~> 3.18, >= 3.18.1) BUNDLED WITH - 2.4.12 + 2.4.19 diff --git a/lib/chroma/api_operations/request.rb b/lib/chroma/api_operations/request.rb index af924bd..897036a 100644 --- a/lib/chroma/api_operations/request.rb +++ b/lib/chroma/api_operations/request.rb @@ -118,8 +118,7 @@ def execute_request(method, url, params = {}, options = {}) request.content_type = "application/json" request.body = params.to_json if params.size > 0 request.basic_auth(uri.user, uri.password) if !uri.user.nil? - - request + request['X-Chroma-Token'] = ENV.fetch('CHROMA_SERVER_AUTHN_CREDENTIALS', nil) if ENV.fetch('CHROMA_SERVER_AUTHN_CREDENTIALS', nil) end end From 86b25d1a1865fdc64c65cadfe1cb9faad99756cd Mon Sep 17 00:00:00 2001 From: Gabriel Figueira Date: Tue, 28 May 2024 14:33:59 -0300 Subject: [PATCH 2/3] fix: implicit return --- lib/chroma/api_operations/request.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/chroma/api_operations/request.rb b/lib/chroma/api_operations/request.rb index 897036a..7d03e62 100644 --- a/lib/chroma/api_operations/request.rb +++ b/lib/chroma/api_operations/request.rb @@ -118,7 +118,8 @@ def execute_request(method, url, params = {}, options = {}) request.content_type = "application/json" request.body = params.to_json if params.size > 0 request.basic_auth(uri.user, uri.password) if !uri.user.nil? - request['X-Chroma-Token'] = ENV.fetch('CHROMA_SERVER_AUTHN_CREDENTIALS', nil) if ENV.fetch('CHROMA_SERVER_AUTHN_CREDENTIALS', nil) + request['X-Chroma-Token'] = ENV.fetch('CHROMA_SERVER_AUTHN_CREDENTIALS', nil) if ENV["CHROMA_SERVER_AUTHN_CREDENTIALS"] + request end end From a318f3d63b29d5ea43afcff8773b7f91da47c78b Mon Sep 17 00:00:00 2001 From: Gabriel Figueira Date: Tue, 28 May 2024 14:40:22 -0300 Subject: [PATCH 3/3] fix: change to single quotes and using fetch env --- lib/chroma/api_operations/request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chroma/api_operations/request.rb b/lib/chroma/api_operations/request.rb index 7d03e62..61e8e99 100644 --- a/lib/chroma/api_operations/request.rb +++ b/lib/chroma/api_operations/request.rb @@ -118,7 +118,7 @@ def execute_request(method, url, params = {}, options = {}) request.content_type = "application/json" request.body = params.to_json if params.size > 0 request.basic_auth(uri.user, uri.password) if !uri.user.nil? - request['X-Chroma-Token'] = ENV.fetch('CHROMA_SERVER_AUTHN_CREDENTIALS', nil) if ENV["CHROMA_SERVER_AUTHN_CREDENTIALS"] + request['X-Chroma-Token'] = ENV.fetch('CHROMA_SERVER_AUTHN_CREDENTIALS', nil) if ENV.fetch('CHROMA_SERVER_AUTHN_CREDENTIALS', nil) request end end