renuo-cli 4.17.1 → 4.17.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d001b3727b2158e75b84057e5520246f4a4983ebc9008a97802134a07a7fe9a1
4
- data.tar.gz: d258158583a1659efea53a52cfb1e29569753e55e4c30d62c95984fed5498813
3
+ metadata.gz: 4e5e4edeb2c97766d224c621442512a677b7d6c0f65578698bd70bcfe46df3df
4
+ data.tar.gz: c95e67243cf5cd444f3601c545c207786cf59bd67833406d6120bac816473205
5
5
  SHA512:
6
- metadata.gz: cea757ec3ba510fbec394fe7d313edac2ef4db8e7d31f53e0c9cf83af0ef8d8225e53fa68a3f3c4beea206ef55e022774ef2cd342a1545aa4af925016b936bb1
7
- data.tar.gz: 38a9b4a0b037a9ec087fd39060b7b154fbb5ce77533e80f9d977246c62f25fc3dee99e88f36ac7cdf96ec7eb01f7651ef6a89eac22bcb43dbf8c2a95ae1a35bd
6
+ metadata.gz: 70a03383d91f799fd4bcae9acce5425f550af8da2f86424ee77960da92ad976ec6c7ff09ee755d5f1490d651e7be4978539ac5b6308471efbb212b219c7034e7
7
+ data.tar.gz: 452fca47194f507a0e6651b116c45ab97db03cb5aa9dcfba2c0ae24b10dc3f254984def3dcb17f2bd1ea735422c2b17540d2939b7a6037be4cea7b1cabc1ac3d
@@ -83,6 +83,11 @@ class Renuo::Cli::Commands::CheckDeploioStatus
83
83
  when "available", "success"
84
84
  puts "#{type} succeeded"
85
85
  true
86
+ when "superseded"
87
+ puts "release was superseded"
88
+ true
89
+ when "paused"
90
+ abort "app is paused"
86
91
  when "error", "failed", "failure"
87
92
  puts fetch_build_logs
88
93
  abort "#{type} failed"
@@ -9,7 +9,7 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
9
9
  PROJECT_NAME_PREFIX = "renuo-"
10
10
 
11
11
  command "create-deploio-app" do |c|
12
- c.syntax = "renuo create-deploio-app"
12
+ c.syntax = "renuo create-deploio-app [project-name] [git-url]"
13
13
  c.summary = "Generates the script necessary to setup an application on Deploio."
14
14
  c.description = <<~DESC
15
15
  Generates the script necessary to setup an application on Deploio.
@@ -20,13 +20,16 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
20
20
  - Configure repository access by generating SSH keys and adding them to 1Password.
21
21
  - Create the application and database for each specified environment.
22
22
  DESC
23
- c.example "renuo create-deploio-app",
23
+ c.option "--org <organization>", String, "The organization name"
24
+ c.example "renuo create-deploio-app my-app git@github.com:renuo/my-app.git",
24
25
  "Prompts the user for the necessary information and generates the commands " \
25
26
  "to create the project, databases, and apps on Deploio."
26
- c.action { new.run }
27
+ c.action { |args, options| new.run(args, options) }
27
28
  end
28
29
 
29
- def run
30
+ def run(args, options = {})
31
+ @project_name, @git_url = args
32
+ @options = options
30
33
  parse_arguments
31
34
  setup_commands
32
35
  setup_environments
@@ -50,7 +53,12 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
50
53
 
51
54
  private
52
55
 
56
+ def valid_name?(name)
57
+ name&.length&.between?(3, 63) && name.match?(/^[a-z0-9-]+$/)
58
+ end
59
+
53
60
  def parse_arguments
61
+ set_organization
54
62
  set_project_name
55
63
  set_git_url
56
64
  set_postgres_version
@@ -59,24 +67,25 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
59
67
 
60
68
  def set_project_name
61
69
  loop do
62
- @project_name = ask("Enter the project name (e.g: my-app): ")
63
-
64
- break if @project_name&.length&.between?(3, 63) && @project_name.match?(/^[a-z0-9-]+$/)
70
+ break if valid_name?(@project_name)
65
71
 
66
72
  say ">> Project name must be between 3 and 63 characters and can only contain lowercase letters, " \
67
73
  "numbers, and hyphens. Please try again.".colorize(:red)
74
+
75
+ @project_name = ask("Enter the project name (e.g: my-app): ")
68
76
  end
69
77
 
70
78
  @project_display_name = @project_name
71
- @project_name = PROJECT_NAME_PREFIX + @project_name
79
+ @project_name_with_org_prefix = "#{@organization}-#{@project_name}"
72
80
  end
73
81
 
74
82
  def set_git_url
75
83
  loop do
76
- @git_url = ask("Enter the git URL (e.g: git@github.com:my-org/my-app.git): ")
77
84
  break if @git_url.present? && git_url_valid?(@git_url)
78
85
 
79
86
  say ">> Git URL must be provided and valid. Please try again.".colorize(:red)
87
+
88
+ @git_url = ask("Enter the git URL: ") { |q| q.default = "git@github.com:renuo/#{@project_name}.git" }
80
89
  end
81
90
 
82
91
  return unless http_git_url?(@git_url)
@@ -87,26 +96,31 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
87
96
 
88
97
  def set_postgres_version
89
98
  loop do
90
- @postgres_version = ask("Enter Postgres version (e.g., 16) or leave empty to skip database creation: ")
99
+ @postgres_version = ask("Enter Postgres version (e.g., 17) or leave empty to skip database creation: ")
91
100
  break if @postgres_version.empty? || @postgres_version.match?(/^\d+$/)
92
101
 
93
102
  say ">> The postgres version is invalid. Only major versions are allowed. " \
