Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Snapshot Repository #1087

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def self.process_body(body)
:type => api_object['type'],
:compress => api_object['settings']['compress'],
:location => api_object['settings']['location'],
:container => api_object['settings']['container'],
:base_path => api_object['settings']['base_path'],
:client => api_object['settings']['client'],
:readonly => api_object['settigns']['readonly'],
:location_mode => api_object['settings']['location_mode'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new fields will need to be added as optional fields on the generate_body method below.

:chunk_size => api_object['settings']['chunk_size'],
:max_restore_rate => api_object['settings']['max_restore_rate'],
:max_snapshot_rate => api_object['settings']['max_snapshot_rate'],
Expand Down
30 changes: 29 additions & 1 deletion lib/puppet/type/elasticsearch_snapshot_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@
newproperty(:location) do
desc 'Repository location'
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like rubocop is complaining about trailing whitespace here.

newproperty(:client) do
defaultto 'default'
desc 'Azure client'
end

newproperty(:container) do
defaultto 'elasticsearch-snapshots'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should set a default value for this field. Instead it should be a conscious decision by the user as to what they want to call their Azure container.

desc 'Azure storage container'
end

newproperty(:base_path) do
desc 'Specifies the path within container to repository data.'
end

newproperty(:readonly) do
defaultto 'false'
desc 'Makes repository read-only.'
end

newproperty(:location_mode) do
defaultto 'primary_only'
desc 'primary_only or secondary_only. Note that if you set it to secondary_only, it will force readonly to true.'
end

newproperty(:chunk_size) do
desc 'File chunk size'
Expand All @@ -46,6 +70,10 @@
end

validate do
raise ArgumentError, 'Location is required.' if self[:location].nil?
if self[:type] == 'fs'
raise ArgumentError, 'Location is required.' if self[:location].nil?
elsif self[:type] == 'azure'
raise ArgumentError, 'Container is required.' if self[:container].nil?
end
end
end # of newtype
25 changes: 23 additions & 2 deletions manifests/snapshot_repository.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,22 @@
# Snapshot repository type.
#
# @param location
# Location of snapshots. Mandatory
# Location of snapshots.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is still mandatory when type => "fs", so we should state that.

#
# @param container
# Azure Container name.
#
# @param client
# Azure named client to use.
#
# @param base_path
# Azure path within container to repository data.
#
# @param readonly
# Makes Azure repository read-only.
#
# @param location_mode
# Azure location_mode.
#
# @param compress
# Compress the snapshot metadata files?
Expand All @@ -60,8 +75,13 @@
# @author Tyler Langlois <[email protected]>
#
define elasticsearch::snapshot_repository (
String $location,
Optional[String] $location = undef,
Enum['absent', 'present'] $ensure = 'present',
Optional[String] $client = undef,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you sort out the alignment on these lines? Should all align on =.

Optional[String] $container = undef,
Optional[String] $base_path = undef,
Optional[Boolean] $readonly = false,
Optional[String] $location_mode = undef,
Optional[String] $api_basic_auth_password = $elasticsearch::api_basic_auth_password,
Optional[String] $api_basic_auth_username = $elasticsearch::api_basic_auth_username,
Optional[Stdlib::Absolutepath] $api_ca_file = $elasticsearch::api_ca_file,
Expand All @@ -88,6 +108,7 @@
chunk_size => $chunk_size,
compress => $compress,
location => $location,
location => $location,
max_restore_rate => $max_restore_rate,
max_snapshot_rate => $max_snapshot_rate,
type => $repository_type,
Expand Down