Skip to content

Commit

Permalink
Remove usage of terraform.yaml template fie
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 committed Dec 8, 2023
1 parent 1c04820 commit 8c28d4d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 172 deletions.
57 changes: 35 additions & 22 deletions mmv1/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@
api_override_path = File.join(override_dir, product_name, 'api.yaml') if override_dir
api_yaml_path = File.join(product_name, 'api.yaml')

provider_override_path = ''
provider_override_path = File.join(override_dir, product_name, "#{provider_name}.yaml") \
if override_dir
provider_yaml_path = File.join(product_name, "#{provider_name}.yaml")
# provider_override_path = ''
# provider_override_path = File.join(override_dir, product_name, "#{provider_name}.yaml") \
# if override_dir
# provider_yaml_path = File.join(product_name, "#{provider_name}.yaml")

unless File.exist?(product_yaml_path) || File.exist?(product_override_path) \
|| File.exist?(api_yaml_path) || File.exist?(api_override_path)
Expand Down Expand Up @@ -188,13 +188,13 @@
product_yaml = File.read(product_yaml_path)
end

unless File.exist?(provider_yaml_path) || File.exist?(provider_override_path)
unless File.exist?(product_yaml_path) || File.exist?(product_override_path)
Google::LOGGER.info "#{product_name}: Skipped as no #{provider_name}.yaml file exists"
next
end
provider_yaml_path = 'templates/terraform.yaml'
end
# unless File.exist?(provider_yaml_path) || File.exist?(provider_override_path)
# unless File.exist?(product_yaml_path) || File.exist?(product_override_path)
# Google::LOGGER.info "#{product_name}: Skipped as no #{provider_name}.yaml file exists"
# next
# end
# provider_yaml_path = 'templates/terraform.yaml'
# end

raise "Output path '#{output_path}' does not exist or is not a directory" \
unless Dir.exist?(output_path)
Expand All @@ -209,6 +209,8 @@
next
end

Google::LOGGER.info "#{product_yaml_path}: product_yaml_path"

if File.exist?(product_yaml_path) || File.exist?(product_override_path)
resources = []
Dir["#{product_name}/*"].each do |file_path|
Expand Down Expand Up @@ -262,22 +264,33 @@
product_api.set_variable(resources, 'objects')
end

if File.exist?(provider_yaml_path)
product_api, provider_config, = \
Provider::Config.parse(provider_yaml_path, product_api, version)
end
# Load any dynamic overrides passed in with -r
if File.exist?(provider_override_path)
product_api, provider_config, = \
Provider::Config.parse(provider_override_path, product_api, version, override_dir)
end
# Google::LOGGER.info "#{provider_yaml_path}: provider_yaml_path"
# Google::LOGGER.info "#{provider_override_path}: provider_override_path"

# Google::LOGGER.info "#{product_api}: Compiling provider config product_api 0"

# if File.exist?(provider_yaml_path)
# product_api, provider_config, = \
# Provider::Config.parse(provider_yaml_path, product_api, version)
# end
# # Load any dynamic overrides passed in with -r
# if File.exist?(provider_override_path)
# product_api, provider_config, = \
# Provider::Config.parse(provider_override_path, product_api, version, override_dir)
# end

provider_config = nil
product_api&.validate

# Google::LOGGER.info "#{product_api}: Compiling provider config product_api"
# Google::LOGGER.info "#{provider_config}: Compiling provider config provider_config"

Google::LOGGER.info "#{product_name}: Compiling provider config"
pp provider_config if ENV['COMPILER_DEBUG']
# pp provider_config if ENV['COMPILER_DEBUG']

if force_provider.nil?
provider = \
provider_config.provider.new(provider_config, product_api, version, start_time)
Provider::Terraform.new(provider_config, product_api, version, start_time)
else
override_providers = {
'oics' => Provider::TerraformOiCS,
Expand Down
114 changes: 0 additions & 114 deletions mmv1/provider/config.rb

This file was deleted.

24 changes: 12 additions & 12 deletions mmv1/provider/terraform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def generate(output_folder, types, product_path, dump_yaml, generate_code, gener
# common-compile.yaml is a special file that will get compiled by the last product
# used in a single invocation of the compiled. It should not contain product-specific
# information; instead, it should be run-specific such as the version to compile at.
compile_product_files(output_folder) \
unless @config.files.nil? || @config.files.compile.nil?
# compile_product_files(output_folder) \
# unless @config.files.nil? || @config.files.compile.nil?

FileUtils.mkpath output_folder
pwd = Dir.pwd
Expand Down Expand Up @@ -160,16 +160,16 @@ def copy_file_list(output_folder, files)
end

# Compiles files specified within the product
def compile_product_files(output_folder)
file_template = ProductFileTemplate.new(
output_folder,
nil,
@api,
@target_version_name,
build_env
)
compile_file_list(output_folder, @config.files.compile, file_template)
end
# def compile_product_files(output_folder)
# file_template = ProductFileTemplate.new(
# output_folder,
# nil,
# @api,
# @target_version_name,
# build_env
# )
# compile_file_list(output_folder, @config.files.compile, file_template)
# end

# Compiles files that are shared at the provider level
def compile_common_files(
Expand Down
4 changes: 2 additions & 2 deletions mmv1/provider/terraform/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'provider/config'
# require 'provider/config'

module Provider
class Terraform
# Settings for the provider
class Config < Provider::Config
class Config
def provider
Provider::Terraform
end
Expand Down
22 changes: 0 additions & 22 deletions mmv1/templates/terraform.yaml

This file was deleted.

0 comments on commit 8c28d4d

Please sign in to comment.