Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ref property for string output. #213

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/aaz_dev/cli/controller/az_output_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, output, cmd_ctx):

@property
def ref(self):
if isinstance(self._output, (CMDObjectOutput, CMDArrayOutput)) and self._output.ref:
if isinstance(self._output, (CMDObjectOutput, CMDArrayOutput, CMDStringOutput)) and self._output.ref:
ref, is_selector = self._cmd_ctx.get_variant(self._output.ref)
if is_selector:
return f'{ref}.required()'
Expand All @@ -29,6 +29,8 @@ def next_link(self):
def client_flatten(self):
if isinstance(self._output, (CMDObjectOutput, CMDArrayOutput)):
return self._output.client_flatten is True
elif isinstance(self._output, CMDStringOutput):
return False
else:
raise NotImplementedError()

Expand Down
6 changes: 2 additions & 4 deletions src/aaz_dev/command/model/configuration/_arg_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,12 @@ def get_type(self):

def get_reverse_boolean(self):
assert isinstance(self.schema, CMDBooleanSchemaBase)
if self._ref_arg:
assert isinstance(self._ref_arg, CMDBooleanArgBase)
if self._ref_arg and isinstance(self._ref_arg, CMDBooleanArgBase):
return self._ref_arg.reverse
return False

def get_resource_location_no_rg_default(self):
assert isinstance(self.schema, CMDResourceLocationSchemaBase)
if self._ref_arg:
assert isinstance(self._ref_arg, CMDResourceLocationArgBase)
if self._ref_arg and isinstance(self._ref_arg, CMDResourceLocationArgBase):
return self._ref_arg.no_rg_default
return False
5 changes: 4 additions & 1 deletion src/aaz_dev/command/model/configuration/_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ class CMDArrayOutput(CMDOutput):
class CMDStringOutput(CMDOutput):
TYPE_VALUE = 'string'

value = StringType(required=True)
# ref means get value from content
ref = CMDVariantField()
# use placeholder value as output
value = StringType()