diff --git a/.app.yml b/.app.yml new file mode 100644 index 0000000..d5febb0 --- /dev/null +++ b/.app.yml @@ -0,0 +1,5 @@ +org: cloudtruth +name: kubetruth +version: 0.5.0 + + diff --git a/.dockerignore b/.dockerignore index 76ecb9d..729f08b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,3 +4,10 @@ pkg tmp packaged-char old-index.yaml +.bundle +.idea +.codecov.yml +coverage +.dockerignore +.rspec_status +local diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 42e723d..9edb6ac 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -13,21 +13,19 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/cache@v1 - with: - path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gems- + - uses: satackey/action-docker-layer-caching@v0.0.11 + continue-on-error: true - - name: Install Ruby version specified in `.ruby-version` - uses: eregon/use-ruby-action@master # this will use by default the .ruby-version file + - name: Set environment from cloudtruth + uses: cloudtruth/configure-action@v1 + with: + token: "${{ secrets.CLOUDTRUTH_API_KEY }}" + project: "deploy" + environment: "production" - - run: ruby -v - - run: gem install --no-document bundler - - run: bundle config path vendor/bundle - - run: bundle install --jobs 4 --retry 3 - - run: bundle exec rspec + - name: Run the tests + run: | + rake test deploy: if: startsWith(github.ref, 'refs/tags/v') @@ -37,6 +35,9 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: satackey/action-docker-layer-caching@v0.0.11 + continue-on-error: true + - name: Set environment from cloudtruth uses: cloudtruth/configure-action@v1 with: @@ -54,31 +55,18 @@ jobs: - name: Build the Docker image run: | - docker build --target release -t kubetruth . + rake build_release - name: Push the Docker image run: | tag=${GITHUB_REF##*/v} - echo "Pushing version '$tag' to docker hub" echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin - - docker tag kubetruth cloudtruth/kubetruth:latest - docker push cloudtruth/kubetruth:latest - docker tag kubetruth cloudtruth/kubetruth:${tag} - docker push cloudtruth/kubetruth:${tag} + TAGS="$tag latest" bundle exec rake docker_push - name: Package helm chart run: | export HELM_REPO_URL="${PACKAGES_URL}/${PACKAGES_HELM_PATH}" - mkdir -p tmp/packaged-chart/ - (cd tmp/packaged-chart && helm package ../../helm/kubetruth) - ./bin/generate-helmv2.sh - (cd tmp/packaged-chart && helm package ../../tmp/helmv2/kubetruth) - maybe_merge="" - if curl -sfL ${HELM_REPO_URL}/index.yaml -o tmp/old-index.yaml; then - maybe_merge="--merge tmp/old-index.yaml" - fi - helm repo index ${maybe_merge} --url ${HELM_REPO_URL} tmp/packaged-chart/ + bundle exec rake helm_package - name: Deploy helm chart to S3 run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 05fc373..7122293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +0.5.0 (06/18/2021) +------------------ + +* remove conditional update as server-side apply takes care of it [7de290f](../../commit/7de290f) +* add a signal handler to wake up from polling sleep [c9c3873](../../commit/c9c3873) +* fix creating namespace [9db00b4](../../commit/9db00b4) +* add context to projectmappings to allow for small modifications (e.g. name, namespace) without having to replace the entire template Made resource_templates into a map, and made override merging of it (and context) be additive in nature so one can add a new mapping with a template without having to replace the existing ones [5d5646b](../../commit/5d5646b) +* add a key_safe filter to ensure ConfigMap/Secret keys are converted to something safe to use [6ef09e1](../../commit/6ef09e1) +* update readme [3249752](../../commit/3249752) +* update readme [bea9ff1](../../commit/bea9ff1) +* Use a list of resource_templates instead of specifically named ones for configmaps and secrets [63d961f](../../commit/63d961f) +* update for new version [353d422](../../commit/353d422) +* Major refactoring to allow using a template for the entire kuberenetes resources (ConfigMaps/Secrets/others) created for each project. [f76e9d2](../../commit/f76e9d2) + 0.4.1 (05/19/2021) ------------------ diff --git a/Dockerfile b/Dockerfile index 495492c..1451880 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,40 +13,46 @@ ENV APP_DIR="/srv/app" \ # values. ENV BUNDLE_BIN="${BUNDLE_PATH}/bin" \ GEM_HOME="${BUNDLE_PATH}" -ENV PATH="${APP_DIR}:${BUNDLE_BIN}:${PATH}" +ENV PATH="${APP_DIR}:${APP_DIR}/bin:${BUNDLE_BIN}:${PATH}" RUN mkdir -p $APP_DIR $BUNDLE_PATH WORKDIR $APP_DIR FROM base as build -COPY Gemfile* *.gemspec $APP_DIR/ -COPY lib/kubetruth/version.rb $APP_DIR/lib/kubetruth/ - RUN apk add --no-cache \ --virtual app \ $APP_PACKAGES && \ apk add --no-cache \ --virtual build_deps \ - $BUILD_PACKAGES && \ - bundle install && \ - apk del build_deps + $BUILD_PACKAGES + +COPY Gemfile* $APP_DIR/ +RUN bundle config --global without 'development test' && \ + bundle install --jobs=4 RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing kubectl COPY . $APP_DIR/ -RUN bundle config set deployment 'true' && \ - bundle config set without 'development test' && \ + + +FROM build as development + +RUN bundle config --delete without && \ bundle install --jobs=4 +# Specify the script to use when running the container +ENTRYPOINT ["entrypoint.sh"] +# Start the main app process by sending the "app" parameter to the entrypoint +CMD ["app"] + + FROM base AS release RUN apk add --no-cache \ --virtual app \ $RELEASE_PACKAGES -RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing kubectl - COPY --from=build $BUNDLE_PATH $BUNDLE_PATH COPY --from=build $APP_DIR $APP_DIR diff --git a/Gemfile b/Gemfile index fd66c5f..b9b1d69 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,26 @@ source "https://rubygems.org" -# Specify your gem's dependencies in kubetruth.gemspec -gemspec +# development dependencies +group :development do + gem "rake", "~> 12.0" + gem "pry" + gem "pry-byebug" +end -gem "rake", "~> 12.0" -gem "rspec", "~> 3.0" -gem "vcr" -gem "webmock" -gem 'codecov', require: false, group: 'test' -gem "simplecov" -gem "pry" -gem "pry-byebug" +# test dependencies +group :development, :test do + gem "rspec", "~> 3.0" + gem "vcr" + gem "webmock" + gem 'codecov', require: false, group: 'test' + gem "simplecov" +end + +# application runtime dependencies +gem 'gem_logger' +gem 'logging' +gem 'activesupport' +gem 'clamp' +gem 'graphql-client' +gem 'kubeclient' +gem 'liquid' diff --git a/Gemfile.lock b/Gemfile.lock index ac92c44..5dd3d7b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,15 +1,3 @@ -PATH - remote: . - specs: - kubetruth (0.5.0) - activesupport - clamp - gem_logger - graphql-client - kubeclient - liquid - logging - GEM remote: https://rubygems.org/ specs: @@ -126,8 +114,14 @@ PLATFORMS ruby DEPENDENCIES + activesupport + clamp codecov - kubetruth! + gem_logger + graphql-client + kubeclient + liquid + logging pry pry-byebug rake (~> 12.0) diff --git a/README.md b/README.md index ac4920d..85eb2c9 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,9 @@ CloudTruth projects whose names match its `project_selector` pattern. Note that Kubetruth watches for changes to ProjectMappings, so touching any of them wakes it up from a polling sleep. This makes it quick and easy to test out -configuration changes without having a short polling interval. +configuration changes without having a short polling interval. You can also +force a wakeup by execing the wakeup script in the running container: +`kubectl exec deployment/kubetruth -- wakeup` To customize how the kubernetes resources are generated, edit the `resource_templates` property in the ProjectMappings. These templates are @@ -271,7 +273,9 @@ Namespace: default ## Development -After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. +After checking out the repo, run `bundle` to install dependencies. Then, run +`bundle exec rspec` to run the tests. You can also run `bundle exec rake console` for an +interactive prompt that will allow you to experiment. To install and run via helm in a local cluster: ``` @@ -279,7 +283,7 @@ To install and run via helm in a local cluster: # with the command: # eval $(minikube docker-env) # -docker build -t kubetruth . && helm install \ +docker build --release development -t kubetruth . && helm install \ --set image.repository=kubetruth --set image.pullPolicy=Never --set image.tag=latest \ --set appSettings.debug=true --set appSettings.apiKey=$CLOUDTRUTH_API_KEY --set appSettings.environment=development \ kubetruth ./helm/kubetruth/ diff --git a/Rakefile b/Rakefile index b7e9ed5..0bbe026 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,227 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" +require 'yaml' +require 'open-uri' -RSpec::Core::RakeTask.new(:spec) +ROOT_DIR = File.expand_path(__dir__) +APP = YAML.load(File.read("#{ROOT_DIR}/.app.yml"), filename: "#{ROOT_DIR}/.app.yml", symbolize_names: true) +TMP_DIR = "#{ROOT_DIR}/tmp" +HELMV2_DIR = "#{TMP_DIR}/helmv2" +HELM_PKG_DIR = "#{TMP_DIR}/packaged-chart" -task :default => :spec +require 'rake/clean' +CLEAN << TMP_DIR + +def get_var(name, env_name: name.to_s.upcase, yml_name: name.to_s.downcase.to_sym, prompt: true, required: true) + value = ENV[env_name] + value ||= APP[yml_name] + + if value.nil? && $stdin.tty? && prompt + print "Enter '#{name}': " + value = $stdin.gets + end + + fail "'#{name}' is required" if value.nil? && required + value +end + +def gsub_file(file, pattern, replace) + File.write(file, File.read(file).gsub(pattern, replace)) +end + +directory HELMV2_DIR + +file "#{HELMV2_DIR}/#{APP[:name]}/Chart.yaml" => [HELMV2_DIR] do + cp_r "#{ROOT_DIR}/helm/#{APP[:name]}", HELMV2_DIR, preserve: true + cp_r "#{ROOT_DIR}/helm/helmv2/.", "#{HELMV2_DIR}/#{APP[:name]}/", preserve: true + chart = File.read("#{HELMV2_DIR}/#{APP[:name]}/Chart.yaml") + chart = chart.gsub(/apiVersion: v2/, "apiVersion: v1") + chart = chart.gsub(/version: ([0-9.]*)/, "version: \1-helmv2") + File.write("#{HELMV2_DIR}/#{APP[:name]}/Chart.yaml", chart) +end + +task :generate_helmv2 => ["#{HELMV2_DIR}/#{APP[:name]}/Chart.yaml"] + +directory HELM_PKG_DIR + +HELM_SRC_DIR = "#{ROOT_DIR}/helm/#{APP[:name]}" +task :helm_build_package => [HELM_PKG_DIR] do + sh "helm package #{HELM_SRC_DIR}", chdir: HELM_PKG_DIR +end + +HELMV2_SRC_DIR = "#{HELMV2_DIR}/#{APP[:name]}" +task :helmv2_build_package => [HELM_PKG_DIR, :generate_helmv2] do + sh "helm package #{HELMV2_SRC_DIR}", chdir: HELM_PKG_DIR +end + +task :helm_index => [:helm_build_package, :helmv2_build_package] do + helm_repo_url = get_var('HELM_REPO_URL') + + maybe_merge="" + begin + File.write("#{TMP_DIR}/old-index.yaml", IO.read("#{helm_repo_url}/index.yaml")) + maybe_merge="--merge #{TMP_DIR}/old-index.yaml" + rescue + puts "No pre-existing helm index at #{helm_repo_url}" + end + + sh "helm repo index #{maybe_merge} --url #{helm_repo_url} #{TMP_DIR}/packaged-chart/" + +end + +task :helm_package => [:helm_index] + +task :build_development do + sh "docker build --target development -t kubetruth-development ." +end + +task :test => [:build_development] do + sh "docker run -e CI -e CODECOV_TOKEN kubetruth-development test" +end + +task :rspec do + require "rspec/core/rake_task" + RSpec::Core::RakeTask.new(:spec) + Rake::Task[:spec].invoke +end + +task :build_release do + sh "docker build --target release -t kubetruth ." +end + +task :docker_push do + tags = get_var(:tags) + tags = tags.split + tags.each do |tag| + puts "Pushing version '#{tag}' to docker hub" + sh "docker tag #{APP[:name]} #{APP[:org]}/#{APP[:name]}:#{tag}" + sh "docker push #{APP[:org]}/#{APP[:name]}:#{tag}" + end +end + +task :set_version do + version = get_var('VERSION') + + gsub_file("#{ROOT_DIR}/helm/#{APP[:name]}/Chart.yaml", + /^version:.*/, "version: #{version}") + gsub_file("#{ROOT_DIR}/helm/#{APP[:name]}/Chart.yaml", + /^appVersion:.*/, "appVersion: #{version}") + gsub_file("#{ROOT_DIR}/.app.yml", + /version:.*/, "version: #{version}") +end + +task :release do + if `git diff --stat`.present? + raise "The git tree is dirty, a clean tree is required to release" + end + + current_branch=`git branch --show-current` + default_branch="master" + if current_branch != default_branch + raise "Can only release from the default branch" + end + + Rake::Task[:set_version].invoke + bundle + Rake::Task[:changelog].invoke + + cmds = [] + cmds << 'git ci -m\"Updated changelog\" .' + cmds << 'git push' + cmds << "git tag -f \"v#{version}\"" + cmds << 'git push -f --tags' + puts "Will execute:" + cmds.each {|c| puts c} + print "\nProceed (y/n)? " + if $stdin.gets =~ /^y/i + cmds.each { |c| sh c } + else + puts "Aborted" + end +end + +task :changelog do + changelog_file = Dir['CHANGELOG*'].first + entries = "" + sha_url_format = "../../commit/%h" + + current_version = get_var('CURRENT_VERSION', prompt: false, yml_name: :version) + + starting_version = nil + ending_version = nil, ending_version_name = nil + + version_range = get_var('VERSION_RANGE', prompt: false, required: false) + if version_range + first_ver, second_ver = version_range.split("..") + starting_version = "v#{first_ver.gsub(/^[^\d]*/, '')}" if ! first_ver.nil? && first_ver.size > 0 + ending_version = "v#{second_ver.gsub(/^[^\d]*/, '')}" if ! second_ver.nil? && second_ver.size > 0 + ending_version_name = ending_version if ending_version + end + + # If we already have a changelog, make the starting_version be the + # last one in the changelog + # + if ! starting_version && File.exist?(changelog_file) + entries = File.read(changelog_file) + head = entries.split.first + if head =~ /(\d+\.\d+\.\d+).*/ + starting_version = "v#{$1}" + + if current_version == starting_version + puts "WARN: current_version is the same as most recent changelog: #{current_version}" + end + end + end + + # Get a list of current tags + tags = `git tag -l`.split + tags = tags.sort_by {|t| t[1..-1].split(".").collect {|s| s.to_i } } + newest_tag = tags[-1] + + if current_version == newest_tag + # When generating CHANGELOG after release, we want the last tag as the ending version + ending_version = newest_tag + ending_version_name = newest_tag + else + # When generating CHANGELOG before release, we want the current ver as the ending version + ending_version = "HEAD" + ending_version_name = current_version + end + + if starting_version + version_selector = "#{starting_version}..#{ending_version}" + else + puts "WARN: No starting version, dumping entire history, try: rake changelog VERSION=v1.2.3" + version_selector = "" + end + + # Generate changelog from repo + puts "Generating a changelog for #{version_selector}" + log=`git log --pretty='format:%s [%h](#{sha_url_format})' #{version_selector}`.lines.to_a + + # Strip out maintenance entries + log = log.delete_if do |l| + l =~ /^Regenerated? gemspec/ || + l =~ /^version bump/i || + l =~ /^bump version/i || + l =~ /^updated? changelog/i || + l =~ /^merged? branch/i + end + + # Write out changelog file + File.open(changelog_file, 'w') do |out| + ver_title = ending_version_name.gsub(/^v/, '') + " (#{Time.now.strftime("%m/%d/%Y")})" + out.puts ver_title + out.puts "-" * ver_title.size + out.puts "\n" + log.each { |l| out.print "* #{l}" } + out.puts "\n\n" + out.puts entries + end +end + +task :console do + $LOAD_PATH.unshift File.expand_path("lib", __dir__) + require "bundler/setup" + require APP[:name] + require "pry" + Pry.start +end diff --git a/bin/assign_version.sh b/bin/assign_version.sh deleted file mode 100755 index 59c1e24..0000000 --- a/bin/assign_version.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -e - -if [[ $# != 1 ]]; then - echo "usage: $(basename $0) version" - exit 1 -fi - -root_dir=$(cd $(dirname $0)/.. && pwd) -tag=$1 - -sed -i '' -e "s/^version:.*/version: $tag/" "${root_dir}/helm/kubetruth/Chart.yaml" -sed -i '' -e "s/^appVersion:.*/appVersion: $tag/" "${root_dir}/helm/kubetruth/Chart.yaml" -sed -i '' -e "s/VERSION *=.*/VERSION = \"$tag\"/" "${root_dir}/lib/kubetruth/version.rb" diff --git a/bin/changelog b/bin/changelog deleted file mode 100755 index 0c5bd18..0000000 --- a/bin/changelog +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env ruby - -changelog_file = Dir['CHANGELOG*'].first -entries = "" -sha_url_format = "../../commit/%h" - -current_version=ARGV[1] -if current_version.nil? - require 'bundler' - helper = Bundler::GemHelper.new(Dir.pwd) - current_version = "v#{helper.gemspec.version}" -end - -starting_version = nil -ending_version = nil, ending_version_name = nil - -if ENV['VERSION'] - ver = ENV['VERSION'] - first_ver, second_ver = ver.split("..") - starting_version = "v#{first_ver.gsub(/^[^\d]*/, '')}" if ! first_ver.nil? && first_ver.size > 0 - ending_version = "v#{second_ver.gsub(/^[^\d]*/, '')}" if ! second_ver.nil? && second_ver.size > 0 - ending_version_name = ending_version if ending_version -end - -# If we already have a changelog, make the starting_version be the -# last one in the changelog -# -if ! starting_version && File.exist?(changelog_file) - entries = File.read(changelog_file) - head = entries.split.first - if head =~ /(\d+\.\d+\.\d+).*/ - starting_version = "v#{$1}" - - if current_version == starting_version - puts "WARN: gemspec version is the same as most recent changelog: #{current_version}" - end - end -end - - # Get a list of current tags -tags = `git tag -l`.split -tags = tags.sort_by {|t| t[1..-1].split(".").collect {|s| s.to_i } } -newest_tag = tags[-1] - -if current_version == newest_tag - # When generating CHANGELOG after release, we want the last tag as the ending version - ending_version = newest_tag - ending_version_name = newest_tag -else - # When generating CHANGELOG before release, we want the current ver as the ending version - ending_version = "HEAD" - ending_version_name = current_version -end - -if starting_version - version_selector = "#{starting_version}..#{ending_version}" -else - puts "WARN: No starting version, dumping entire history, try: rake changelog VERSION=v1.2.3" - version_selector = "" -end - -# Generate changelog from repo -puts "Generating a changelog for #{version_selector}" -log=`git log --pretty='format:%s [%h](#{sha_url_format})' #{version_selector}`.lines.to_a - -# Strip out maintenance entries -log = log.delete_if do |l| - l =~ /^Regenerated? gemspec/ || - l =~ /^version bump/i || - l =~ /^bump version/i || - l =~ /^updated? changelog/i || - l =~ /^merged? branch/i -end - -# Write out changelog file -File.open(changelog_file, 'w') do |out| - ver_title = ending_version_name.gsub(/^v/, '') + " (#{Time.now.strftime("%m/%d/%Y")})" - out.puts ver_title - out.puts "-" * ver_title.size - out.puts "\n" - log.each { |l| out.print "* #{l}" } - out.puts "\n\n" - out.puts entries -end diff --git a/bin/console b/bin/console deleted file mode 100755 index e721245..0000000 --- a/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "kubetruth" - -# 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. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/bin/generate-helmv2.sh b/bin/generate-helmv2.sh deleted file mode 100755 index 14ea5ab..0000000 --- a/bin/generate-helmv2.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e -root_dir=$(cd $(dirname $0)/.. && pwd) -helmv2dir="${root_dir}/tmp/helmv2" - -mkdir -p "${helmv2dir}" -cp -Rp "${root_dir}/helm/kubetruth" "${helmv2dir}/" -cp -Rp "${root_dir}/helm/helmv2"/* "${helmv2dir}/kubetruth/" -sed -i'' -e 's/apiVersion: v2/apiVersion: v1/' "${helmv2dir}/kubetruth/Chart.yaml" -sed -i'' -e 's/version: \([0-9.]*\)/version: \1-helmv2/' "${helmv2dir}/kubetruth/Chart.yaml" diff --git a/bin/kubetruth b/bin/kubetruth new file mode 100755 index 0000000..b5bdd19 --- /dev/null +++ b/bin/kubetruth @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby + +$LOAD_PATH.unshift File.expand_path("../lib", __dir__) + +require "kubetruth" +require 'kubetruth/cli' +Kubetruth::CLI.run diff --git a/bin/release.sh b/bin/release.sh deleted file mode 100755 index 3b6d8d2..0000000 --- a/bin/release.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -e - -if [[ $# != 1 ]]; then - echo "usage: $(basename $0) version" - exit 1 -fi - -root_dir=$(cd $(dirname $0)/.. && pwd) -cd $root_dir - -version=$1 - -if [[ $(git diff --stat) != '' ]]; then - echo "The git tree is dirty, a clean tree is required to release" - exit 1 -fi - -current_branch=$(git branch --show-current) -default_branch="master" -if [[ "$current_branch" != "$default_branch" ]]; then - echo "Can only release from the default branch" - exit 1 -fi - -./bin/assign_version.sh $version -bundle -./bin/changelog $version - -echo git ci -m\"Updated changelog\" . -echo git push -echo git tag -f \"v${version}\" -echo git push -f --tags diff --git a/bin/setup b/bin/setup deleted file mode 100755 index dce67d8..0000000 --- a/bin/setup +++ /dev/null @@ -1,8 +0,0 @@ -#!/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/entrypoint.sh b/entrypoint.sh index 3b17c89..bdec24d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,29 +3,18 @@ # fail fast set -e -function start_app { - echo "Starting app" - - exec kubetruth "$@" -} -export -f start_app - -function start_console { - echo "Starting console" - exec bundle exec irb -} -export -f start_console - action=$1; shift case $action in app) - start_app "$@" + echo "Starting app" + exec bundle exec kubetruth "$@" ;; console) - start_console + echo "Starting console" + exec bundle exec rake console ;; test) diff --git a/exe/kubetruth b/exe/kubetruth deleted file mode 100755 index 0823abf..0000000 --- a/exe/kubetruth +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby - -require_relative "../lib/kubetruth" -require_relative '../lib/kubetruth/cli' -Kubetruth::CLI.run diff --git a/helm/kubetruth/Chart.yaml b/helm/kubetruth/Chart.yaml index e301231..45f5714 100644 --- a/helm/kubetruth/Chart.yaml +++ b/helm/kubetruth/Chart.yaml @@ -15,9 +15,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.4.1 +version: 0.5.0 + # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 0.4.1 +appVersion: 0.5.0 + diff --git a/kubetruth.gemspec b/kubetruth.gemspec deleted file mode 100644 index 301c6bc..0000000 --- a/kubetruth.gemspec +++ /dev/null @@ -1,35 +0,0 @@ -require_relative 'lib/kubetruth/version' - -Gem::Specification.new do |spec| - spec.name = "kubetruth" - spec.version = Kubetruth::VERSION - spec.authors = ["Matt Conway"] - spec.email = ["matt@cloudtruth.com"] - - spec.summary = %q{The CloudTruth integration for kubernetes} - spec.description = %q{The CloudTruth integration for kubernetes that pushes parameter updates into kubernetes config maps and secrets} - spec.homepage = "https://cloudtruth.com" - spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") - - spec.metadata["allowed_push_host"] = "http://rubygems.com" - - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "https://github.com/cloudtruth/kubetruth" - spec.metadata["changelog_uri"] = "https://github.com/cloudtruth/kubetruth/CHANGELOG.md" - - # 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. - spec.files = Dir['*.md', 'LICENSE', 'exe/**/*', 'lib/**/*'] - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency 'gem_logger' - spec.add_dependency 'logging' - spec.add_dependency 'activesupport' - spec.add_dependency 'clamp' - spec.add_dependency 'graphql-client' - spec.add_dependency 'kubeclient' - spec.add_dependency 'liquid' - -end diff --git a/lib/kubetruth.rb b/lib/kubetruth.rb index d146c1f..92eba6b 100644 --- a/lib/kubetruth.rb +++ b/lib/kubetruth.rb @@ -2,13 +2,16 @@ require 'active_support/core_ext/string/inflections' # prevent our use of ActiveSupport causing an error with json adapters require 'active_support/json' +require 'yaml' require_relative 'kubetruth/logging' # Need to setup logging before loading any other files Kubetruth::Logging.setup_logging(level: :info, color: false) -require_relative "kubetruth/version" - module Kubetruth + VERSION = YAML.load(File.read(File.expand_path('../.app.yml', __dir__)), + filename: File.expand_path('../.app.yml', __dir__), + symbolize_names: true)[:version] + class Error < StandardError; end end diff --git a/lib/kubetruth/version.rb b/lib/kubetruth/version.rb deleted file mode 100644 index 0b6c4dd..0000000 --- a/lib/kubetruth/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Kubetruth - VERSION = "0.5.0" -end