Skip to content

Add aciconvert subcommand to confcom#80

Open
ksayid wants to merge 12 commits intomainfrom
input_converter
Open

Add aciconvert subcommand to confcom#80
ksayid wants to merge 12 commits intomainfrom
input_converter

Conversation

@ksayid
Copy link
Copy Markdown
Collaborator

@ksayid ksayid commented Jan 15, 2025

Introduces aciconvert subcommand, which converts ARM templates, images, or YAML files into JSON format. This was an ask from an internal customer.

Other changes

  • Env vars are now sorted alphabetically in the policy. This was done to make the policy from $$\text{YAML} \overset{\text{aciconvert}}{\to} \text{JSON} \overset{\text{acipolicygen}}{\to} \text{Policy}$$ match the policy from $$\text{YAML} \overset{\text{acipolicygen}}{\to} \text{Policy}$$
  • Made a few tests more flexible. They assumed the positions of env vars in the policy, but now we just check for existence in the list of env vars.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 9 changed files in this pull request and generated 2 comments.

Files not reviewed (4)
  • src/confcom/azext_confcom/commands.py: Evaluated as low risk
  • src/confcom/azext_confcom/_validators.py: Evaluated as low risk
  • src/confcom/azext_confcom/_params.py: Evaluated as low risk
  • src/confcom/azext_confcom/container.py: Evaluated as low risk
Comments suppressed due to low confidence (1)

src/confcom/azext_confcom/custom.py:400

  • The filename handling logic in the loop could lead to unexpected behavior if multiple policies are generated. Ensure the filenames are correctly handled to avoid overwriting files.
output_filename = f"{output_filename_base}_({i}).json"

split_env_rules = []
for env in env_rules:
temp_env = {}
rule = temp_env["name"] = env[config.POLICY_FIELD_CONTAINERS_ELEMENTS_ENVS_RULE]
Copy link

Copilot AI Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The split operation on the environment variable rule assumes there will always be exactly one '=' character. Add a check to ensure the rule format is correct before splitting.

Suggested change
rule = temp_env["name"] = env[config.POLICY_FIELD_CONTAINERS_ELEMENTS_ENVS_RULE]
if rule.count('=') != 1: logger.warning("Environment variable rule %s has more than one '='. Please verify its format in the output file", rule); continue

Copilot uses AI. Check for mistakes.
print(output)


