A Python command-line utility for validating that the outputs of a given Declarative Form Azure Portal UI JSON template map to the input parameters of a given ARM Deployment Template JSON template

Overview

validate-declarative-form

tests

A Python command-line utility for validating that the outputs of a given Declarative Form Azure Portal UI JSON template map to the input parameters of a given ARM Deployment Template JSON template.

Declarative Form Output => ARM Template Parameters

What is a Declarative Form?

Developers describe custom Azure Portal user interfaces for ARM deployment templates as JSON.

For many years, Create UI Definition (also known as createUiDefinition.json and CUID) was both the JSON schema and named mechanism for creating custom Azure Portal user interfaces.

Declarative Form is Create UI Definition's successor.

Running the Validator locally

Run the --help command to see the required arguments:

python validate_declarative_form.py -h

And you should get back some help:

usage: validate_declarative_form.py [-h] form_template_path deployment_template_path 

Validate a Declarative Form UI template against an ARM Deployment Template.

And can execute it like:

python validate_declarative_form.py sample-templates/form.json sample-templates/template.json

Running the Validator in an automated workflow

I could use the validator on a *nix agent with python3 by downloading the validator script from this repository, then passing my form template and deployment template as arguments to that script:

curl -s \
  -o validate_declarative_form.py \
  -L https://raw.githubusercontent.com/glennmusa/validate-declarative-form/main/validate_declarative_form.py

python validate_declarative_form.py path/to/a/form.json path/to/a/template.json

Success

If successful, you'll find this in the stdout:

Success!

Failure

Any failure will print the errors to stderr and exit code 1.

Some example errors:

Required parameter 'fizz' not found in Declarative Form output
Form output 'fizz2' not found in deployment template parameters
File could not be found: samples/form2.json

Debugging source or running tests

This repository defines a dev container that has everything you need to get up and running quickly with all the tools and configuration you need already installed configured.

It's really simple to get started now in your browser on a GitHub Codespace:

  • on this repository, click the green <> Code button then New Codespace

If you prefer local development, you can use this same dev container in Visual Studio Code:

Debugging the Validator

Debugging in the dev container

There's launch.json editor settings specified that pass command line arguments to any active Python script:

  • Open validate_declarative_form.py in the dev container
  • set a breakpoint
  • press F5 to start debugging

See https://code.visualstudio.com/docs/python/debugging/ for more information on how to debug Python from the Codespace.

Testing the Validator

Testing in the dev container

There's settings.json editor settings specified that inform where Python unit tests can be discovered:

  • Select "Testing" from the Application menu (or open the Command Pallete (F1) and type View: Show Testing)
  • Expand the validation directory and it's children to see all the unit tests
  • You can run them all selecting the "Run Tests" button (or open the Command Pallete (F1) and type Test: Run All Tests)
  • You can debug individual tests by setting a breakpoint in validate_declarative_form.py or validate_declarative_form_test.py and selecting Debug Test from the tests pane

Testing from the terminal

You can run the unit tests by calling the unittest module from Python like:

python -m unittest validate_declarative_form_test.py -v

And you should get output similar to:

test_form_specifies_all_required_parameters (validate_declarative_form_test.ValidateDeclarativeFormTest)
Test that all required parameters not output by the form return errors ... ok
test_form_specifies_valid_parameters (validate_declarative_form_test.ValidateDeclarativeFormTest)
Test that all form outputs exist as deployment template parameters ... ok
test_get_required_parameters (validate_declarative_form_test.ValidateDeclarativeFormTest)
Test that all deployment template parameters that do not have default values are returned ... ok
test_validate_form_captures_extraneous_form_output (validate_declarative_form_test.ValidateDeclarativeFormTest)
Test that if there are extra form outputs that are not template parameters ... ok
test_validate_form_captures_missing_required_parameter (validate_declarative_form_test.ValidateDeclarativeFormTest)
Test that if there is a missing required template parameter ... ok
test_validate_form_catches_invalid_template_json (validate_declarative_form_test.ValidateDeclarativeFormTest)
Test that if invalid JSON is passed that load fails and ... ok
test_validate_form_without_errors (validate_declarative_form_test.ValidateDeclarativeFormTest)
Test that if there are no errors in the validation ... ok

----------------------------------------------------------------------
Ran 7 tests in 0.001s

OK
Owner
Glenn Musa
Glenn Musa
A mini command line tool to spellcheck text files using tadqeek.alsharekh.org

