Skip to content

Commit

Permalink
Don't require -o arg when running autogen (GoogleCloudPlatform#11474)
Browse files Browse the repository at this point in the history
  • Loading branch information
SirGitsalot authored Aug 19, 2024
1 parent 1f43377 commit b0013a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mmv1/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
if products_to_generate && all_products
raise 'Either -p/--products OR -a/--all must be present' \
if products_to_generate.nil? && !all_products
raise 'Option -o/--output is a required parameter' if output_path.nil?
raise 'Option -o/--output is a required parameter' \
if output_path.nil? && !openapi_generate
raise 'Option -e/--engine is a required parameter' if provider_name.nil?

if openapi_generate
Expand Down
7 changes: 6 additions & 1 deletion mmv1/openapi_generate/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def initialize(folder, output)
end

def run
Dir[@folder].each do |openapi_file|
openapi_dir = Dir[@folder]
raise "No OpenAPI files found in #{@folder}" if openapi_dir.empty?

openapi_dir.each do |openapi_file|
write_yaml(openapi_file, @output)
end
end
Expand Down Expand Up @@ -287,10 +290,12 @@ def build_product(spec_path, output)
def write_yaml(spec_path, output)
resource_paths = find_resources(spec_path)
product_path = build_product(spec_path, output)
Google::LOGGER.info "Generated product '#{product_path}/product.yaml'"
resource_paths.each do |path_array|
resource = build_resource(spec_path, path_array[0], path_array[1])
file_path = File.join(product_path, "#{resource.name}.yaml")
File.write(file_path, resource.to_yaml)
Google::LOGGER.info "Generated resource '#{file_path}'"
end
end
end
Expand Down

0 comments on commit b0013a8

Please sign in to comment.