kubes 0.1.0 → 0.2.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 +5 -5
- data/.gitignore +15 -7
- data/.rspec +3 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +3 -1
- data/Guardfile +19 -0
- data/LICENSE.txt +201 -0
- data/README.md +46 -18
- data/Rakefile +13 -1
- data/docs/.gitignore +5 -0
- data/docs/CNAME +1 -0
- data/docs/Gemfile +16 -0
- data/docs/LICENSE +201 -0
- data/docs/Procfile +2 -0
- data/docs/README.md +24 -0
- data/docs/Rakefile +38 -0
- data/docs/_config.yml +71 -0
- data/docs/_docs/auto-context.md +47 -0
- data/docs/_docs/config.md +9 -0
- data/docs/_docs/config/docker.md +70 -0
- data/docs/_docs/config/env.md +58 -0
- data/docs/_docs/config/kubectl.md +61 -0
- data/docs/_docs/contributing.md +98 -0
- data/docs/_docs/dsl.md +66 -0
- data/docs/_docs/dsl/multiple-resources.md +114 -0
- data/docs/_docs/dsl/resources.md +12 -0
- data/docs/_docs/dsl/resources/backend_config.md +45 -0
- data/docs/_docs/dsl/resources/config_map.md +84 -0
- data/docs/_docs/dsl/resources/daemon_set.md +58 -0
- data/docs/_docs/dsl/resources/deployment.md +142 -0
- data/docs/_docs/dsl/resources/generic.md +58 -0
- data/docs/_docs/dsl/resources/ingress.md +103 -0
- data/docs/_docs/dsl/resources/managed_certificate.md +39 -0
- data/docs/_docs/dsl/resources/namespace.md +34 -0
- data/docs/_docs/dsl/resources/network_policy.md +45 -0
- data/docs/_docs/dsl/resources/pod.md +82 -0
- data/docs/_docs/dsl/resources/role.md +44 -0
- data/docs/_docs/dsl/resources/role_binding.md +55 -0
- data/docs/_docs/dsl/resources/secret.md +87 -0
- data/docs/_docs/dsl/resources/service.md +60 -0
- data/docs/_docs/dsl/resources/service_account.md +37 -0
- data/docs/_docs/extra-env.md +23 -0
- data/docs/_docs/extra-env/dsl.md +86 -0
- data/docs/_docs/extra-env/yaml.md +67 -0
- data/docs/_docs/helpers.md +18 -0
- data/docs/_docs/intro.md +15 -0
- data/docs/_docs/intro/concepts.md +37 -0
- data/docs/_docs/intro/how-kubes-works.md +29 -0
- data/docs/_docs/intro/install.md +6 -0
- data/docs/_docs/intro/ordering.md +63 -0
- data/docs/_docs/intro/ordering/custom.md +25 -0
- data/docs/_docs/intro/structure.md +43 -0
- data/docs/_docs/kustomize.md +54 -0
- data/docs/_docs/layering.md +8 -0
- data/docs/_docs/layering/dsl.md +5 -0
- data/docs/_docs/layering/merge.md +96 -0
- data/docs/_docs/layering/yaml.md +5 -0
- data/docs/_docs/learn/dsl.md +5 -0
- data/docs/_docs/learn/dsl/change.md +16 -0
- data/docs/_docs/learn/dsl/cluster.md +5 -0
- data/docs/_docs/learn/dsl/delete.md +30 -0
- data/docs/_docs/learn/dsl/deploy.md +61 -0
- data/docs/_docs/learn/dsl/install.md +5 -0
- data/docs/_docs/learn/dsl/new-project.md +33 -0
- data/docs/_docs/learn/dsl/next-steps.md +5 -0
- data/docs/_docs/learn/dsl/review-project.md +52 -0
- data/docs/_docs/learn/dsl/update.md +53 -0
- data/docs/_docs/learn/yaml.md +5 -0
- data/docs/_docs/learn/yaml/change.md +17 -0
- data/docs/_docs/learn/yaml/cluster.md +5 -0
- data/docs/_docs/learn/yaml/delete.md +30 -0
- data/docs/_docs/learn/yaml/deploy.md +62 -0
- data/docs/_docs/learn/yaml/install.md +5 -0
- data/docs/_docs/learn/yaml/new-project.md +36 -0
- data/docs/_docs/learn/yaml/next-steps.md +5 -0
- data/docs/_docs/learn/yaml/review-project.md +97 -0
- data/docs/_docs/learn/yaml/update.md +54 -0
- data/docs/_docs/next-steps.md +13 -0
- data/docs/_docs/patterns.md +7 -0
- data/docs/_docs/patterns/clock-web-worker.md +71 -0
- data/docs/_docs/resources.md +11 -0
- data/docs/_docs/resources/base.md +33 -0
- data/docs/_docs/resources/role.md +41 -0
- data/docs/_docs/resources/shared.md +36 -0
- data/docs/_docs/yaml.md +46 -0
- data/docs/_includes/commands.html +131 -0
- data/docs/_includes/content.html +25 -0
- data/docs/_includes/dsl/methods.md +1 -0
- data/docs/_includes/dsl/rolling_deployment.md +1 -0
- data/docs/_includes/dsl/suffix_hash.md +8 -0
- data/docs/_includes/example.html +12 -0
- data/docs/_includes/footer.html +37 -0
- data/docs/_includes/google_analytics.html +10 -0
- data/docs/_includes/header.html +31 -0
- data/docs/_includes/intro/install.md +15 -0
- data/docs/_includes/js.html +3 -0
- data/docs/_includes/kubes-steps.md +3 -0
- data/docs/_includes/layering/layers.md +64 -0
- data/docs/_includes/learn/cluster.md +22 -0
- data/docs/_includes/learn/next-steps.md +6 -0
- data/docs/_includes/learn/review.md +25 -0
- data/docs/_includes/learn/start.md +3 -0
- data/docs/_includes/reference.md +3 -0
- data/docs/_includes/sidebar.html +113 -0
- data/docs/_layouts/default.html +35 -0
- data/docs/_reference/kubes-apply.md +24 -0
- data/docs/_reference/kubes-clean.md +22 -0
- data/docs/_reference/kubes-compile.md +22 -0
- data/docs/_reference/kubes-completion.md +42 -0
- data/docs/_reference/kubes-completion_script.md +25 -0
- data/docs/_reference/kubes-delete.md +23 -0
- data/docs/_reference/kubes-deploy.md +35 -0
- data/docs/_reference/kubes-docker-build.md +20 -0
- data/docs/_reference/kubes-docker-help.md +15 -0
- data/docs/_reference/kubes-docker-push.md +20 -0
- data/docs/_reference/kubes-docker.md +25 -0
- data/docs/_reference/kubes-init.md +26 -0
- data/docs/_reference/kubes-version.md +21 -0
- data/docs/_sass/bootstrap-overrides.scss +17 -0
- data/docs/_sass/buttons.scss +62 -0
- data/docs/_sass/caret.scss +39 -0
- data/docs/_sass/content.scss +21 -0
- data/docs/_sass/cta.scss +39 -0
- data/docs/_sass/default.scss +103 -0
- data/docs/_sass/footer.scss +66 -0
- data/docs/_sass/masthead.scss +77 -0
- data/docs/_sass/mixins.scss +79 -0
- data/docs/_sass/sidebar.scss +107 -0
- data/docs/_sass/syntax.scss +89 -0
- data/docs/_sass/table.scss +30 -0
- data/docs/_sass/theme.scss +292 -0
- data/docs/_sass/variables.scss +24 -0
- data/docs/bin/build +4 -0
- data/docs/bin/rerun +2 -0
- data/docs/bin/web +8 -0
- data/docs/css/main.scss +24 -0
- data/docs/docs.md +7 -0
- data/docs/getting-started.md +12 -0
- data/docs/img/logos/boltops-logo-full.png +0 -0
- data/docs/img/logos/boltops-logo.png +0 -0
- data/docs/img/logos/filler-logo.png +0 -0
- data/docs/img/logos/kubes-black.png +0 -0
- data/docs/img/logos/kubes-sign.png +0 -0
- data/docs/index.html +34 -0
- data/docs/js/app.js +39414 -0
- data/docs/opal/app.rb +16 -0
- data/docs/opal/pager.rb +90 -0
- data/docs/opal/sidebar.rb +94 -0
- data/docs/opal/sidebar/expander.rb +51 -0
- data/docs/reference.md +15 -0
- data/docs/support.md +19 -0
- data/docs/vendor/bootstrap/css/bootstrap-grid.css +3719 -0
- data/docs/vendor/bootstrap/css/bootstrap-grid.css.map +1 -0
- data/docs/vendor/bootstrap/css/bootstrap-grid.min.css +7 -0
- data/docs/vendor/bootstrap/css/bootstrap-grid.min.css.map +1 -0
- data/docs/vendor/bootstrap/css/bootstrap-reboot.css +331 -0
- data/docs/vendor/bootstrap/css/bootstrap-reboot.css.map +1 -0
- data/docs/vendor/bootstrap/css/bootstrap-reboot.min.css +8 -0
- data/docs/vendor/bootstrap/css/bootstrap-reboot.min.css.map +1 -0
- data/docs/vendor/bootstrap/css/bootstrap.css +10038 -0
- data/docs/vendor/bootstrap/css/bootstrap.css.map +1 -0
- data/docs/vendor/bootstrap/css/bootstrap.min.css +7 -0
- data/docs/vendor/bootstrap/css/bootstrap.min.css.map +1 -0
- data/docs/vendor/bootstrap/js/bootstrap.bundle.js +7013 -0
- data/docs/vendor/bootstrap/js/bootstrap.bundle.js.map +1 -0
- data/docs/vendor/bootstrap/js/bootstrap.bundle.min.js +7 -0
- data/docs/vendor/bootstrap/js/bootstrap.bundle.min.js.map +1 -0
- data/docs/vendor/bootstrap/js/bootstrap.js +4435 -0
- data/docs/vendor/bootstrap/js/bootstrap.js.map +1 -0
- data/docs/vendor/bootstrap/js/bootstrap.min.js +7 -0
- data/docs/vendor/bootstrap/js/bootstrap.min.js.map +1 -0
- data/docs/vendor/font-awesome/css/font-awesome.css +2337 -0
- data/docs/vendor/font-awesome/css/font-awesome.min.css +4 -0
- data/docs/vendor/font-awesome/fonts/FontAwesome.otf +0 -0
- data/docs/vendor/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- data/docs/vendor/font-awesome/fonts/fontawesome-webfont.svg +2671 -0
- data/docs/vendor/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- data/docs/vendor/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- data/docs/vendor/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- data/docs/vendor/font-awesome/less/animated.less +34 -0
- data/docs/vendor/font-awesome/less/bordered-pulled.less +25 -0
- data/docs/vendor/font-awesome/less/core.less +12 -0
- data/docs/vendor/font-awesome/less/fixed-width.less +6 -0
- data/docs/vendor/font-awesome/less/font-awesome.less +18 -0
- data/docs/vendor/font-awesome/less/icons.less +789 -0
- data/docs/vendor/font-awesome/less/larger.less +13 -0
- data/docs/vendor/font-awesome/less/list.less +19 -0
- data/docs/vendor/font-awesome/less/mixins.less +60 -0
- data/docs/vendor/font-awesome/less/path.less +15 -0
- data/docs/vendor/font-awesome/less/rotated-flipped.less +20 -0
- data/docs/vendor/font-awesome/less/screen-reader.less +5 -0
- data/docs/vendor/font-awesome/less/stacked.less +20 -0
- data/docs/vendor/font-awesome/less/variables.less +799 -0
- data/docs/vendor/font-awesome/scss/_animated.scss +34 -0
- data/docs/vendor/font-awesome/scss/_bordered-pulled.scss +25 -0
- data/docs/vendor/font-awesome/scss/_core.scss +12 -0
- data/docs/vendor/font-awesome/scss/_fixed-width.scss +6 -0
- data/docs/vendor/font-awesome/scss/_icons.scss +789 -0
- data/docs/vendor/font-awesome/scss/_larger.scss +13 -0
- data/docs/vendor/font-awesome/scss/_list.scss +19 -0
- data/docs/vendor/font-awesome/scss/_mixins.scss +60 -0
- data/docs/vendor/font-awesome/scss/_path.scss +15 -0
- data/docs/vendor/font-awesome/scss/_rotated-flipped.scss +20 -0
- data/docs/vendor/font-awesome/scss/_screen-reader.scss +5 -0
- data/docs/vendor/font-awesome/scss/_stacked.scss +20 -0
- data/docs/vendor/font-awesome/scss/_variables.scss +799 -0
- data/docs/vendor/font-awesome/scss/font-awesome.scss +18 -0
- data/docs/vendor/jquery/jquery.js +10598 -0
- data/docs/vendor/jquery/jquery.min.js +2 -0
- data/docs/vendor/jquery/jquery.min.map +1 -0
- data/docs/vendor/jquery/jquery.slim.js +8495 -0
- data/docs/vendor/jquery/jquery.slim.min.js +2 -0
- data/docs/vendor/jquery/jquery.slim.min.map +1 -0
- data/docs/vendor/simple-line-icons/css/simple-line-icons.css +778 -0
- data/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.eot +0 -0
- data/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.svg +200 -0
- data/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.ttf +0 -0
- data/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.woff +0 -0
- data/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.woff2 +0 -0
- data/docs/vendor/simple-line-icons/less/simple-line-icons.less +982 -0
- data/docs/vendor/simple-line-icons/scss/simple-line-icons.scss +979 -0
- data/exe/kubes +14 -0
- data/kubes.gemspec +29 -19
- data/lib/kubes.rb +21 -1
- data/lib/kubes/args/custom.rb +30 -0
- data/lib/kubes/args/dsl.rb +14 -0
- data/lib/kubes/auth.rb +21 -0
- data/lib/kubes/auth/ecr.rb +55 -0
- data/lib/kubes/autoloader.rb +21 -0
- data/lib/kubes/aws_services.rb +14 -0
- data/lib/kubes/cli.rb +93 -0
- data/lib/kubes/cli/apply.rb +9 -0
- data/lib/kubes/cli/base.rb +9 -0
- data/lib/kubes/cli/build.rb +8 -0
- data/lib/kubes/cli/clean.rb +9 -0
- data/lib/kubes/cli/compile.rb +8 -0
- data/lib/kubes/cli/delete.rb +11 -0
- data/lib/kubes/cli/deploy.rb +13 -0
- data/lib/kubes/cli/describe.rb +8 -0
- data/lib/kubes/cli/docker.rb +20 -0
- data/lib/kubes/cli/get.rb +8 -0
- data/lib/kubes/cli/help.rb +11 -0
- data/lib/kubes/cli/help/completion.md +20 -0
- data/lib/kubes/cli/help/completion_script.md +3 -0
- data/lib/kubes/cli/help/deploy.md +10 -0
- data/lib/kubes/cli/init.rb +69 -0
- data/lib/kubes/cli/sequence.rb +27 -0
- data/lib/kubes/command.rb +100 -0
- data/lib/kubes/compiler.rb +71 -0
- data/lib/kubes/compiler/decorator.rb +17 -0
- data/lib/kubes/compiler/decorator/base.rb +16 -0
- data/lib/kubes/compiler/decorator/compile.rb +12 -0
- data/lib/kubes/compiler/decorator/resources/base.rb +13 -0
- data/lib/kubes/compiler/decorator/resources/container.rb +76 -0
- data/lib/kubes/compiler/decorator/resources/container/mapping.rb +28 -0
- data/lib/kubes/compiler/decorator/resources/deployment.rb +10 -0
- data/lib/kubes/compiler/decorator/resources/pod.rb +10 -0
- data/lib/kubes/compiler/decorator/resources/secret.rb +23 -0
- data/lib/kubes/compiler/decorator/write.rb +14 -0
- data/lib/kubes/compiler/dsl/core/base.rb +27 -0
- data/lib/kubes/compiler/dsl/core/blocks.rb +55 -0
- data/lib/kubes/compiler/dsl/core/fields.rb +78 -0
- data/lib/kubes/compiler/dsl/core/files.rb +28 -0
- data/lib/kubes/compiler/dsl/core/helpers.rb +4 -0
- data/lib/kubes/compiler/dsl/core/parser.rb +43 -0
- data/lib/kubes/compiler/dsl/syntax/backend_config.rb +10 -0
- data/lib/kubes/compiler/dsl/syntax/cluster_role.rb +4 -0
- data/lib/kubes/compiler/dsl/syntax/cluster_role_binding.rb +4 -0
- data/lib/kubes/compiler/dsl/syntax/config_map.rb +20 -0
- data/lib/kubes/compiler/dsl/syntax/daemon_set.rb +23 -0
- data/lib/kubes/compiler/dsl/syntax/deployment.rb +163 -0
- data/lib/kubes/compiler/dsl/syntax/ingress.rb +41 -0
- data/lib/kubes/compiler/dsl/syntax/managed_certificate.rb +18 -0
- data/lib/kubes/compiler/dsl/syntax/namespace.rb +13 -0
- data/lib/kubes/compiler/dsl/syntax/network_policy.rb +30 -0
- data/lib/kubes/compiler/dsl/syntax/pod.rb +81 -0
- data/lib/kubes/compiler/dsl/syntax/resource.rb +70 -0
- data/lib/kubes/compiler/dsl/syntax/role.rb +40 -0
- data/lib/kubes/compiler/dsl/syntax/role_binding.rb +43 -0
- data/lib/kubes/compiler/dsl/syntax/secret.rb +22 -0
- data/lib/kubes/compiler/dsl/syntax/service.rb +68 -0
- data/lib/kubes/compiler/dsl/syntax/service_account.rb +20 -0
- data/lib/kubes/compiler/layering.rb +39 -0
- data/lib/kubes/compiler/shared/helpers.rb +30 -0
- data/lib/kubes/compiler/strategy.rb +27 -0
- data/lib/kubes/compiler/strategy/base.rb +13 -0
- data/lib/kubes/compiler/strategy/dsl.rb +32 -0
- data/lib/kubes/compiler/strategy/erb.rb +42 -0
- data/lib/kubes/compiler/strategy/pass.rb +9 -0
- data/lib/kubes/compiler/strategy/result.rb +26 -0
- data/lib/kubes/compiler/util/normalize.rb +11 -0
- data/lib/kubes/compiler/util/yaml_dump.rb +23 -0
- data/lib/kubes/completer.rb +159 -0
- data/lib/kubes/completer/script.rb +6 -0
- data/lib/kubes/completer/script.sh +10 -0
- data/lib/kubes/config.rb +82 -0
- data/lib/kubes/core.rb +32 -0
- data/lib/kubes/docker/args/default.rb +39 -0
- data/lib/kubes/docker/base.rb +88 -0
- data/lib/kubes/docker/build.rb +33 -0
- data/lib/kubes/docker/push.rb +33 -0
- data/lib/kubes/hooks/builder.rb +41 -0
- data/lib/kubes/hooks/dsl.rb +19 -0
- data/lib/kubes/kubectl.rb +87 -0
- data/lib/kubes/kubectl/args/base.rb +12 -0
- data/lib/kubes/kubectl/args/kustomize.rb +28 -0
- data/lib/kubes/kubectl/args/standard.rb +32 -0
- data/lib/kubes/kubectl/batch.rb +49 -0
- data/lib/kubes/kubectl/decider.rb +15 -0
- data/lib/kubes/kubectl/kustomize.rb +13 -0
- data/lib/kubes/kubectl/ordering.rb +27 -0
- data/lib/kubes/logger.rb +26 -0
- data/lib/kubes/logging.rb +7 -0
- data/lib/kubes/util/consider.rb +9 -0
- data/lib/kubes/util/sh.rb +43 -0
- data/lib/kubes/util/sure.rb +17 -0
- data/lib/kubes/util/time.rb +14 -0
- data/lib/kubes/version.rb +1 -1
- data/lib/templates/base/.kubes/config.rb.tt +9 -0
- data/lib/templates/base/.kubes/config/env/dev.rb +6 -0
- data/lib/templates/base/.kubes/config/env/prod.rb +6 -0
- data/lib/templates/docker/Dockerfile +4 -0
- data/lib/templates/dsl/.kubes/resources/base/all.rb.tt +2 -0
- data/lib/templates/dsl/.kubes/resources/web/deployment.rb.tt +7 -0
- data/lib/templates/dsl/.kubes/resources/web/deployment/dev.rb +1 -0
- data/lib/templates/dsl/.kubes/resources/web/deployment/prod.rb +1 -0
- data/lib/templates/dsl/.kubes/resources/web/service.rb.tt +8 -0
- data/lib/templates/yaml/.kubes/resources/base/all.yaml.tt +2 -0
- data/lib/templates/yaml/.kubes/resources/base/deployment.yaml.tt +11 -0
- data/lib/templates/yaml/.kubes/resources/web/deployment.yaml.tt +24 -0
- data/lib/templates/yaml/.kubes/resources/web/deployment/dev.yaml +2 -0
- data/lib/templates/yaml/.kubes/resources/web/deployment/prod.yaml +2 -0
- data/lib/templates/yaml/.kubes/resources/web/service.yaml.tt +14 -0
- data/spec/cli_spec.rb +8 -0
- data/spec/fixtures/artifacts/demo-web/deployment.yaml +26 -0
- data/spec/fixtures/artifacts/demo-web/service.yaml +16 -0
- data/spec/fixtures/blocks/deployments.rb +9 -0
- data/spec/fixtures/decorators/deployment/configMap/envFrom.yaml +27 -0
- data/spec/fixtures/decorators/deployment/configMap/valueFrom.yaml +30 -0
- data/spec/fixtures/decorators/deployment/configMap/volumes.yaml +34 -0
- data/spec/fixtures/decorators/deployment/secret/envFrom.yaml +27 -0
- data/spec/fixtures/decorators/deployment/secret/valueFrom.yaml +30 -0
- data/spec/fixtures/decorators/deployment/secret/volumes.yaml +34 -0
- data/spec/fixtures/decorators/pod/configMap/envFrom.yaml +12 -0
- data/spec/fixtures/decorators/pod/configMap/valueFrom.yaml +16 -0
- data/spec/fixtures/decorators/pod/configMap/volumes.yaml +19 -0
- data/spec/fixtures/decorators/pod/secret/envFrom.yaml +12 -0
- data/spec/fixtures/decorators/pod/secret/valueFrom.yaml +16 -0
- data/spec/fixtures/decorators/pod/secret/volumes.yaml +19 -0
- data/spec/fixtures/deployments/minimum.rb +5 -0
- data/spec/fixtures/deployments/props.rb +7 -0
- data/spec/fixtures/deployments/setter/container.rb +11 -0
- data/spec/fixtures/deployments/setter/containers.rb +14 -0
- data/spec/fixtures/deployments/setter/metadata.rb +15 -0
- data/spec/fixtures/deployments/setter/sidecar.rb +12 -0
- data/spec/fixtures/deployments/setter/spec.rb +10 -0
- data/spec/fixtures/multiple-files/deployment-1.rb +4 -0
- data/spec/fixtures/multiple-files/deployment-2.rb +4 -0
- data/spec/fixtures/project/.gitignore +1 -0
- data/spec/fixtures/project/.kubes/resources/deployment.rb +32 -0
- data/spec/fixtures/project/.kubes/resources/foobar.rb +0 -0
- data/spec/fixtures/project/.kubes/resources/service.rb +3 -0
- data/spec/fixtures/services/minimum.rb +3 -0
- data/spec/fixtures/syntax/network_policy.rb +3 -0
- data/spec/fixtures/syntax/pod.rb +1 -0
- data/spec/kubes/compiler/decorator/resources/deployment_spec.rb +92 -0
- data/spec/kubes/compiler/decorator/resources/pod_spec.rb +92 -0
- data/spec/kubes/compiler/strategy/dsl_spec.rb +36 -0
- data/spec/kubes/compiler_spec.rb +10 -0
- data/spec/kubes/dsl/daemon_set.rb +11 -0
- data/spec/kubes/dsl/deployment_spec.rb +60 -0
- data/spec/kubes/dsl/network_policy_spec.rb +14 -0
- data/spec/kubes/dsl/pod_spec.rb +11 -0
- data/spec/kubes/dsl/service_spec.rb +12 -0
- data/spec/kubes/kubectl/batch_spec.rb +24 -0
- data/spec/spec_helper.rb +34 -0
- metadata +602 -22
- data/bin/console +0 -14
- data/bin/setup +0 -8
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
class Kubes::Compiler
|
|
2
|
+
module Layering
|
|
3
|
+
def pre_layers
|
|
4
|
+
return [] if Kubes.kustomize?
|
|
5
|
+
|
|
6
|
+
ext = File.extname(@path)
|
|
7
|
+
kind = File.basename(@path).sub(ext,'') # IE: deployment
|
|
8
|
+
all = "all"
|
|
9
|
+
if @block_form
|
|
10
|
+
kind = kind.pluralize
|
|
11
|
+
all = all.pluralize
|
|
12
|
+
end
|
|
13
|
+
layers = [
|
|
14
|
+
"#{all}#{ext}",
|
|
15
|
+
"#{all}/#{Kubes.env}#{ext}",
|
|
16
|
+
"#{kind}#{ext}",
|
|
17
|
+
"#{kind}/#{Kubes.env}#{ext}",
|
|
18
|
+
]
|
|
19
|
+
layers.map do |layer|
|
|
20
|
+
"#{Kubes.root}/.kubes/resources/base/#{layer}"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def post_layers
|
|
25
|
+
return [] if Kubes.kustomize?
|
|
26
|
+
|
|
27
|
+
ext = File.extname(@path)
|
|
28
|
+
kind_path = @path.sub(ext,'')
|
|
29
|
+
|
|
30
|
+
layers = [
|
|
31
|
+
"base",
|
|
32
|
+
Kubes.env.to_s
|
|
33
|
+
]
|
|
34
|
+
layers.map do |layer|
|
|
35
|
+
"#{kind_path}/#{layer}#{ext}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "base64"
|
|
2
|
+
|
|
3
|
+
module Kubes::Compiler::Shared
|
|
4
|
+
module Helpers
|
|
5
|
+
extend Kubes::Compiler::Dsl::Core::Fields
|
|
6
|
+
fields "name"
|
|
7
|
+
|
|
8
|
+
def built_image
|
|
9
|
+
return @options[:image] if @options[:image] # override
|
|
10
|
+
|
|
11
|
+
path = Kubes.config.state.docker_image_path
|
|
12
|
+
unless File.exist?(path)
|
|
13
|
+
raise "Missing file with docker image built by kubes: #{path}. Try first running: kubes docker build"
|
|
14
|
+
end
|
|
15
|
+
IO.read(path)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def with_extra(value)
|
|
19
|
+
[value, extra].compact.join('-')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def extra
|
|
23
|
+
ENV['KUBES_EXTRA']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def base64(v)
|
|
27
|
+
Base64.encode64(v).strip
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class Kubes::Compiler
|
|
2
|
+
class Strategy
|
|
3
|
+
def initialize(options={})
|
|
4
|
+
@options = options
|
|
5
|
+
@path = options[:path]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def compile
|
|
9
|
+
klass = strategy_class
|
|
10
|
+
return false unless klass
|
|
11
|
+
|
|
12
|
+
strategy = klass.new(@options.merge(path: @path)) # Dsl or Erb
|
|
13
|
+
result = strategy.run
|
|
14
|
+
result.compile_decorate! # compile phase decoration
|
|
15
|
+
result
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def strategy_class
|
|
19
|
+
ext = File.extname(@path)
|
|
20
|
+
case ext
|
|
21
|
+
when '.rb' then Dsl
|
|
22
|
+
when '.yaml' then Erb
|
|
23
|
+
else Pass
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class Kubes::Compiler::Strategy
|
|
2
|
+
class Base
|
|
3
|
+
include Kubes::Logging
|
|
4
|
+
|
|
5
|
+
def initialize(options={})
|
|
6
|
+
@options = options
|
|
7
|
+
@path = options[:path]
|
|
8
|
+
|
|
9
|
+
@filename = @path.sub(%r{.*\.kubes/resources/},'') # IE: web/deployment.rb or web/deployment.yaml
|
|
10
|
+
@save_file = @filename.sub('.rb','.yaml')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class Kubes::Compiler::Strategy
|
|
2
|
+
class Dsl < Base
|
|
3
|
+
include Kubes::Compiler::Util::Normalize
|
|
4
|
+
|
|
5
|
+
def run
|
|
6
|
+
dsl = dsl_class.new(@options) # Deployment, Service, etc
|
|
7
|
+
data = dsl.run
|
|
8
|
+
Result.new(@save_file, data)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def dsl_class
|
|
12
|
+
if block_form?
|
|
13
|
+
Kubes::Compiler::Dsl::Core::Blocks
|
|
14
|
+
else
|
|
15
|
+
syntax_class
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def syntax_class
|
|
20
|
+
klass_name = normalize_kind(@filename)
|
|
21
|
+
"Kubes::Compiler::Dsl::Syntax::#{klass_name}".constantize
|
|
22
|
+
rescue NameError
|
|
23
|
+
logger.debug "Using default resource for: #{klass_name}"
|
|
24
|
+
Kubes::Compiler::Dsl::Syntax::Resource # default
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def block_form?
|
|
28
|
+
type = extract_type(@filename)
|
|
29
|
+
type.pluralize == type
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "render_me_pretty"
|
|
2
|
+
|
|
3
|
+
class Kubes::Compiler::Strategy
|
|
4
|
+
class Erb < Base
|
|
5
|
+
extend Kubes::Compiler::Dsl::Core::Fields
|
|
6
|
+
include Kubes::Compiler::Dsl::Core::Helpers
|
|
7
|
+
include Kubes::Compiler::Shared::Helpers
|
|
8
|
+
include Kubes::Compiler::Layering
|
|
9
|
+
|
|
10
|
+
def run
|
|
11
|
+
@data = {}
|
|
12
|
+
|
|
13
|
+
render_files(pre_layers)
|
|
14
|
+
render(@path) # main resource definition
|
|
15
|
+
render_files(post_layers)
|
|
16
|
+
|
|
17
|
+
Result.new(@save_file, @data)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def render_files(paths)
|
|
21
|
+
paths.each do |path|
|
|
22
|
+
render(path)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# render and merge
|
|
27
|
+
def render(path)
|
|
28
|
+
result = render_result(path)
|
|
29
|
+
@data.deeper_merge!(result)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def render_result(path)
|
|
33
|
+
if File.exist?(path)
|
|
34
|
+
yaml = RenderMePretty.result(path, context: self)
|
|
35
|
+
result = YAML.load(yaml)
|
|
36
|
+
result.is_a?(Hash) ? result : {} # in case of blank yaml doc a Boolean false is returned
|
|
37
|
+
else
|
|
38
|
+
{}
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class Kubes::Compiler::Strategy
|
|
2
|
+
class Result
|
|
3
|
+
include Kubes::Compiler::Util::YamlDump
|
|
4
|
+
|
|
5
|
+
attr_reader :filename
|
|
6
|
+
def initialize(filename, data)
|
|
7
|
+
@filename, @data = filename, data
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def io?
|
|
11
|
+
@data.respond_to?(:read)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def compile_decorate!
|
|
15
|
+
@data = Kubes::Compiler::Decorator::Compile.new(@data).result
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def write_decorate!
|
|
19
|
+
@data = Kubes::Compiler::Decorator::Write.new(@data).result
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def content
|
|
23
|
+
yaml_dump(@data)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Kubes::Compiler::Util
|
|
2
|
+
module Normalize
|
|
3
|
+
def normalize_kind(path)
|
|
4
|
+
extract_type(path).underscore.camelize # Deployment, Service, Ingress, ManagedCertificate, etc
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def extract_type(path)
|
|
8
|
+
File.basename(path).sub('.rb','').sub(/-.*/,'')
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "yaml"
|
|
3
|
+
|
|
4
|
+
module Kubes::Compiler::Util
|
|
5
|
+
module YamlDump
|
|
6
|
+
def yaml_dump(data)
|
|
7
|
+
if data.is_a?(Kubes::Compiler::Dsl::Core::Blocks)
|
|
8
|
+
items = data.results.map { |k,v| standardize_yaml(v) }
|
|
9
|
+
items.map(&:to_yaml).join("")
|
|
10
|
+
else
|
|
11
|
+
data = standardize_yaml(data)
|
|
12
|
+
data.to_yaml
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# https://stackoverflow.com/questions/24508364/how-to-emit-yaml-in-ruby-expanding-aliases/46104244#46104244
|
|
17
|
+
# Prevents YAML from generating aliases/anchors.
|
|
18
|
+
def standardize_yaml(data)
|
|
19
|
+
json = data.to_json
|
|
20
|
+
YAML.load(json)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Code Explanation:
|
|
3
|
+
|
|
4
|
+
There are 3 types of things to auto-complete:
|
|
5
|
+
|
|
6
|
+
1. command: the command itself
|
|
7
|
+
2. parameters: command parameters.
|
|
8
|
+
3. options: command options
|
|
9
|
+
|
|
10
|
+
Here's an example:
|
|
11
|
+
|
|
12
|
+
mycli hello name --from me
|
|
13
|
+
|
|
14
|
+
* command: hello
|
|
15
|
+
* parameters: name
|
|
16
|
+
* option: --from
|
|
17
|
+
|
|
18
|
+
When command parameters are done processing, the remaining completion words will be options. We can tell that the command params are completed based on the method arity.
|
|
19
|
+
|
|
20
|
+
## Arity
|
|
21
|
+
|
|
22
|
+
For example, say you had a method for a CLI command with the following form:
|
|
23
|
+
|
|
24
|
+
ufo scale service count --cluster development
|
|
25
|
+
|
|
26
|
+
It's equivalent ruby method:
|
|
27
|
+
|
|
28
|
+
scale(service, count) = has an arity of 2
|
|
29
|
+
|
|
30
|
+
So typing:
|
|
31
|
+
|
|
32
|
+
ufo scale service count [TAB] # there are 3 parameters including the "scale" command according to Thor's CLI processing.
|
|
33
|
+
|
|
34
|
+
So the completion should only show options, something like this:
|
|
35
|
+
|
|
36
|
+
--noop --verbose --cluster
|
|
37
|
+
|
|
38
|
+
## Splat Arguments
|
|
39
|
+
|
|
40
|
+
When the ruby method has a splat argument, it's arity is negative. Here are some example methods and their arities.
|
|
41
|
+
|
|
42
|
+
ship(service) = 1
|
|
43
|
+
scale(service, count) = 2
|
|
44
|
+
ships(*services) = -1
|
|
45
|
+
foo(example, *rest) = -2
|
|
46
|
+
|
|
47
|
+
Fortunately, negative and positive arity values are processed the same way. So we take simply take the absolute value of the arity and process it the same.
|
|
48
|
+
|
|
49
|
+
Here are some test cases, hit TAB after typing the command:
|
|
50
|
+
|
|
51
|
+
kubes completion
|
|
52
|
+
kubes completion hello
|
|
53
|
+
kubes completion hello name
|
|
54
|
+
kubes completion hello name --
|
|
55
|
+
kubes completion hello name --noop
|
|
56
|
+
|
|
57
|
+
kubes completion
|
|
58
|
+
kubes completion sub:goodbye
|
|
59
|
+
kubes completion sub:goodbye name
|
|
60
|
+
|
|
61
|
+
## Subcommands and Thor::Group Registered Commands
|
|
62
|
+
|
|
63
|
+
Sometimes the commands are not simple thor commands but are subcommands or Thor::Group commands. A good specific example is the ufo tool.
|
|
64
|
+
|
|
65
|
+
* regular command: ufo ship
|
|
66
|
+
* subcommand: ufo docker
|
|
67
|
+
* Thor::Group command: ufo init
|
|
68
|
+
|
|
69
|
+
Auto-completion accounts for each of these type of commands.
|
|
70
|
+
=end
|
|
71
|
+
module Kubes
|
|
72
|
+
class Completer
|
|
73
|
+
def initialize(command_class, *params)
|
|
74
|
+
@params = params
|
|
75
|
+
@current_command = @params[0]
|
|
76
|
+
@command_class = command_class # CLI initiall
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def run
|
|
80
|
+
if subcommand?(@current_command)
|
|
81
|
+
subcommand_class = @command_class.subcommand_classes[@current_command]
|
|
82
|
+
@params.shift # destructive
|
|
83
|
+
Completer.new(subcommand_class, *@params).run # recursively use subcommand
|
|
84
|
+
return
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# full command has been found!
|
|
88
|
+
unless found?(@current_command)
|
|
89
|
+
puts all_commands
|
|
90
|
+
return
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# will only get to here if command aws found (above)
|
|
94
|
+
arity = @command_class.instance_method(@current_command).arity.abs
|
|
95
|
+
if @params.size > arity or thor_group_command?
|
|
96
|
+
puts options_completion
|
|
97
|
+
else
|
|
98
|
+
puts params_completion
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def subcommand?(command)
|
|
103
|
+
@command_class.subcommands.include?(command)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# hacky way to detect that command is a registered Thor::Group command
|
|
107
|
+
def thor_group_command?
|
|
108
|
+
command_params(raw=true) == [[:rest, :args]]
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def found?(command)
|
|
112
|
+
public_methods = @command_class.public_instance_methods(false)
|
|
113
|
+
command && public_methods.include?(command.to_sym)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# all top-level commands
|
|
117
|
+
def all_commands
|
|
118
|
+
commands = @command_class.all_commands.reject do |k,v|
|
|
119
|
+
v.is_a?(Thor::HiddenCommand)
|
|
120
|
+
end
|
|
121
|
+
commands.keys
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def command_params(raw=false)
|
|
125
|
+
params = @command_class.instance_method(@current_command).parameters
|
|
126
|
+
# Example:
|
|
127
|
+
# >> Sub.instance_method(:goodbye).parameters
|
|
128
|
+
# => [[:req, :name]]
|
|
129
|
+
# >>
|
|
130
|
+
raw ? params : params.map!(&:last)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def params_completion
|
|
134
|
+
offset = @params.size - 1
|
|
135
|
+
offset_params = command_params[offset..-1]
|
|
136
|
+
command_params[offset..-1].first
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def options_completion
|
|
140
|
+
used = ARGV.select { |a| a.include?('--') } # so we can remove used options
|
|
141
|
+
|
|
142
|
+
method_options = @command_class.all_commands[@current_command].options.keys
|
|
143
|
+
class_options = @command_class.class_options.keys
|
|
144
|
+
|
|
145
|
+
all_options = method_options + class_options + ['help']
|
|
146
|
+
|
|
147
|
+
all_options.map! { |o| "--#{o.to_s.gsub('_','-')}" }
|
|
148
|
+
filtered_options = all_options - used
|
|
149
|
+
filtered_options.uniq
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Useful for debugging. Using puts messes up completion.
|
|
153
|
+
def log(msg)
|
|
154
|
+
File.open("/tmp/complete.log", "a") do |file|
|
|
155
|
+
file.puts(msg)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
data/lib/kubes/config.rb
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
module Kubes
|
|
2
|
+
class Config
|
|
3
|
+
include Singleton
|
|
4
|
+
include DslEvaluator
|
|
5
|
+
|
|
6
|
+
attr_reader :config
|
|
7
|
+
def initialize
|
|
8
|
+
@config = defaults
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def defaults
|
|
12
|
+
config = ActiveSupport::OrderedOptions.new
|
|
13
|
+
|
|
14
|
+
config.state = ActiveSupport::OrderedOptions.new
|
|
15
|
+
config.state.docker_image_path = "#{Kubes.root}/.kubes/state/docker_image.txt"
|
|
16
|
+
|
|
17
|
+
config.logger = Logger.new($stdout)
|
|
18
|
+
config.logger.level = ENV['KUBES_LOG_LEVEL'] || :info
|
|
19
|
+
|
|
20
|
+
# Auto-switching options
|
|
21
|
+
config.kubectl = ActiveSupport::OrderedOptions.new
|
|
22
|
+
config.kubectl.context = nil
|
|
23
|
+
config.kubectl.context_keep = true # after switching context keep it
|
|
24
|
+
config.kubectl.exit_on_fail = nil # whether or not continue if the kubectl command fails
|
|
25
|
+
|
|
26
|
+
config.kubectl.exit_on_fail_for_apply = true # whether or not continue if the kubectl apply command fails
|
|
27
|
+
config.kubectl.exit_on_fail_for_delete = false # whether or not continue if the kubectl delete command fails
|
|
28
|
+
# Note: not using config.kubectl.delete.exit_on_fail because delete a method internal to ActiveSupport::OrderedOptions
|
|
29
|
+
|
|
30
|
+
config.kubectl.order = ActiveSupport::OrderedOptions.new
|
|
31
|
+
config.kubectl.order.roles = role_order
|
|
32
|
+
config.kubectl.order.kinds = kind_order
|
|
33
|
+
|
|
34
|
+
config.suffix_hash = true # append suffix has to ConfigMap and Secret
|
|
35
|
+
|
|
36
|
+
config.repo = nil # expected to be set by .kubes/config.rb
|
|
37
|
+
|
|
38
|
+
config
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Create shared resources first
|
|
42
|
+
def role_order
|
|
43
|
+
%w[
|
|
44
|
+
common
|
|
45
|
+
shared
|
|
46
|
+
]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Create resources in specific order so dependent resources are available
|
|
50
|
+
def kind_order
|
|
51
|
+
%w[
|
|
52
|
+
Namespace
|
|
53
|
+
StorageClass
|
|
54
|
+
CustomResourceDefinition
|
|
55
|
+
MutatingWebhookConfiguration
|
|
56
|
+
ServiceAccount
|
|
57
|
+
PodSecurityPolicy
|
|
58
|
+
Role
|
|
59
|
+
ClusterRole
|
|
60
|
+
RoleBinding
|
|
61
|
+
ClusterRoleBinding
|
|
62
|
+
ConfigMap
|
|
63
|
+
Secret
|
|
64
|
+
Service
|
|
65
|
+
LimitRange
|
|
66
|
+
Deployment
|
|
67
|
+
StatefulSet
|
|
68
|
+
CronJob
|
|
69
|
+
PodDisruptionBudget
|
|
70
|
+
]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def configure
|
|
74
|
+
yield(@config)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def load_configs
|
|
78
|
+
evaluate_file(".kubes/config.rb")
|
|
79
|
+
evaluate_file(".kubes/config/env/#{Kubes.env}.rb")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|