Skip to content

Commit

Permalink
refactor: align exports (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Lechner <22294087+lechnerc77@users.noreply.github.com>
  • Loading branch information
lechnerc77 and lechnerc77 authored Sep 13, 2024
1 parent 10e5cbe commit 760ca9e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions cmd/exportFromFileHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,38 @@ func exportFromFile(subaccount string, jsonfile string, resourceFile string, con
}
}
if len(value) != 0 {
generateConfigForResource(resName, value, subaccount, configDir)
generateConfigForResource(resName, value, subaccount, configDir, resourceFile)
}
}

generateConfig(resourceFile, configDir)
finalizeTfConfig(configDir)
}

func generateConfigForResource(resource string, values []string, subaccount string, configDir string) {
func generateConfigForResource(resource string, values []string, subaccount string, configDir string, resourceFileName string) {
if resource == "environment-instances" {
exportEnvironmentInstances(subaccount, configDir, values)
execPreExportSteps("saenvinstanceconf")
exportEnvironmentInstances(subaccount, "saenvinstanceconf", values)
execPostExportSteps("saenvinstanceconf", configDir, resourceFileName, "SUBACCOUNT ENVIRONMENT INSTANCES")
}
if resource == "subaccount" {
exportSubaccount(subaccount, configDir, values)
execPreExportSteps("saconf")
exportSubaccount(subaccount, "saconf", values)
execPostExportSteps("saconf", configDir, resourceFileName, "SUBACCOUNT")
}
if resource == "entitlements" {
exportSubaccountEntitlements(subaccount, configDir, values)
execPreExportSteps("saentitlementconf")
exportSubaccountEntitlements(subaccount, "saentitlementconf", values)
execPostExportSteps("saentitlementconf", configDir, resourceFileName, "SUBACCOUNT ENTITLEMENTS")
}
if resource == "subscriptions" {
exportSubaccountSubscriptions(subaccount, configDir, values)
execPreExportSteps("sasubscriptionconf")
exportSubaccountSubscriptions(subaccount, "sasubscriptionconf", values)
execPostExportSteps("sasubscriptionconf", configDir, resourceFileName, "SUBACCOUNT SUBSCRIPTIONS")
}
if resource == "trust-configurations" {
exportTrustConfigurations(subaccount, configDir, values)
execPreExportSteps("satrustconf")
exportTrustConfigurations(subaccount, "satrustconf", values)
execPostExportSteps("satrustconf", configDir, resourceFileName, "SUBACCOUNT TRUST CONFIGURATIONS")
}
}

Expand Down

0 comments on commit 760ca9e

Please sign in to comment.