-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `ses upload` subcommand can be used to upload yaml file with SES configuration to crowbar.
- Loading branch information
Showing
9 changed files
with
246 additions
and
0 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
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,54 @@ | ||
# | ||
# Copyright 2019, SUSE | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
module Crowbar | ||
module Client | ||
module App | ||
# | ||
# A Thor based CLI wrapper for SES commands | ||
# | ||
class Ses < Base | ||
desc "upload FILE", | ||
"Upload SES configuration file" | ||
|
||
long_desc <<-LONGDESC | ||
`upload FILE` will upload yaml file with SES configuration to the | ||
server. Data inside this file could be used later for integrating | ||
SES cluster with other services. | ||
LONGDESC | ||
|
||
# | ||
# SES config upload command | ||
# | ||
# It will upload yaml file with SES configuration to the server. | ||
# Data inside this file could be used later for integrating SES | ||
# cluster with other services. | ||
# | ||
# @param file [String] the path to the file | ||
# | ||
def upload(file) | ||
Command::Ses::Upload.new( | ||
*command_params( | ||
file: file | ||
) | ||
).execute | ||
rescue => e | ||
catch_errors(e) | ||
end | ||
end | ||
end | ||
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
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,29 @@ | ||
# | ||
# Copyright 2019, SUSE | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
module Crowbar | ||
module Client | ||
module Command | ||
# | ||
# Module for the SES command implementations | ||
# | ||
module Ses | ||
autoload :Upload, | ||
File.expand_path("../ses/upload", __FILE__) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2019, SUSE | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
module Crowbar | ||
module Client | ||
module Command | ||
module Ses | ||
# | ||
# Implementation for the SES config upload command | ||
# | ||
class Upload < Base | ||
def request | ||
args.file = | ||
case args.file | ||
when "-" | ||
stdin.to_io | ||
when File | ||
args.file | ||
else | ||
unless File.exist?(args.file) | ||
err "File #{args.file} does not exist." | ||
end | ||
File.new( | ||
args.file, | ||
File::RDONLY | ||
) | ||
end | ||
|
||
@request ||= Request::Ses::Upload.new( | ||
args | ||
) | ||
end | ||
|
||
def execute | ||
request.process do |request| | ||
case request.code | ||
when 200 | ||
say "Successfully uploaded SES configuration" | ||
else | ||
err request.parsed_response["error"] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
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
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,29 @@ | ||
# | ||
# Copyright 2019, SUSE | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
module Crowbar | ||
module Client | ||
module Request | ||
# | ||
# Module for the SES request implementations | ||
# | ||
module Ses | ||
autoload :Upload, | ||
File.expand_path("../ses/upload", __FILE__) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Copyright 2019, SUSE | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require "easy_diff" | ||
|
||
module Crowbar | ||
module Client | ||
module Request | ||
module Ses | ||
# | ||
# Implementation for the SES config upload request | ||
# | ||
class Upload < Base | ||
|
||
def content | ||
super.easy_merge!( | ||
sesconfig: { | ||
file: attrs.file | ||
} | ||
) | ||
end | ||
|
||
# | ||
# HTTP method that gets used by the request | ||
# | ||
# @return [Symbol] the method for the request | ||
# | ||
def method | ||
:post | ||
end | ||
|
||
# | ||
# Path to the API endpoint for the request | ||
# | ||
# @return [String] path to the API endpoint | ||
# | ||
def url | ||
[ | ||
"ses", | ||
"settings", | ||
"upload" | ||
].join("/") | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |