diff --git a/.devcontainer.json b/.devcontainer.json index a44ea85..b823dc1 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -40,12 +40,20 @@ "redhat.vscode-yaml", "mutantdino.resourcemonitor", "technosophos.vscode-helm", - "crystal-lang-tools.crystal-lang" + "crystal-lang-tools.crystal-lang", + "karunamurti.rspec-snippets", + "walkme.Ruby-extension-pack", + "groksrc.ruby", + "miguel-savignano.ruby-symbols" ], "recommendations": [ "GitHub.copilot", "GitHub.copilot-chat", - "JeroenV.github-copilot-with-context" + "JeroenV.github-copilot-with-context", + "rubocop.vscode-rubocop", + "Shopify.ruby-lsp", + "castwide.solargraph", + "hoovercj.ruby-linter" ], "settings": { "editor.tabSize": 2, @@ -115,6 +123,29 @@ "explorer.autoReveal": false, "explorer.confirmDragAndDrop": false, + "ruby.format": "rubocop", + "ruby.lint": { + "ruby": true, + "rubocop": true + }, + + "rubyLsp.yjit": true, + + "rubyLsp.enableExperimentalFeatures": true, + "rubyLsp.enabledFeatures": { + "completion": true, + "diagnostics": true, + "documentSymbol": true, + "formatting": true, + "hover": true, + "references": true, + "rename": true, + "selectionRange": true, + "workspaceSymbol": true + }, + + "solargraph.formatting": true, + "[json]": { "editor.defaultFormatter": "vscode.json-language-features" }, diff --git a/.gitignore b/.gitignore index f23147d..89376b8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,13 +3,8 @@ /_yardoc/ /coverage/ /doc/ -/pkg/ /spec/reports/ /tmp/ -/dist/ -/docs/ -/lib/ -/bin/ .DS_Store .env.vars .zsh_history diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..96c00fa --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,225 @@ +require: + - rubocop-rake + - rubocop-rspec + +AllCops: + NewCops: enable + +Gemspec/DeprecatedAttributeAssignment: # new in 1.30 + Enabled: true +Gemspec/DevelopmentDependencies: # new in 1.44 + Enabled: false +Gemspec/RequireMFA: # new in 1.23 + Enabled: true +Layout/LineContinuationLeadingSpace: # new in 1.31 + Enabled: true +Layout/LineContinuationSpacing: # new in 1.31 + Enabled: true +Layout/LineEndStringConcatenationIndentation: # new in 1.18 + Enabled: true +Layout/SpaceBeforeBrackets: # new in 1.7 + Enabled: true +Lint/AmbiguousAssignment: # new in 1.7 + Enabled: true +Lint/AmbiguousOperatorPrecedence: # new in 1.21 + Enabled: true +Lint/AmbiguousRange: # new in 1.19 + Enabled: true +Lint/ConstantOverwrittenInRescue: # new in 1.31 + Enabled: true +Lint/DeprecatedConstants: # new in 1.8 + Enabled: true +Lint/DuplicateBranch: # new in 1.3 + Enabled: true +Lint/DuplicateMagicComment: # new in 1.37 + Enabled: true +Lint/DuplicateMatchPattern: # new in 1.50 + Enabled: true +Lint/DuplicateRegexpCharacterClassElement: # new in 1.1 + Enabled: true +Lint/EmptyBlock: # new in 1.1 + Enabled: true +Lint/EmptyClass: # new in 1.3 + Enabled: true +Lint/EmptyInPattern: # new in 1.16 + Enabled: true +Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21 + Enabled: true +Lint/ItWithoutArgumentsInBlock: # new in 1.59 + Enabled: true +Lint/LambdaWithoutLiteralBlock: # new in 1.8 + Enabled: true +Lint/LiteralAssignmentInCondition: # new in 1.58 + Enabled: true +Lint/MixedCaseRange: # new in 1.53 + Enabled: true +Lint/NoReturnInBeginEndBlocks: # new in 1.2 + Enabled: true +Lint/NonAtomicFileOperation: # new in 1.31 + Enabled: true +Lint/NumberedParameterAssignment: # new in 1.9 + Enabled: true +Lint/OrAssignmentToConstant: # new in 1.9 + Enabled: true +Lint/RedundantDirGlobSort: # new in 1.8 + Enabled: true +Lint/RedundantRegexpQuantifiers: # new in 1.53 + Enabled: true +Lint/RefinementImportMethods: # new in 1.27 + Enabled: true +Lint/RequireRangeParentheses: # new in 1.32 + Enabled: true +Lint/RequireRelativeSelfPath: # new in 1.22 + Enabled: true +Lint/SymbolConversion: # new in 1.9 + Enabled: true +Lint/ToEnumArguments: # new in 1.1 + Enabled: true +Lint/TripleQuotes: # new in 1.9 + Enabled: true +Lint/UnexpectedBlockArity: # new in 1.5 + Enabled: true +Lint/UnmodifiedReduceAccumulator: # new in 1.1 + Enabled: true +Lint/UselessRescue: # new in 1.43 + Enabled: true +Lint/UselessRuby2Keywords: # new in 1.23 + Enabled: true +Metrics/CollectionLiteralLength: # new in 1.47 + Enabled: true +Naming/BlockForwarding: # new in 1.24 + Enabled: true +Security/CompoundHash: # new in 1.28 + Enabled: true +Security/IoMethods: # new in 1.22 + Enabled: true +Style/ArgumentsForwarding: # new in 1.1 + Enabled: true +Style/ArrayIntersect: # new in 1.40 + Enabled: true +Style/CollectionCompact: # new in 1.2 + Enabled: true +Style/ComparableClamp: # new in 1.44 + Enabled: true +Style/ConcatArrayLiterals: # new in 1.41 + Enabled: true +Style/DataInheritance: # new in 1.49 + Enabled: true +Style/DirEmpty: # new in 1.48 + Enabled: true +Style/DocumentDynamicEvalDefinition: # new in 1.1 + Enabled: true +Style/EmptyHeredoc: # new in 1.32 + Enabled: true +Style/EndlessMethod: # new in 1.8 + Enabled: true +Style/EnvHome: # new in 1.29 + Enabled: true +Style/ExactRegexpMatch: # new in 1.51 + Enabled: true +Style/FetchEnvVar: # new in 1.28 + Enabled: true +Style/FileEmpty: # new in 1.48 + Enabled: true +Style/FileRead: # new in 1.24 + Enabled: true +Style/FileWrite: # new in 1.24 + Enabled: true +Style/HashConversion: # new in 1.10 + Enabled: true +Style/HashExcept: # new in 1.7 + Enabled: true +Style/IfWithBooleanLiteralBranches: # new in 1.9 + Enabled: true +Style/InPatternThen: # new in 1.16 + Enabled: true +Style/MagicCommentFormat: # new in 1.35 + Enabled: true +Style/MapCompactWithConditionalBlock: # new in 1.30 + Enabled: true +Style/MapIntoArray: # new in 1.63 + Enabled: true +Style/MapToHash: # new in 1.24 + Enabled: true +Style/MapToSet: # new in 1.42 + Enabled: true +Style/MinMaxComparison: # new in 1.42 + Enabled: true +Style/MultilineInPatternThen: # new in 1.16 + Enabled: true +Style/NegatedIfElseCondition: # new in 1.2 + Enabled: true +Style/NestedFileDirname: # new in 1.26 + Enabled: true +Style/NilLambda: # new in 1.3 + Enabled: true +Style/NumberedParameters: # new in 1.22 + Enabled: true +Style/NumberedParametersLimit: # new in 1.22 + Enabled: true +Style/ObjectThen: # new in 1.28 + Enabled: true +Style/OpenStructUse: # new in 1.23 + Enabled: true +Style/OperatorMethodCall: # new in 1.37 + Enabled: true +Style/QuotedSymbols: # new in 1.16 + Enabled: true +Style/RedundantArgument: # new in 1.4 + Enabled: true +Style/RedundantArrayConstructor: # new in 1.52 + Enabled: true +Style/RedundantConstantBase: # new in 1.40 + Enabled: true +Style/RedundantCurrentDirectoryInPath: # new in 1.53 + Enabled: true +Style/RedundantDoubleSplatHashBraces: # new in 1.41 + Enabled: true +Style/RedundantEach: # new in 1.38 + Enabled: true +Style/RedundantFilterChain: # new in 1.52 + Enabled: true +Style/RedundantHeredocDelimiterQuotes: # new in 1.45 + Enabled: true +Style/RedundantInitialize: # new in 1.27 + Enabled: true +Style/RedundantLineContinuation: # new in 1.49 + Enabled: true +Style/RedundantRegexpArgument: # new in 1.53 + Enabled: true +Style/RedundantRegexpConstructor: # new in 1.52 + Enabled: true +Style/RedundantSelfAssignmentBranch: # new in 1.19 + Enabled: true +Style/RedundantStringEscape: # new in 1.37 + Enabled: true +Style/ReturnNilInPredicateMethodDefinition: # new in 1.53 + Enabled: true +Style/SelectByRegexp: # new in 1.22 + Enabled: true +Style/SingleLineDoEndBlock: # new in 1.57 + Enabled: true +Style/StringChars: # new in 1.12 + Enabled: true +Style/SuperWithArgsParentheses: # new in 1.58 + Enabled: true +Style/SwapValues: # new in 1.1 + Enabled: true +Style/YAMLFileRead: # new in 1.53 + Enabled: true +Style/StringLiterals: + Enabled: false +Layout/LineLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: true + Exclude: + - bin/bundle +Metrics/PerceivedComplexity: + Enabled: true + Exclude: + - bin/bundle +Metrics/MethodLength: + Enabled: true + Exclude: + - bin/bundle diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 77f658d..7014ee6 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,73 +2,83 @@ ## Our Pledge -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards -Examples of behavior that contributes to creating a positive environment -include: +Examples of behavior that contributes to a positive environment for our community include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community -Examples of unacceptable behavior by participants include: +Examples of unacceptable behavior include: -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission +* Publishing others' private information, such as a physical or email + address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting -## Our Responsibilities +## Enforcement Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at vito@botta.me. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at vito@botta.me. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [https://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, +available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org -[homepage]: https://contributor-covenant.org -[version]: https://contributor-covenant.org/version/1/4/ +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. diff --git a/Dockerfile.dev b/Dockerfile.dev index 3c40e12..a1ae620 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM jruby:9.4.6.0-jre8 +FROM ruby:3.3.0-slim-bookworm RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/tmp/cache/apt-cache \ --mount=type=cache,id=dev-apt-lib,sharing=locked,target=/tmp/cache/apt-lib \ diff --git a/Gemfile b/Gemfile index 19e98a0..4cfe17b 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,5 @@ source "https://rubygems.org" -gem "http" -gem "llhttp-ffi", "~> 0.5.0" +# Specify your gem's dependencies in hetzner-k3s.gemspec +gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 95ad221..8a2da3e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,35 +1,79 @@ +PATH + remote: . + specs: + hetzner-k3s (2.0.0) + GEM remote: https://rubygems.org/ specs: - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) - base64 (0.2.0) - domain_name (0.6.20240107) - ffi (1.16.3-java) - ffi-compiler (1.3.2) - ffi (>= 1.15.5) - rake - http (5.2.0) - addressable (~> 2.8) - base64 (~> 0.1) - http-cookie (~> 1.0) - http-form_data (~> 2.2) - llhttp-ffi (~> 0.5.0) - http-cookie (1.0.5) - domain_name (~> 0.5) - http-form_data (2.3.0) - llhttp-ffi (0.5.0) - ffi-compiler (~> 1.0) - rake (~> 13.0) - public_suffix (5.0.5) + ast (2.4.2) + diff-lcs (1.5.1) + json (2.7.2) + json (2.7.2-java) + language_server-protocol (3.17.0.3) + parallel (1.24.0) + parser (3.3.0.5) + ast (~> 2.4.1) + racc + racc (1.7.3) + racc (1.7.3-java) + rainbow (3.1.1) rake (13.2.1) + regexp_parser (2.9.0) + rexml (3.2.6) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rubocop (1.63.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) + rubocop-capybara (2.20.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.25.1) + rubocop (~> 1.41) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (2.29.1) + rubocop (~> 1.40) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.28.3) + rubocop (~> 1.40) + ruby-progressbar (1.13.0) + unicode-display_width (2.5.0) PLATFORMS + aarch64-linux universal-java-1.8 DEPENDENCIES - http - llhttp-ffi (~> 0.5.0) + hetzner-k3s! + rake (~> 13.2, >= 13.2.1) + rspec (~> 3.13) + rubocop (~> 1.63, >= 1.63.1) + rubocop-rake (~> 0.6.0) + rubocop-rspec (~> 2.29, >= 2.29.1) BUNDLED WITH 2.5.9 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..cca7175 --- /dev/null +++ b/Rakefile @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require "bundler/gem_tasks" +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +require "rubocop/rake_task" + +RuboCop::RakeTask.new + +task default: %i[spec rubocop] diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..b5c77ab --- /dev/null +++ b/bin/console @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "bundler/setup" +require "hetzner/k3s" + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +require "irb" +IRB.start(__FILE__) diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..4eb7d7b --- /dev/null +++ b/bin/rake @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rake", "rake") diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 0000000..cb53ebe --- /dev/null +++ b/bin/rspec @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..369a05b --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rubocop' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..dce67d8 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install + +# Do any other automated setup that you need to do here diff --git a/config/warble.rb b/config/warble.rb deleted file mode 100644 index f331af1..0000000 --- a/config/warble.rb +++ /dev/null @@ -1,182 +0,0 @@ -# Disable Rake-environment-task framework detection by uncommenting/setting to false -# Warbler.framework_detection = false - -# Warbler web application assembly configuration file -Warbler::Config.new do |config| - # Features: additional options controlling how the jar is built. - # Currently the following features are supported: - # - *gemjar*: package the gem repository in a jar file in WEB-INF/lib - # - *executable*: embed a web server and make the war executable - # - *runnable*: allows to run bin scripts e.g. `java -jar my.war -S rake -T` - # - *compiled*: compile .rb files to .class files - config.features = %w(runnable compiled) - - # Application directories to be included in the webapp. - config.dirs = %w(bin lib) - - # Additional files/directories to include, above those in config.dirs - # config.includes = FileList["db"] - - # Additional files/directories to exclude - # config.excludes = FileList["lib/tasks/*"] - - # Additional Java .jar files to include. Note that if .jar files are placed - # in lib (and not otherwise excluded) then they need not be mentioned here. - # JRuby and JRuby-Rack are pre-loaded in this list. Be sure to include your - # own versions if you directly set the value - # config.java_libs += FileList["lib/java/*.jar"] - - # Loose Java classes and miscellaneous files to be included. - # config.java_classes = FileList["target/classes/**.*"] - - # One or more pathmaps defining how the java classes should be copied into - # the archive. The example pathmap below accompanies the java_classes - # configuration above. See http://rake.rubyforge.org/classes/String.html#M000017 - # for details of how to specify a pathmap. - # config.pathmaps.java_classes << "%{target/classes/,}p" - - # Bundler support is built-in. If Warbler finds a Gemfile in the - # project directory, it will be used to collect the gems to bundle - # in your application. If you wish to explicitly disable this - # functionality, uncomment here. - config.bundler = true - - # An array of Bundler groups to avoid including in the war file. - # Defaults to ["development", "test", "assets"]. - # config.bundle_without = [] - - # Other gems to be included. If you don't use Bundler or a gemspec - # file, you need to tell Warbler which gems your application needs - # so that they can be packaged in the archive. - # For Rails applications, the Rails gems are included by default - # unless the vendor/rails directory is present. - # config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"] - # config.gems << "tzinfo" - - # Uncomment this if you don't want to package rails gem. - # config.gems -= ["rails"] - - # The most recent versions of gems are used. - # You can specify versions of gems by using a hash assignment: - # config.gems["rails"] = "4.2.5" - - # You can also use regexps or Gem::Dependency objects for flexibility or - # finer-grained control. - # config.gems << /^sinatra-/ - # config.gems << Gem::Dependency.new("sinatra", "= 1.4.7") - - # Include gem dependencies not mentioned specifically. Default is - # true, uncomment to turn off. - # config.gem_dependencies = false - - # Array of regular expressions matching relative paths in gems to be - # excluded from the war. Defaults to empty, but you can set it like - # below, which excludes test files. - # config.gem_excludes = [/^(test|spec)\//] - - # Pathmaps for controlling how application files are copied into the archive - # config.pathmaps.application = ["WEB-INF/%p"] - - # Name of the archive (without the extension). Defaults to the basename - # of the project directory. - config.jar_name = "hetzner-k3s" - - # File extension for the archive. Defaults to either 'jar' or 'war'. - config.jar_extension = "jar" - - # Destionation for the created archive. Defaults to project's root directory. - config.autodeploy_dir = "dist/" - - # Name of the MANIFEST.MF template for the war file. Defaults to a simple - # MANIFEST.MF that contains the version of Warbler used to create the war file. - # config.manifest_file = "config/MANIFEST.MF" - - # When using the 'compiled' feature and specified, only these Ruby - # files will be compiled. Default is to compile all \.rb files in - # the application. - # config.compiled_ruby_files = FileList['app/**/*.rb'] - - # Determines if ruby files in supporting gems will be compiled. - # Ignored unless compile feature is used. - config.compile_gems = true - - # When set it specify the bytecode version for compiled class files - # config.bytecode_version = "1.6" - - # When set to true, Warbler will override the value of ENV['GEM_HOME'] even it - # has already been set. When set to false it will use any existing value of - # GEM_HOME if it is set. - # config.override_gem_home = true - - # Allows for specifing custom executables - # config.executable = ["rake", "bin/rake"] - - # Sets default (prefixed) parameters for the executables - # config.executable_params = "do:something" - - # If set to true, moves jar files into WEB-INF/lib. Prior to version 1.4.2 of Warbler this was done - # by default. But since 1.4.2 this config defaults to false. It may need to be set to true for - # web servers that do not explode the WAR file. - # Alternatively, this option can be set to a regular expression, which will - # act as a jar selector -- only jar files that match the pattern will be - # included in the archive. - # config.move_jars_to_webinf_lib = false - - # === War files only below here === - - # Embedded webserver to use with the 'executable' feature. Currently supported - # webservers are: - # - *jetty* - Embedded Jetty from Eclipse - # config.webserver = 'jetty' - - # Path to the pre-bundled gem directory inside the war file. Default - # is 'WEB-INF/gems'. Specify path if gems are already bundled - # before running Warbler. This also sets 'gem.path' inside web.xml. - # config.gem_path = "WEB-INF/vendor/bundler_gems" - - # Files for WEB-INF directory (next to web.xml). This contains - # web.xml by default. If there is an .erb-File it will be processed - # with webxml-config. You may want to exclude this file via - # config.excludes. - # config.webinf_files += FileList["jboss-web.xml"] - - # Files to be included in the root of the webapp. Note that files in public - # will have the leading 'public/' part of the path stripped during staging. - # config.public_html = FileList["public/**/*", "doc/**/*"] - - # Pathmaps for controlling how public HTML files are copied into the .war - # config.pathmaps.public_html = ["%{public/,}p"] - - # Value of RAILS_ENV for the webapp -- default as shown below - # config.webxml.rails.env = ENV['RAILS_ENV'] || 'production' - - # Public ROOT mapping, by default assets are copied into .war ROOT directory. - # config.public.root = '' - - # Application booter to use, either :rack or :rails (autodetected by default) - # config.webxml.booter = :rails - - # When using the :rack booter, "Rackup" script to use. - # - For 'rackup.path', the value points to the location of the rackup - # script in the web archive file. You need to make sure this file - # gets included in the war, possibly by adding it to config.includes - # or config.webinf_files above. - # - For 'rackup', the rackup script you provide as an inline string - # is simply embedded in web.xml. - # The script is evaluated in a Rack::Builder to load the application. - # Examples: - # config.webxml.rackup.path = 'WEB-INF/hello.ru' - # config.webxml.rackup = %{require './lib/demo'; run Rack::Adapter::Camping.new(Demo)} - # config.webxml.rackup = require 'cgi' && CGI::escapeHTML(File.read("config.ru")) - - # Control the pool of Rails runtimes. Leaving unspecified means - # the pool will grow as needed to service requests. It is recommended - # that you fix these values when running a production server! - # If you're using threadsafe! mode, you probably don't want to set these values, - # since 1 runtime(default for threadsafe mode) will be enough. - # config.webxml.jruby.min.runtimes = 2 - # config.webxml.jruby.max.runtimes = 4 - - # JNDI data source name - # config.webxml.jndi = 'jdbc/rails' -end diff --git a/exe/hetzner-k3s b/exe/hetzner-k3s new file mode 100755 index 0000000..b7936eb --- /dev/null +++ b/exe/hetzner-k3s @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "bundler/setup" +require "hetzner_k3s" + +puts "Hello, #{ARGV[0] || 'World'}" diff --git a/hetzner-k3s.gemspec b/hetzner-k3s.gemspec new file mode 100644 index 0000000..2b12d6c --- /dev/null +++ b/hetzner-k3s.gemspec @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require_relative "lib/hetzner/k3s/version" + +Gem::Specification.new do |spec| + spec.name = "hetzner-k3s" + spec.version = Hetzner::K3s::VERSION + spec.authors = ["Vito Botta"] + + spec.summary = "The easiest way to create production grade Kubernetes clusters in Hetzner Cloud" + spec.description = "A CLI tool to create and manage Kubernetes clusters in Hetzner Cloud using the lightweight distribution k3s by Rancher." + spec.homepage = "https://github.com/vitobotta/hetzner-k3s" + spec.license = "MIT" + spec.required_ruby_version = ">= 3.0.0" + + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = "https://github.com/vitobotta/hetzner-k3s" + spec.metadata["changelog_uri"] = "https://github.com/vitobotta/hetzner-k3s/releases" + spec.metadata["rubygems_mfa_required"] = "true" + + # Specify which files should be added to the gem when it is released. + # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + gemspec = File.basename(__FILE__) + spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls| + ls.readlines("\x0", chomp: true).reject do |f| + (f == gemspec) || + f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile]) + end + end + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + # Uncomment to register a new dependency of your gem + # spec.add_dependency "example-gem", "~> 1.0" + + # For more information and examples about making a new gem, check out our + # guide at: https://bundler.io/guides/creating_gem.html + + spec.add_development_dependency "rake", '~> 13.2', '>= 13.2.1' + spec.add_development_dependency "rspec", '~> 3.13' + spec.add_development_dependency "rubocop", '~> 1.63', '>= 1.63.1' + spec.add_development_dependency "rubocop-rake", '~> 0.6.0' + spec.add_development_dependency "rubocop-rspec", '~> 2.29', '>= 2.29.1' +end diff --git a/lib/hetzner/k3s.rb b/lib/hetzner/k3s.rb new file mode 100644 index 0000000..9cc0010 --- /dev/null +++ b/lib/hetzner/k3s.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require_relative "k3s/version" + +module Hetzner + module K3s + class Error < StandardError; end + # Your code goes here... + end +end diff --git a/lib/hetzner/k3s/version.rb b/lib/hetzner/k3s/version.rb new file mode 100644 index 0000000..6134623 --- /dev/null +++ b/lib/hetzner/k3s/version.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Hetzner + module K3s + VERSION = "2.0.0" + end +end diff --git a/spec/hetzner/k3s_spec.rb b/spec/hetzner/k3s_spec.rb new file mode 100644 index 0000000..5abd06f --- /dev/null +++ b/spec/hetzner/k3s_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +RSpec.describe Hetzner::K3s do + it "has a version number" do + expect(Hetzner::K3s::VERSION).not_to be_nil + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..e319f0f --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "hetzner/k3s" + +RSpec.configure do |config| + # Enable flags like --only-failures and --next-failure + config.example_status_persistence_file_path = ".rspec_status" + + # Disable RSpec exposing methods globally on `Module` and `main` + config.disable_monkey_patching! + + config.expect_with :rspec do |c| + c.syntax = :expect + end +end