rubyoctopus 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f4b94d7686aebfc20a914a94f7b91d12babc320cc26e9c44d7bcbc0029c13f4c
4
+ data.tar.gz: ab1ecc8c2f71af3e1d61b36bd34384197ed7e122ba7a35f49b2666546d5924f4
5
+ SHA512:
6
+ metadata.gz: '01691662ffc474f98b30ace2bea769d0ebf32d82e1437189c4be2b2b94944298daac5a0f6e3b9684ec2a9153a943c5863af25bd81a54518e81a893305b658676'
7
+ data.tar.gz: 3493475ed86fc5d3163154b526430855a12cfdda453272639573db468253ffa75469399f58e473143ff2e1655737e49d3287527433c737415e26aded3621f9d8
@@ -0,0 +1,17 @@
1
+ # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
+ ARG VARIANT=2-bullseye
3
+ FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
4
+
5
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
6
+ ARG NODE_VERSION="none"
7
+ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
8
+
9
+ # [Optional] Uncomment this section to install additional OS packages.
10
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
11
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
12
+
13
+ # [Optional] Uncomment this line to install additional gems.
14
+ RUN gem install bundler
15
+
16
+ # [Optional] Uncomment this line to install global node packages.
17
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,43 @@
1
+ # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
+ ARG VARIANT=2-bullseye
3
+ FROM ruby:${VARIANT}
4
+
5
+ # Copy library scripts to execute
6
+ COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
7
+
8
+ # [Option] Install zsh
9
+ ARG INSTALL_ZSH="false"
10
+ # [Option] Upgrade OS packages to their latest versions
11
+ ARG UPGRADE_PACKAGES="true"
12
+ # Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
13
+ ARG USERNAME=vscode
14
+ ARG USER_UID=1000
15
+ ARG USER_GID=$USER_UID
16
+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
17
+ # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
18
+ && apt-get purge -y imagemagick imagemagick-6-common \
19
+ # Install common packages, non-root user, rvm, core build tools
20
+ && bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
21
+ && bash /tmp/library-scripts/ruby-debian.sh "none" "${USERNAME}" "true" "true" \
22
+ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
23
+
24
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
25
+ ARG NODE_VERSION="none"
26
+ ENV NVM_DIR=/usr/local/share/nvm
27
+ ENV NVM_SYMLINK_CURRENT=true \
28
+ PATH=${NVM_DIR}/current/bin:${PATH}
29
+ RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \
30
+ && apt-get clean -y && rm -rf /var/lib/apt/lists/*
31
+
32
+ # Remove library scripts for final image
33
+ RUN rm -rf /tmp/library-scripts
34
+
35
+ # [Optional] Uncomment this section to install additional OS packages.
36
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
37
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
38
+
39
+ # [Optional] Uncomment this line to install additional gems.
40
+ # RUN gem install <your-gem-names-here>
41
+
42
+ # [Optional] Uncomment this line to install global node packages.
43
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,36 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/ruby
3
+ {
4
+ "name": "Ruby",
5
+ "build": {
6
+ "dockerfile": "Dockerfile",
7
+ "args": {
8
+ // Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
9
+ // Append -bullseye or -buster to pin to an OS version.
10
+ // Use -bullseye variants on local on arm64/Apple Silicon.
11
+ "VARIANT": "2.6",
12
+ // Options
13
+ "NODE_VERSION": "none"
14
+ }
15
+ },
16
+
17
+ // Set *default* container specific settings.json values on container create.
18
+ "settings": {},
19
+
20
+ // Add the IDs of extensions you want installed when the container is created.
21
+ "extensions": [
22
+ "rebornix.Ruby"
23
+ ],
24
+
25
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
26
+ // "forwardPorts": [],
27
+
28
+ // Use 'postCreateCommand' to run commands after the container is created.
29
+ "postCreateCommand": "bin/setup",
30
+
31
+ // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
32
+ "remoteUser": "vscode",
33
+ "features": {
34
+ "git": "latest"
35
+ }
36
+ }
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 2.6
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Style/StringLiteralsInInterpolation:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Layout/LineLength:
14
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-01-26
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rubyoctopus.gemspec
6
+ gemspec
7
+
8
+ # rubocop:disable Style/HashSyntax
9
+ gem "rubocop", "~> 1.21", :group => %i[development test]
10
+ # rubocop:enable Style/HashSyntax
11
+
12
+ group :development do
13
+ gem "dotenv"
14
+ end
15
+
16
+ group :test do
17
+ gem "simplecov", require: false
18
+
19
+ gem "rake", "~> 13.0"
20
+
21
+ gem "rspec", "~> 3.0"
22
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,96 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubyoctopus (0.1.0)
5
+ faraday (~> 1.0)
6
+ faraday_middleware (~> 1.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ diff-lcs (1.5.0)
13
+ docile (1.4.0)
14
+ dotenv (2.7.6)
15
+ faraday (1.9.3)
16
+ faraday-em_http (~> 1.0)
17
+ faraday-em_synchrony (~> 1.0)
18
+ faraday-excon (~> 1.1)
19
+ faraday-httpclient (~> 1.0)
20
+ faraday-multipart (~> 1.0)
21
+ faraday-net_http (~> 1.0)
22
+ faraday-net_http_persistent (~> 1.0)
23
+ faraday-patron (~> 1.0)
24
+ faraday-rack (~> 1.0)
25
+ faraday-retry (~> 1.0)
26
+ ruby2_keywords (>= 0.0.4)
27
+ faraday-em_http (1.0.0)
28
+ faraday-em_synchrony (1.0.0)
29
+ faraday-excon (1.1.0)
30
+ faraday-httpclient (1.0.1)
31
+ faraday-multipart (1.0.3)
32
+ multipart-post (>= 1.2, < 3)
33
+ faraday-net_http (1.0.1)
34
+ faraday-net_http_persistent (1.2.0)
35
+ faraday-patron (1.0.0)
36
+ faraday-rack (1.0.0)
37
+ faraday-retry (1.0.3)
38
+ faraday_middleware (1.2.0)
39
+ faraday (~> 1.0)
40
+ multipart-post (2.1.1)
41
+ parallel (1.21.0)
42
+ parser (3.1.0.0)
43
+ ast (~> 2.4.1)
44
+ rainbow (3.1.1)
45
+ rake (13.0.6)
46
+ regexp_parser (2.2.0)
47
+ rexml (3.2.5)
48
+ rspec (3.10.0)
49
+ rspec-core (~> 3.10.0)
50
+ rspec-expectations (~> 3.10.0)
51
+ rspec-mocks (~> 3.10.0)
52
+ rspec-core (3.10.1)
53
+ rspec-support (~> 3.10.0)
54
+ rspec-expectations (3.10.2)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.10.0)
57
+ rspec-mocks (3.10.2)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.10.0)
60
+ rspec-support (3.10.3)
61
+ rubocop (1.24.1)
62
+ parallel (~> 1.10)
63
+ parser (>= 3.0.0.0)
64
+ rainbow (>= 2.2.2, < 4.0)
65
+ regexp_parser (>= 1.8, < 3.0)
66
+ rexml
67
+ rubocop-ast (>= 1.15.1, < 2.0)
68
+ ruby-progressbar (~> 1.7)
69
+ unicode-display_width (>= 1.4.0, < 3.0)
70
+ rubocop-ast (1.15.1)
71
+ parser (>= 3.0.1.1)
72
+ ruby-progressbar (1.11.0)
73
+ ruby2_keywords (0.0.5)
74
+ simplecov (0.21.2)
75
+ docile (~> 1.1)
76
+ simplecov-html (~> 0.11)
77
+ simplecov_json_formatter (~> 0.1)
78
+ simplecov-html (0.12.3)
79
+ simplecov_json_formatter (0.1.3)
80
+ unicode-display_width (2.1.0)
81
+
82
+ PLATFORMS
83
+ aarch64-linux
84
+ universal-darwin-20
85
+ x86_64-linux
86
+
87
+ DEPENDENCIES
88
+ dotenv
89
+ rake (~> 13.0)
90
+ rspec (~> 3.0)
91
+ rubocop (~> 1.21)
92
+ rubyoctopus!
93
+ simplecov
94
+
95
+ BUNDLED WITH
96
+ 2.3.5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Ruby-Octopus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ [![Ruby](https://github.com/Ruby-Octopus/ruby-octopus/actions/workflows/main.yml/badge.svg)](https://github.com/Ruby-Octopus/ruby-octopus/actions/workflows/main.yml)
2
+ # RubyOctopus
3
+
4
+ RubyOctopus is a REST client for [Octopus Deploy](https://octopus.com/) written in Ruby.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'rubyoctopus'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install rubyoctopus
21
+
22
+ ## Usage
23
+
24
+ Create an instance of the `OctopusClient` class by passing your Octopus API URL and an API key to it.
25
+
26
+ ```ruby
27
+ example = RubyOctopus::OctopusClient.new("octopus_domain_here/api", "API-key_goes_here")
28
+ ```
29
+
30
+ TODO: Add more examples, as the class gets built out more.
31
+
32
+ ## Development
33
+
34
+ (OPTIONAL) Can use Visual Studio Code to Open Folder in Container via their Remote - Containers extension.
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Ruby-Octopus/ruby-octopus.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyOctopus
4
+ module Model
5
+ # A class modeling an Environment in Octopus.
6
+ class EnvironmentResource
7
+ attr_accessor :id, :space_id, :name, :description, :sort_order, :use_guided_failure,
8
+ :allow_dynamic_infrastructure, :extension_settings, :links
9
+
10
+ def initialize(attribute_values)
11
+ @id = attribute_values["Id"]
12
+ @space_id = attribute_values["SpaceId"]
13
+ @name = attribute_values["Name"]
14
+ @description = attribute_values["Description"]
15
+ @sort_order = attribute_values["SortOrder"]
16
+ @use_guided_failure = attribute_values["UseGuidedFailure"]
17
+ @allow_dynamic_infrastructure = attribute_values["AllowDynamicInfrastructure"]
18
+ @extension_settings = attribute_values["ExtensionSettings"]
19
+ @links = attribute_values["Links"]
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "octopusconnection"
4
+
5
+ module RubyOctopus
6
+ # Base class to use to perform actions against an Octopus instance.
7
+ class OctopusClient
8
+ attr_reader :connection
9
+
10
+ def initialize(url, api_key)
11
+ @connection = OctopusConnection.new(url, api_key)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday_middleware"
5
+
6
+ module RubyOctopus
7
+ # Base class to use to perform actions against an Octopus instance.
8
+ class OctopusConnection
9
+ # Users might want to check which domain an instance is targeting.
10
+ attr_reader :url
11
+
12
+ def initialize(url, api_key)
13
+ @url = url
14
+ @conn = Faraday.new(
15
+ url: url,
16
+ headers: { "X-Octopus-ApiKey": api_key }
17
+ ) do |faraday|
18
+ faraday.adapter Faraday.default_adapter
19
+ faraday.response :json
20
+ end
21
+ end
22
+
23
+ def get(resource_type)
24
+ @conn.get(resource_type)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyOctopus
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rubyoctopus/version"
4
+ require_relative "rubyoctopus/octopusclient"
5
+ require_relative "rubyoctopus/model/environmentresource"
6
+
7
+ module RubyOctopus
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dotenv/load"
4
+
5
+ require_relative "../lib/rubyoctopus"
6
+
7
+ # Set these values in your .env
8
+ client = RubyOctopus::OctopusClient.new(ENV["OCTOPUS_URL"], ENV["OCTOPUS_API_KEY"])
9
+
10
+ # Gets the first page of environments from the server
11
+ response = client.connection.get("Environments")
12
+ puts "Received a #{response.status} response from server"
13
+
14
+ environments = if response.status == 200
15
+ response.body["Items"].map { |item| RubyOctopus::Model::EnvironmentResource.new(item) }
16
+ end
17
+
18
+ environments.each { |environment| puts "#{environment.id}: #{environment.name}" }
@@ -0,0 +1,4 @@
1
+ module RubyOctopus
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubyoctopus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mason Emery
8
+ - Jeff Merckens
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2022-01-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday_middleware
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.2'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.2'
42
+ description:
43
+ email:
44
+ - thepolytheist@users.noreply.github.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".devcontainer/Dockerfile"
50
+ - ".devcontainer/base.Dockerfile"
51
+ - ".devcontainer/devcontainer.json"
52
+ - ".rspec"
53
+ - ".rubocop.yml"
54
+ - CHANGELOG.md
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - lib/rubyoctopus.rb
61
+ - lib/rubyoctopus/model/environmentresource.rb
62
+ - lib/rubyoctopus/octopusclient.rb
63
+ - lib/rubyoctopus/octopusconnection.rb
64
+ - lib/rubyoctopus/version.rb
65
+ - samples/get_environments.rb
66
+ - sig/rubyoctopus.rbs
67
+ homepage: https://github.com/Ruby-Octopus/ruby-octopus
68
+ licenses: []
69
+ metadata:
70
+ homepage_uri: https://github.com/Ruby-Octopus/ruby-octopus
71
+ source_code_uri: https://github.com/Ruby-Octopus/ruby-octopus
72
+ changelog_uri: https://github.com/Ruby-Octopus/ruby-octopus/blob/main/CHANGELOG.md
73
+ github_repo: git@github.com:Ruby-Octopus/ruby-octopus.git
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 2.6.0
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 3.0.3.1
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: RubyOctopus is a REST client for Octopus Deploy written in Ruby.
93
+ test_files: []