94
- "For example, use 16 instead of 16.4. Please try again.".colorize(:red)
103
+ "For example, use 17 instead of 17.4. Please try again.".colorize(:red)
104
+ end
105
+ end
106
+
107
+ def set_vault_name
108
+ @vault_name = ask("SSH Credentials for deploio to access the git repo will be stored on 1Password. " \
109
+ "Enter the 1Password vault name: ") do |q|
110
+ q.default = "Deploio"
95
111
  end
96
112
  end
97
113
 
98
- def set_vault_name # rubocop:disable Metrics/MethodLength
114
+ def set_organization
115
+ @organization = @options.org if @options.org
116
+
99
117
  loop do
100
- @vault_name = ask("Enter the 1Password vault name (leave empty to skip): ")
101
- if @vault_name.empty?
102
- say "Skipping 1Password vault setup. Defaulting to Deploio."
103
- @vault_name = "Deploio"
104
- break
105
- elsif @vault_name.present?
106
- break
107
- else
108
- say ">> The vault name must be provided. Please try again.".colorize(:red)
109
- end
118
+ break if valid_name?(@organization)
119
+
120
+ say ">> Organization name must be between 3 and 63 characters and can only contain lowercase letters, " \
121
+ "numbers, and hyphens. Please try again.".colorize(:red)
122
+
123
+ @organization = ask("Enter the organization name (default: renuo): ") { |q| q.default = "renuo" }
110
124
  end
111
125
  end
112
126
 
@@ -136,28 +150,36 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
136
150
 
137
151
  def say_project_creation
138
152
  say <<~OUTPUT
139
- nctl create project #{@project_name} --display-name='#{@project_display_name}'
153
+ nctl create project #{@project_name_with_org_prefix} --display-name='#{@project_display_name}' --organization=#{@organization}
140
154
  OUTPUT
141
155
  end
142
156
 
143
157
  def say_database_creation(environment)
144
- say <<~OUTPUT
145
- nctl create postgres #{environment} \\
146
- --project=#{@project_name} \\
147
- --postgres-version=#{@postgres_version} \\
148
- --machine-type=nine-db-xs
149
- OUTPUT
158
+ if environment == "main"
159
+ say <<~OUTPUT
160
+ nctl create postgres #{environment} \\
161
+ --project=#{@project_name_with_org_prefix} \\
162
+ --postgres-version=#{@postgres_version} \\
163
+ --machine-type=nine-db-xs
164
+ OUTPUT
165
+ else
166
+ say <<~OUTPUT
167
+ nctl create postgresdatabase #{environment} \\
168
+ --project=#{@project_name_with_org_prefix} \\
169
+ --postgres-database-version=#{@postgres_version}
170
+ OUTPUT
171
+ end
150
172
  end
151
173
 
152
174
  def say_app_creation(environment)
153
175
  say <<~OUTPUT
154
176
  nctl create app #{environment} \\
155
- --project #{@project_name} \\
177
+ --project #{@project_name_with_org_prefix} \\
156
178
  --git-ssh-private-key-from-file=#{GITHUB_SSH_KEY_FILE_NAME} \\
157
179
  --git-url=#{@git_url} \\
158
180
  --git-revision="#{environment}" \\
159
- --basic-auth=false `# Disabling Deploio basic auth as Rails app handles authentication` \\
160
- --build-env=SECRET_KEY_BASE='rails secret' `# Do not forget to generate the secret key` \\
181
+ --basic-auth=#{environment == "develop"} \\
182
+ --build-env=SECRET_KEY_BASE="$(rails secret)" \\
161
183
  --language=ruby \\
162
184
  --size=mini
163
185
  OUTPUT
@@ -167,16 +189,19 @@ class Renuo::Cli::Commands::CreateDeploioApp # rubocop:disable Metrics/ClassLeng
167
189
  say <<~OUTPUT
168
190
  # Create SSH key item in 1Password directly
169
191
  op item create \\
192
+ --account renuo.1password.com \\
170
193
  --category ssh \\
171
194
  --ssh-generate-key #{SSH_ALGORITHM.downcase} \\
172
- --title "#{@project_name}-deploy-key" \\
195
+ --title "#{@project_name_with_org_prefix}-deploy-key" \\
173
196
  --vault #{@vault_name} \\
174
- --tags #{@project_name}
197
+ --tags #{@project_name_with_org_prefix}
175
198
 
176
199
  # Extract keys to temp files for deploio usage
177
- op item get "#{@project_name}-deploy-key" --vault #{@vault_name} \\
200
+ op item get "#{@project_name_with_org_prefix}-deploy-key" --vault #{@vault_name} \\
201
+ --account renuo.1password.com \\
178
202
  --reveal --fields "public key" > #{file_name}.pub
179
- op item get "#{@project_name}-deploy-key" --vault #{@vault_name} --reveal \\
203
+ op item get "#{@project_name_with_org_prefix}-deploy-key" --vault #{@vault_name} --reveal \\
204
+ --account renuo.1password.com \\
180
205
  --fields "private key" --format json | jq -r '.ssh_formats.openssh.value' > #{file_name}
181
206
  OUTPUT
182
207
  end
@@ -3,7 +3,7 @@
3
3
  # :nocov:
4
4
  module Renuo
5
5
  class Cli
6
- VERSION = "4.17.1"
6
+ VERSION = "4.17.3"
7
7
  NAME = "renuo-cli"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renuo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.17.1
4
+ version: 4.17.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renuo AG
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.7.2
139
+ rubygems_version: 3.6.9
140
140
  specification_version: 4
141
141
  summary: The Renuo CLI automates some common workflows.
142
142
  test_files: []