Class: Polyn::Cli::Commands
- Inherits:
-
Thor
- Object
- Thor
- Polyn::Cli::Commands
- Includes:
- Thor::Actions
- Defined in:
- lib/polyn/cli.rb
Overview
Thor commands for the CLI. Subclassed so other classes can be in the CLI namespace
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
45 46 47 |
# File 'lib/polyn/cli.rb', line 45 def self.exit_on_failure? true end |
Instance Method Details
#init ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/polyn/cli.rb', line 51 def init say "Initializing Polyn schema repository" directory "tf", File.join(.dir, "tf") directory "schemas", File.join(.dir, "schemas") template "docker-compose.yml", File.join(.dir, "docker-compose.yml") template "Dockerfile", File.join(.dir, "Dockerfile") template ".dockerignore", File.join(.dir, ".dockerignore") template ".gitignore", File.join(.dir, ".gitignore") template "README.md", File.join(.dir, "README.md") template "Gemfile", File.join(.dir, "Gemfile") run tf_init say "Initializing git" inside .dir do run "git init" end say "Repository initialized" end |
#tf_init ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/polyn/cli.rb', line 71 def tf_init terraform_root = File.join(.dir, "tf") say "Initializing Terraform" inside terraform_root do # In a development environment we want developers to work with their own local # .tfstate rather than one configured in a remote `backend` intended for # production use. # https://www.terraform.io/language/settings/backends/configuration # # Terraform assumes only one backend will be configured and there's no path # to switch between local and remote. There's also no way to dynamically load # modules. https://github.com/hashicorp/terraform/issues/1439 # Instead we'll copy a backend config to the terraform root if we're in a production # environment if polyn_env == "production" add_remote_backend(terraform_root) { run "terraform init" } else run "terraform init" end end end |
#up ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/polyn/cli.rb', line 94 def up terraform_root = File.join(Dir.getwd, "tf") # We only want to run nats in the docker container if # the developer isn't already running nats themselves locally if polyn_env == "development" && !nats_running? say "Starting NATS" run "docker compose up --detach" end say "Updating JetStream configuration" inside "tf" do if polyn_env == "production" add_remote_backend(terraform_root) { run tf_apply } else run tf_apply end end say "Updating Polyn schema registry" Polyn::Cli::SchemaLoader.new(self).load_schemas end |