Skip to content

Commit

Permalink
Make main-tf contents exported
Browse files Browse the repository at this point in the history
Signed-off-by: Mitch Connors <[email protected]>
  • Loading branch information
therealmitchconnors committed Nov 20, 2023
1 parent bed1fa2 commit 0752be6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/terraform/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ type FileProducer struct {
features *feature.Flags
}

// WriteMainTF writes the content main configuration file that has the desired
// state configuration for Terraform.
func (fp *FileProducer) WriteMainTF() (ProviderHandle, error) {
func (fp *FileProducer) BuildMainTF() map[string]any {
// If the resource is in a deletion process, we need to remove the deletion
// protection.
lifecycle := map[string]any{
Expand All @@ -153,7 +151,7 @@ func (fp *FileProducer) WriteMainTF() (ProviderHandle, error) {
// Note(turkenh): To use third party providers, we need to configure
// provider name in required_providers.
providerSource := strings.Split(fp.Setup.Requirement.Source, "/")
m := map[string]any{
return map[string]any{
"terraform": map[string]any{
"required_providers": map[string]any{
providerSource[len(providerSource)-1]: map[string]string{
Expand All @@ -171,6 +169,12 @@ func (fp *FileProducer) WriteMainTF() (ProviderHandle, error) {
},
},
}
}

// WriteMainTF writes the content main configuration file that has the desired
// state configuration for Terraform.
func (fp *FileProducer) WriteMainTF() error {
m := fp.BuildMainTF()
rawMainTF, err := json.JSParser.Marshal(m)
if err != nil {
return InvalidProviderHandle, errors.Wrap(err, "cannot marshal main hcl object")
Expand Down

0 comments on commit 0752be6

Please sign in to comment.