tadqeek_sakhr A mini command line tool to spellcheck text files using tadqeek.alsharekh.org Usage usage: python tadqeek_sakhr.py [-h] -i INPUT [-o OUT

Youssif Shaaban Alsager 5 Dec 11, 2022
liquidctl – liquid cooler control Cross-platform tool and drivers for liquid coolers and other devices

Cross-platform CLI and Python drivers for AIO liquid coolers and other devices

1.7k Jan 08, 2023
A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.

mycli A command line client for MySQL that can do auto-completion and syntax highlighting. HomePage: http://mycli.net Documentation: http://mycli.net/

dbcli 10.7k Jan 07, 2023
A simple command line tool written in python to manage a to-do list

A simple command line tool written in python to manage a to-do list Dependencies: python Commands: todolist (-a | --add) [(-p | --priority)] [(-l | --

edwloef 0 Nov 02, 2021
🦎 A NeoVim plugin for highlighting visual selections like in a normal document editor!

🦎 HighStr.nvim A NeoVim plugin for highlighting visual selections like in a normal document editor! Demo TL;DR HighStr.nvim is a NeoVim plugin writte

Pocco81 222 Jan 03, 2023
A curated list of awesome things related to Textual

Awesome Textual | A curated list of awesome things related to Textual. Textual is a TUI (Text User Interface) framework for Python inspired by modern

Marcelo Trylesinski 5 May 08, 2022
CryptoCo-py is a Python CLI application that uses CoinGecko API to allow the user to query cryptocurrency information by typing simple commands.

CryptoCo-py is a Python CLI application that uses CoinGecko API to allow the user to query cryptocurrency information by typing simple com

1 Jan 10, 2022
CLI tool for one-line installation of C++/CMake projects.

cmakip When working on virtual environments, Python projects can be installed with a single command invocation, for example pip install --no-deps . .

Artificial and Mechanical Intelligence 4 Feb 15, 2022
Declarative CLIs with argparse and dataclasses

argparse_dataclass Declarative CLIs with argparse and dataclasses. Features Features marked with a ✓ are currently implemented; features marked with a

Mike DePalatis 29 Dec 06, 2022
GetRepo-py is a command line client that queries GitHub API and searches repositories by given arguments

GetRepo-py is a command line client that queries GitHub API and searches repositories by given arguments

Davidcin 3 Feb 14, 2022
Analyzing the most strategic words to guess on Wordle, based on letter frequency distributions

wordle-analysis Evaluating different heuristics to determine the most effective solving strategy and building an AI-powered assistant tool to help you

Sejal Dua 9 Feb 27, 2022
Tools crack instagram + fb ayok dicoba keburu premium 😁

FITUR INSTALLASI [1] pkg update && pkg upgrade [2] pkg install git [3] pkg install python [4] pkg install python2 [5] pkg install nano [6]

Jeeck 1 Dec 11, 2021
Password manager for the CLI simps.

CLI Password Manager Password manager for the CLI simps. Free software: MIT license

1 Dec 30, 2021
Python script to tabulate data formats like json, csv, html, etc

pyT PyT is a a command line tool and as well a library for visualising various data formats like: JSON HTML Table CSV XML, etc. Features Print table o

Mobolaji Abdulsalam 1 Dec 30, 2021
Python CLI script to solve wordles.

Wordle Solver Python CLI script to solve wordles. You need at least python 3.8 installed to run this. No dependencies. Sample Usage Let's say the word

Rachel Brindle 1 Jan 16, 2022
A command line interface to interact with the Hypixel api allowing the user to get stats, leaderboards, etc

HyConsole is a way to get data on players and leaderboards from the Hypixel Minecraft server from the command line. Keep in mind I have no a

1 Feb 14, 2022
A Command Line Error Parser Built using Python.

"Stalk Overflow with debuggy" Error Parser Everything is done in Python so it's extremely easy to install and use. Supports Python 3. Debuggy is used

Derhnyel 22 Nov 10, 2022
Tmux Based Dropdown Dashboard For Python

sextans It's a private configuration and an ongoing experiment while I use Archlinux. A simple drop down dashboard based on tmux. It includes followin

秋葉 4 Dec 22, 2021
git-partial-submodule is a command-line script for setting up and working with submodules while enabling them to use git's partial clone and sparse checkout features.

Partial Submodules for Git git-partial-submodule is a command-line script for setting up and working with submodules while enabling them to use git's

Nathan Reed 15 Sep 22, 2022
commandpack - A package of modules for working with commands, command packages, files with command packages.

commandpack Help the project financially: Donate: https://smartlegion.github.io/donate/ Yandex Money: https://yoomoney.ru/to/4100115206129186 PayPal:

4 Sep 04, 2021