def convert_to_json_confcom(
Copy link

Copilot AI Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function does not handle cases where all input parameters (arm_template, image_name, virtual_node_yaml_path) are None. This could lead to a situation where container_group_policies is None, causing the subsequent code to fail. Add a check to ensure at least one input parameter is provided and raise a clear error message if not.

Copilot uses AI. Check for mistakes.
properties["volumeMounts"] = image.get_mounts()
if image.get_exec_processes():
properties["execProcesses"] = image.get_exec_processes()
# if image.get_signals():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these commented out?

SethHollandsworth pushed a commit that referenced this pull request Jan 27, 2025
* build: add cicd pipeline (#7)

* build: move update version logic to workflow (#8)

* build: Run CI on multiple python version (#38)

* build: Run CI in Python 3.8-3.11

* build: remove pull request event for CI to avoid duplicate runs

* feat: enable openapi spec from url in api register (#74)

* feat: enable openapi spec from url in api register

* refactor: set spec definition as link format when link provided

* fix: fix style

* test: add error handling case for testing invalid spec url

* fix: fix test case

* fix: use 404 response url

* test: update case

* test: update test case

* refactor: update error logic

* test: update test case to setup live test pipeline (#76)

* test: update test case to setup live test pipeline (#75)

* test: update test case

* update

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* test: update test case

* refactor: enable both identity

* fix: bad if else

* fix: fix bad parameter

* refactor: add example (#77)

* refactor: add example

* fix: update params

* fix: bad api id

* refactor: add @filename.json examples (#78)

* refactor: add example

* fix: update params

* fix: bad api id

* refactor: add @filename.json examples

* refactor: update

* refactor: add error handling (#79)

* refactor: add error handling

* refactor: catch internal error

* fix: revert the change

* feat: support APIM/APIC sync (#80)

* feat: add APIM/APIC sync commands

* feat: rename apim to azure-api-management

* style: fix code style

* fix: sync property names with new API spec

* Revert "fix: sync property names with new API spec"

This reverts commit 04da67e.

---------

Co-authored-by: frankqianms <frankqian@microsoft.com>

* feat: resolve feedback and fix examples (#82)

* feat: resolve feedback and fix examples

* style: fix code style

* feat: amazon api gateway sync (#81)

* feat: add APIM/APIC sync commands

* feat: rename apim to azure-api-management

* style: fix code style

* fix: sync property names with new API spec

* feat: add aws api gateway sync command

* Revert "fix: sync property names with new API spec"

This reverts commit 04da67e.

* refactor: add amazonApiGatewaySource

* refactor: refactoring apim sync and amazon sync

* refactor: refactor cmd structure to make apim and aws sync seperated

* fix: remove log print

* chore: generate new cmds

* refactor: update version and remove import

* feat: add `apic integration create amazon-api-gateway`

* fix: style

* fix: change query param api-version

* revert changes in _delete.py

* fix: some neede fixs

* fix: add the help sentence

* refactor: make params clear

* refactor: handle msi-resource-id

* refacor: revert flatten of apim resource

* fix: use 06-01-preiew currently

* fix: style

* refactor: arg groups

* fix: bad short param name

* chore: re-generate

* fix: old resource_id name

* chore: arg group

* chore: naming

* fix: fix according to comments

* chore: update

* fix: style

---------

Co-authored-by: Chaoyi Yuan <chyuan@microsoft.com>

* feat: add import amazon-api-gateway cmd (#83)

* feat: add import amazon-api-gateway cmd

* feat: change arg group and update parameter name

---------

Co-authored-by: Chaoyi Yuan <chyuan@microsoft.com>

* fix: use older version API (#84)

* feat: rename command and param names (#85)

* feat: rename command and param names

* doc: update comments

* doc: update sample

* test: add test case for sync cmd `apic integration create apim` and `apic integration create aws` (#86)

* test: add test case for apim sync

* refactor: refactor for apim preparer

* refactor: refactoring case and utils, optimize checkers

* chore: remove print and add explaination

* refactor: rename file

* fix: try to fix error determing the version

* revert: Remove specific azure-cli and azure-core installations

* test: add aws sync testcase (#87)

* test: add test case for aws sync command

* fix: remove key value

* fix: remove pip install

* chore: renaming constants

* refactor: update the utils and test case

* refactor: updated

* fix: workaround for urllib3 package (#88)

* Revert "fix: workaround for urllib3 package (#88)" (#90)

This reverts commit 1d508f4.

* build: 1.2.0 beta 1 release

* build: remove CI and CD files

* doc: improve history

* fix: set extention version to be preview

* refactor: integration examples and bad example for `apic update` (#91)

* refactor: integration examples

* fix: apic update example

* chore: update log

* test: add import-aws case and modify region

---------

Co-authored-by: Chaoyi Yuan <blackchoey@gmail.com>
Co-authored-by: Chaoyi Yuan <chyuan@microsoft.com>
@SethHollandsworth SethHollandsworth force-pushed the main branch 2 times, most recently from 10309d8 to 107e9cf Compare June 9, 2025 14:06
SethHollandsworth pushed a commit that referenced this pull request Aug 27, 2025
* build: add cicd pipeline (#7)

* build: move update version logic to workflow (#8)

* build: Run CI on multiple python version (#38)

* build: Run CI in Python 3.8-3.11

* build: remove pull request event for CI to avoid duplicate runs

* feat: enable openapi spec from url in api register (#74)

* feat: enable openapi spec from url in api register

* refactor: set spec definition as link format when link provided

* fix: fix style

* test: add error handling case for testing invalid spec url

* fix: fix test case

* fix: use 404 response url

* test: update case

* test: update test case

* refactor: update error logic

* test: update test case to setup live test pipeline (#76)

* test: update test case to setup live test pipeline (#75)

* test: update test case

* update

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* test: update test case

* refactor: enable both identity

* fix: bad if else

* fix: fix bad parameter

* refactor: add example (#77)

* refactor: add example

* fix: update params

* fix: bad api id

* refactor: add @filename.json examples (#78)

* refactor: add example

* fix: update params

* fix: bad api id

* refactor: add @filename.json examples

* refactor: update

* refactor: add error handling (#79)

* refactor: add error handling

* refactor: catch internal error

* fix: revert the change

* feat: support APIM/APIC sync (#80)

* feat: add APIM/APIC sync commands

* feat: rename apim to azure-api-management

* style: fix code style

* fix: sync property names with new API spec

* Revert "fix: sync property names with new API spec"

This reverts commit 04da67e.

---------

Co-authored-by: frankqianms <frankqian@microsoft.com>

* feat: resolve feedback and fix examples (#82)

* feat: resolve feedback and fix examples

* style: fix code style

* feat: amazon api gateway sync (#81)

* feat: add APIM/APIC sync commands

* feat: rename apim to azure-api-management

* style: fix code style

* fix: sync property names with new API spec

* feat: add aws api gateway sync command

* Revert "fix: sync property names with new API spec"

This reverts commit 04da67e.

* refactor: add amazonApiGatewaySource

* refactor: refactoring apim sync and amazon sync

* refactor: refactor cmd structure to make apim and aws sync seperated

* fix: remove log print

* chore: generate new cmds

* refactor: update version and remove import

* feat: add `apic integration create amazon-api-gateway`

* fix: style

* fix: change query param api-version

* revert changes in _delete.py

* fix: some neede fixs

* fix: add the help sentence

* refactor: make params clear

* refactor: handle msi-resource-id

* refacor: revert flatten of apim resource

* fix: use 06-01-preiew currently

* fix: style

* refactor: arg groups

* fix: bad short param name

* chore: re-generate

* fix: old resource_id name

* chore: arg group

* chore: naming

* fix: fix according to comments

* chore: update

* fix: style

---------

Co-authored-by: Chaoyi Yuan <chyuan@microsoft.com>

* feat: add import amazon-api-gateway cmd (#83)

* feat: add import amazon-api-gateway cmd

* feat: change arg group and update parameter name

---------

Co-authored-by: Chaoyi Yuan <chyuan@microsoft.com>

* fix: use older version API (#84)

* feat: rename command and param names (#85)

* feat: rename command and param names

* doc: update comments

* doc: update sample

* test: add test case for sync cmd `apic integration create apim` and `apic integration create aws` (#86)

* test: add test case for apim sync

* refactor: refactor for apim preparer

* refactor: refactoring case and utils, optimize checkers

* chore: remove print and add explaination

* refactor: rename file

* fix: try to fix error determing the version

* revert: Remove specific azure-cli and azure-core installations

* test: add aws sync testcase (#87)

* test: add test case for aws sync command

* fix: remove key value

* fix: remove pip install

* chore: renaming constants

* refactor: update the utils and test case

* refactor: updated

* fix: workaround for urllib3 package (#88)

* Revert "fix: workaround for urllib3 package (#88)" (#90)

This reverts commit 1d508f4.

* build: 1.2.0 beta 1 release

* build: remove CI and CD files

* doc: improve history

* fix: set extention version to be preview

* refactor: integration examples and bad example for `apic update` (#91)

* refactor: integration examples

* fix: apic update example

* feat: add api-analysis rules (#89)

* feat: analysi rule init

* feat: add create cmd

* feat: add create and delete api-analysis commands

* feat: add import-ruleset and export-ruleset commands

* fix: update aaz

* fix: registered

* fix: examples

* fix: fix style

* refactor: renaming

* refactor: regenerate aaz

* fix: fix codes

* fix: fix logics

* fix: style

* fix: rename parameter service name

* fix: change api-analysis status to preview

* fix: integration list

* refactor: modify examples

* feat: analysi rule init

* feat: add create cmd

* feat: add create and delete api-analysis commands

* feat: add import-ruleset and export-ruleset commands

* fix: update aaz

* fix: registered

* fix: examples

* fix: fix style

* refactor: renaming

* refactor: regenerate aaz

* fix: fix codes

* fix: fix logics

* fix: style

* fix: change api-analysis status to preview

* fix: change short name of service name

* fix: apic update example

* fix: examples and default value

* chore: example

* fix: bad parameter short names

* fix: downgrade api version

* fix: set default workspace for list,show,update api-analysis

* refactor: integration examples

* fix: style

* chore: update log

* test: add import-aws case and modify region

* feat: add import apim and deperacate import-from-apim, add analysis create and list test cases

* fix: correctly deprecate import-from-apim

* test: add apianalysis test cases

* build: bump up to 1.2.0b2

* test: add api-analysis update testcase

* build: change log of 1.2.0b2

* chore: unregister the filter

* fix: better methods name and remove extra lint disable

* refactor: set default analyzer-type in aaz

* refactor: remove preview tag for some integration commands and hide the analyzer_type param

* chore: update spec for filter param

* fix: set default analyzer_type correctly

* fix: import apim fix (#92)

* add CD

* rename

* upgrade upload-artifact

* fix: fix missing apis param in import apim

* fix: regenerate according to new spec

* cd: remove cd file

* test: update test cases

* fix: fix spec version in register command

* test: update test cases

* test: update recordings

* test: live test

* fix: fix test cases of api analysis

* fix: update recordings

* fix: remove comment

* fix: merge and align latest version

* Update command_patches.py

fix linter

* fix: remove import cmds & preview tag of integrate cmds

* test: remove uneeded test cases

* fix: fix linter failures for auto generated params

* test: update tests

* Update HISTORY.rst

* fix: remove extra yml

* Update HISTORY.rst

* test: update test cases and recordings

* fix: fix cases

---------

Co-authored-by: Chaoyi Yuan <blackchoey@gmail.com>
Co-authored-by: Chaoyi Yuan <chyuan@microsoft.com>
@SethHollandsworth SethHollandsworth force-pushed the main branch 4 times, most recently from b6c62af to 6f26dac Compare August 27, 2025 21:36
@DomAyre
Copy link
Copy Markdown

DomAyre commented Sep 15, 2025

I've created this issue to encapsulate the work: Azure#9167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants