-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Via system property path so we do not require a restart on new install or upgrade as the license will be directly loaded. cf: https://help.sonatype.com/en/installing-and-updating-licenses.html#installing-or-updating-a-license-using-a-system-property But also via the API directly for when the license needs to be updated as the system property path does not care about the license file being updated if a license is already installed.
- Loading branch information
1 parent
ee404d5
commit 19e4c94
Showing
5 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ Gemfile.lock | |
.kitchen/ | ||
.kitchen.local.yml | ||
.bundle/ | ||
bundle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
property :fingerprint, String, default: lazy { node['nexus3']['license_fingerprint'] } | ||
property :license, String, sensitive: true, default: lazy { node['nexus3']['license'] } | ||
property :api_client, ::Nexus3::Api, identity: true, desired_state: false, default: lazy { ::Nexus3::Api.default(node) } | ||
|
||
load_current_value do |_desired| | ||
begin | ||
config = api_client.request(:get, 'system/license') | ||
current_value_does_not_exist! if config.nil? | ||
fingerprint JSON.parse(config)['fingerprint'] | ||
# Nexus returns a 402 Payment Required when there is no license installed, we get an ApiError | ||
rescue ::LoadError, ::Nexus3::ApiError => e | ||
::Chef::Log.warn "A '#{e.class}' occured: #{e.message}" | ||
current_value_does_not_exist! | ||
end | ||
end | ||
|
||
action :update do | ||
converge_if_changed :fingerprint do | ||
converge_by('Uploading license') do | ||
new_resource.api_client.request( | ||
:post, 'system/license', data: ::Base64.decode64(new_resource.license), content_type: 'application/octet-stream' | ||
) | ||
end | ||
end | ||
end | ||
|
||
action :delete do | ||
unless current_resource.nil? | ||
converge_by('Unregistering license') do | ||
new_resource.api_client.request(:delete, 'system/license') | ||
end | ||
end | ||
end | ||
|
||
action_class do | ||
def whyrun_supported? | ||
true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters