Skip to content

Commit

Permalink
Code formatted using crystal tool format src
Browse files Browse the repository at this point in the history
Signed-off-by: Aravinda Vishwanathapura <[email protected]>
  • Loading branch information
aravindavk committed Feb 6, 2023
1 parent ac67668 commit 77c777e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/main.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ args = Args.new

OptionParser.parse do |parser|
parser.banner = "Usage: kadalu-volgen [arguments]"
parser.on("-t TEMPLATE", "--template=TEMPLATE", "Template file") { |f| args.template_file = f}
parser.on("-d DATA_FILE", "--data=DATA_FILE", "Data file") { |f| args.data_file = f}
parser.on("-c OPTIONS_FILE", "--options=OPTIONS_FILE", "Options file") { |f| args.options_file = f}
parser.on("-o OUTPUT_FILE", "--output=OUTPUT_FILE", "Output file") { |f| args.output_file = f}
parser.on("-t TEMPLATE", "--template=TEMPLATE", "Template file") { |f| args.template_file = f }
parser.on("-d DATA_FILE", "--data=DATA_FILE", "Data file") { |f| args.data_file = f }
parser.on("-c OPTIONS_FILE", "--options=OPTIONS_FILE", "Options file") { |f| args.options_file = f }
parser.on("-o OUTPUT_FILE", "--output=OUTPUT_FILE", "Output file") { |f| args.output_file = f }
parser.on("-h", "--help", "Show this help") do
puts parser
exit
Expand Down
8 changes: 4 additions & 4 deletions src/options.cr
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ module VolfileOptions
if opt_conf.name == ""
return {
opt_conf.xlator => {
"xlator_enabled" => option_value
}
"xlator_enabled" => option_value,
},
}
end

return {
opt_conf.xlator => {
opt_conf.name => option_value
}
opt_conf.name => option_value,
},
}
end

Expand Down
6 changes: 3 additions & 3 deletions src/supported_options.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "./helpers"

LOG_LEVELS = ["info", "error", "debug"]
ON_OFF = ["on", "off", "enable", "disable", "yes", "no"]
ON_OFF = ["on", "off", "enable", "disable", "yes", "no"]

VolfileOptions.option_config "diagnostics.client-log-level" do |opt|
opt.type = "client"
Expand Down Expand Up @@ -54,7 +54,7 @@ end

VolfileOptions.option_config "performance.strict-o-direct" do |opt|
opt.xlator = "performance/write-behind"
opt.name ="strict-O_DIRECT"
opt.name = "strict-O_DIRECT"
opt.allowed_values = ON_OFF
end

Expand All @@ -76,6 +76,6 @@ end

VolfileOptions.option_config "performance.read-after-open" do |opt|
opt.xlator = "performance/open-behind"
opt.name ="read-after-open"
opt.name = "read-after-open"
opt.allowed_values = ON_OFF
end
15 changes: 7 additions & 8 deletions src/volgen.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Volgen

names.join(" ")
end

def initialize
end
end
Expand Down Expand Up @@ -138,14 +138,14 @@ module Volgen
# If it is last element then add the previous
# element as subvolumes
if idx == (@elements.size - 1)
element.subvolumes = @elements[idx-1].name
element.subvolumes = @elements[idx - 1].name
next
end

subvols = [] of String
(0...idx).each do |i|
# If current element is DHT then find all child elements
# Or if the graph name starts with the current name
# Or if the graph name starts with the current name
if @elements[i].name.starts_with?(element.name) ||
(element.type == "cluster/replicate" && @elements[i].name.ends_with?("-ta")) ||
(element.type == "cluster/distribute" && under_dht?(@elements[i]))
Expand All @@ -155,7 +155,7 @@ module Volgen

# If no subvolumes identified, then add the
# previous element as subvolume.
subvols << @elements[idx-1].name if subvols.size == 0
subvols << @elements[idx - 1].name if subvols.size == 0

element.subvolumes = subvols.join(" ")
end
Expand Down Expand Up @@ -191,9 +191,8 @@ module Volgen

content.to_s
end

end

def self.generate(tmpl, raw_data)
generate(tmpl, raw_data, Hash(String, String).new)
end
Expand All @@ -205,9 +204,9 @@ module Volgen
data = template_data(raw_data)

rendered = case data
when Volume then template.render({"volume" => data})
when Volume then template.render({"volume" => data})
when StorageUnit then template.render({"storage_unit" => data})
else template.render
else template.render
end

volfile = Volfile.new rendered, options
Expand Down

0 comments on commit 77c777e

Please sign in to comment.