Skip to content

Commit ed39096

Browse files
committed
Add local config repo capability
1 parent 070c2ac commit ed39096

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ To begin:
3232

3333
**TIP:** You can add a # onto the end of the configuration repository location followed by a branch, tag or commit you want to check out, if the default branch is not good enough.
3434

35+
**TIP:** You can specify 'local' instead of a git URL to manage your application list locally without relying on an external Git repository. This is useful when you want complete control over your configuration or are working on a new service that does not have a remote config repo yet. The dev-env will create the `dev-env-config` directory and a default `configuration.yml` will be created with an empty services list. You can then manually add applications to that list, optionally utilising the `repo: none` functionality talked about in the next section.
36+
3537
Other `run.sh` parameters are:
3638

3739
- `halt` - stops all containers

logic.rb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,35 @@
123123
config_repo = $stdin.gets.chomp
124124
File.open(DEV_ENV_CONTEXT_FILE, 'w+') { |file| file.write(config_repo) }
125125
end
126-
126+
127+
config_repo = File.read(DEV_ENV_CONTEXT_FILE)
127128
# Check if dev-env-config exists, and if so pull the dev-env configuration. Otherwise clone it.
128129
if Dir.exist?(DEV_ENV_CONFIG_DIR)
129130
new_project = false
130-
command_successful = run_command("git -C #{root_loc}/dev-env-config pull")
131+
if config_repo == "local"
132+
command_successful = 0
133+
else
134+
command_successful = run_command("git -C #{root_loc}/dev-env-config pull")
135+
end
131136
else
132137
new_project = true
133-
config_repo = File.read(DEV_ENV_CONTEXT_FILE)
134138
parsed_repo, delimiter, ref = config_repo.rpartition('#')
135139
# If they didn't specify a #ref, rpartition returns "", "", wholestring
136140
parsed_repo = ref if delimiter.empty?
137-
command_successful = run_command("git clone #{parsed_repo} #{root_loc}/dev-env-config")
138-
if command_successful.zero? && !delimiter.empty?
139-
command_successful = run_command("git -C #{root_loc}/dev-env-config checkout #{ref}")
141+
if config_repo == "local"
142+
puts colorize_lightblue("Initializing local config repository.")
143+
run_command("mkdir #{DEV_ENV_CONFIG_DIR}")
144+
# Create a configuration.yml with an empty services array
145+
File.open("#{DEV_ENV_CONFIG_DIR}/configuration.yml", 'w') do |file|
146+
file.write("---\nservices: {}\n")
147+
end
148+
puts colorize_green("You can start adding apps to #{DEV_ENV_CONFIG_DIR}/configuration.yml")
149+
exit 1
150+
else
151+
command_successful = run_command("git clone #{parsed_repo} #{DEV_ENV_CONFIG_DIR}")
152+
if command_successful.zero? && !delimiter.empty?
153+
command_successful = run_command("git -C #{DEV_ENV_CONFIG_DIR} checkout #{ref}")
154+
end
140155
end
141156
end
142157

0 commit comments

Comments
 (0)