Class: ClusterFsck::Commands::Edit

Inherits:
Object
  • Object
show all
Includes:
ClusterFsckEnvArgumentParser, Commander::UI
Defined in:
lib/clusterfsck/commands/edit.rb

Instance Method Summary collapse

Methods included from ClusterFsckEnvArgumentParser

included, #set_cluster_fsck_env_and_key_from_args

Instance Method Details

#readerObject



24
25
26
# File 'lib/clusterfsck/commands/edit.rb', line 24

def reader
  @reader ||= ClusterFsck::Reader.new(key, cluster_fsck_env: cluster_fsck_env)
end

#run_command(args, options = Hashie::Mash.new) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
# File 'lib/clusterfsck/commands/edit.rb', line 9

def run_command(args, options = Hashie::Mash.new)
  raise ArgumentError, "must provide a project name" if args.empty?
  set_cluster_fsck_env_and_key_from_args(args)

  @options = options
  raise ArgumentError, "File #{key} is overridden locally! use --force to force" if reader.has_local_override? and !options.force

  new_yaml = ask_editor(YAML.dump(reader.read(remote_only: true).to_hash))
  writer.set(Configuration.from_yaml(new_yaml), reader.version_count)
end

#writerObject



20
21
22
# File 'lib/clusterfsck/commands/edit.rb', line 20

def writer
  @writer ||= ClusterFsck::Writer.new(key, cluster_fsck_env: reader.cluster_fsck_env)
end