Class: Minfra::Cli::Project::Tag

Inherits:
Command show all
Defined in:
lib/minfra/cli/commands/project/tag.rb

Instance Method Summary collapse

Methods included from Logging

#debug, #deprecated, #error, #exit_error, #info, #warn

Methods included from Common

#run_cmd

Instance Method Details

#update(domain, new_tag) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/minfra/cli/commands/project/tag.rb', line 9

def update(domain, new_tag)
  tags = JSON.parse(File.read(tags_path))

  raise ArgumentError, "#{path} doesn't contain #{domain}" unless tags[options[:environment]].key?(domain)

  tags[options[:environment]][domain] = new_tag
  pretty_tags = JSON.pretty_unparse(tags)
  File.write(tags_path, "#{pretty_tags}\n")
  puts "#{tags_path} - UPDATED"
  puts pretty_tags
end