-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4fd1f1
commit 2cf8206
Showing
12 changed files
with
90 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ class Aws(AwsBase): | |
id: int | ||
|
||
class Config: | ||
orm_mode = True | ||
from_attributes = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ class Azure(AzureBase): | |
id: int | ||
|
||
class Config: | ||
orm_mode = True | ||
from_attributes = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ class CustomProvider(CustomProviderBase): | |
id: int | ||
|
||
class Config: | ||
orm_mode = True | ||
from_attributes = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,4 @@ class Deploy(DeployBase): | |
user_id: int | ||
|
||
class Config: | ||
orm_mode = True | ||
from_attributes = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ class Gcloud(GcloudBase): | |
id: int | ||
|
||
class Config: | ||
orm_mode = True | ||
from_attributes = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import hcl2 | ||
|
||
|
||
def convert_to_json(file_path): | ||
with open(file_path, "r") as f: | ||
hcl_data = hcl2.load(f) | ||
clean_data = remove_interpolations(hcl_data) | ||
json_data = list_to_dict(clean_data["variable"]) | ||
return json_data | ||
|
||
|
||
def remove_interpolations(data): | ||
if isinstance(data, dict): | ||
return {k: remove_interpolations(v) for k, v in data.items()} | ||
elif isinstance(data, list): | ||
return [remove_interpolations(elem) for elem in data] | ||
elif isinstance(data, str): | ||
return data.replace("${", "").replace("}", "") | ||
else: | ||
return data | ||
|
||
|
||
def is_interpolation(value): | ||
return isinstance(value, str) and "${" in value | ||
|
||
|
||
def list_to_dict(variables_list: list) -> dict: | ||
variables_dict = {k: v for d in variables_list for k, v in d.items()} | ||
return variables_dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters