Skip to content

Commit

Permalink
Make Manage API params usable as options
Browse files Browse the repository at this point in the history
  • Loading branch information
manue1 committed May 22, 2024
1 parent 42d013a commit 271cc14
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
18 changes: 17 additions & 1 deletion lib/octokit/configurable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ module Configurable
# @return [String] An admin password set up for your GitHub Enterprise management console
# @!attribute management_console_endpoint
# @return [String] Base URL for API requests to the GitHub Enterprise management console
# @!attribute manage_ghes_endpoint
# @return [String] Base URL for API requests to the GitHub Enterprise Server Manage API
# @!attribute manage_ghes_username
# @return [String] API username for requests to the GitHub Enterprise Server Manage API
# @!attribute manage_ghes_password
# @return [String] API user password for requests to the GitHub Enterprise Server Manage API
# @!attribute middleware
# @see https:/lostisland/faraday
# @return [Faraday::Builder or Faraday::RackBuilder] Configure middleware for Faraday
Expand Down Expand Up @@ -59,7 +65,10 @@ module Configurable
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :ssl_verify_mode, :user_agent
attr_writer :password, :web_endpoint, :api_endpoint, :login,
:management_console_endpoint, :management_console_password
:management_console_endpoint, :management_console_password,
:manage_ghes_endpoint,
:manage_ghes_username,
:manage_ghes_password

class << self
# List of configurable keys for {Octokit::Client}
Expand All @@ -77,6 +86,9 @@ def keys
login
management_console_endpoint
management_console_password
manage_ghes_endpoint
manage_ghes_username
manage_ghes_password
middleware
netrc
netrc_file
Expand Down Expand Up @@ -126,6 +138,10 @@ def management_console_endpoint
File.join(@management_console_endpoint, '')
end

def manage_ghes_endpoint
File.join(@manage_ghes_endpoint, '')
end

# Base URL for generated web URLs
#
# @return [String] Default: https:/
Expand Down
18 changes: 18 additions & 0 deletions lib/octokit/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ def management_console_endpoint
ENV.fetch('OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT', nil)
end

# Default GHES Manage API endpoint from ENV
# @return [String]
def manage_ghes_endpoint
ENV.fetch('OCTOKIT_MANAGE_GHES_ENDPOINT', nil)
end

# Default GHES Manage API username from ENV
# @return [String]
def manage_ghes_username
ENV.fetch('OCTOKIT_MANAGE_GHES_USERNAME', nil)
end

# Default GHES Manage API password from ENV
# @return [String]
def manage_ghes_password
ENV.fetch('OCTOKIT_MANAGE_GHES_PASSWORD', nil)
end

# Default options for Faraday::Connection
# @return [Hash]
def connection_options
Expand Down
16 changes: 8 additions & 8 deletions lib/octokit/manage_ghes_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def endpoint
manage_ghes_endpoint
end

# Set Manage GHES API endpoint
#
# @param value [String] Manage GHES API endpoint
def manage_ghes_endpoint=(value)
reset_agent
@manage_ghes_endpoint = value
end

# Set Manage GHES API username
#
# @param value [String] Manage GHES API username
Expand All @@ -52,13 +60,5 @@ def manage_ghes_password=(value)
reset_agent
@manage_ghes_password = value
end

# Set Manage GHES API endpoint
#
# @param value [String] Manage GHES API endpoint
def manage_ghes_endpoint=(value)
reset_agent
@manage_ghes_endpoint = value
end
end
end

0 comments on commit 271cc14

Please sign in to comment.