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 terminal client for connecting to hack.chat servers

A terminal client for connecting to hack.chat servers.

V9 2 Sep 21, 2022
A begginer reverse shell tool python.

A begginer reverse shell tool python. Este programa é para apenas estudo e conhecimento. Não use isso em outra pessoas. Não me responsabilizo por uso

Dio brando 2 Jan 05, 2022
The command line interface for Gradient - Gradient is an an end-to-end MLOps platform

Gradient CLI Get started: Create Account • Install CLI • Tutorials • Docs Resources: Website • Blog • Support • Contact Sales Gradient is an an end-to

Paperspace 58 Dec 06, 2022
DShell, a tool that combines with discord.py and Jishaku to present to you, shell channels.

Discord shell or dshell for short is a Python package that combines with discord.py and Jishaku to transform an ordinary Discord channel into one capable of running bash commands using a Discord bot.

11 Nov 15, 2022
Patool is a portable command line archive file manager

Patool Patool is an archive file manager. Various archive formats can be created, extracted, tested, listed, searched, repacked and compared with pato

318 Jan 04, 2023
Chat In Terminal - Chat-App in python

Chat In Terminal Hello all. 😉 Sockets and servers are vey important for connection and importantly chatting with others. 😂 😁 I have thought of maki

Shreejan Dolai 5 Nov 17, 2022
pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery.

pypinfo: View PyPI download statistics with ease. pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery. Installation pypin

Ofek Lev 351 Dec 26, 2022
Euporie is a text-based user interface for running and editing Jupyter notebooks

Euporie is a text-based user interface for running and editing Jupyter notebooks

781 Jan 01, 2023
Alacritty terminal used with Bash, Tmux, Vim, Mutt, Lynx, etc. and the many different additions added to each configuration file

Alacritty terminal used with Bash, Tmux, Vim, Mutt, Lynx, etc. and the many different additions added to each configuration file

Carter 19 Aug 24, 2022
A communist shell written in Python

kash A communist shell written in Python It doesn't support escapes, quotes, comment lines, |, &&, , or similar yet. If you need help, get it from

Çınar Yılmaz 1 Dec 10, 2021
A command line tool (and Python library) for archiving Twitter JSON

A command line tool (and Python library) for archiving Twitter JSON

Documenting the Now 1.3k Dec 28, 2022
Personal and work vim 8 configuration with submodules

vimfiles Windows Vim 8 configuration files based on the recommendations of Ruslan Osipov, Keep Your vimrc file clean and The musings of bluz71. :help

1 Aug 27, 2022
Pyreadline3 - Windows implementation of the GNU readline library

pyreadline3 The pyreadline3 package is based on the stale package pyreadline loc

32 Jan 06, 2023
Conditional Transformer Language Model for Controllable Generation

CTRL - A Conditional Transformer Language Model for Controllable Generation Authors: Nitish Shirish Keskar, Bryan McCann, Lav Varshney, Caiming Xiong,

Salesforce 1.7k Jan 05, 2023
A very simple OpenContest command line client written in Python

OpenContest Client A very simple OpenContest command line client written in Python. The only dependency is the requests library. Tested with Linux onl

Ladue Computer Science 1 May 25, 2022
👻 Ghoul is an easy to use information service, allowing you to get/add information on someone or something directly from your terminal.

👻 Ghoul is an easy to use information service, allowing you to get/add information on someone or something directly from your terminal. It c

Billy 11 Nov 10, 2021
Helping you manage your data science projects sanely.

PyDS CLI Helping you manage your data science projects sanely. Requirements Anaconda/Miniconda/Miniforge/Mambaforge (Mambaforge recommended!) git on y

Eric Ma 16 Apr 25, 2022
Generate your name in Ascii modular type art through the terminal

ASCII Name Generator Designed and developed by Eduardo Aire The ASCII Art Name Generator is a simple program that helps you to have a practical Shell/

Eduardo Aire 1 Nov 17, 2021
Terminal epub reader with inline images

nuber Inspired by epy, nuber is an Epub terminal reader with inline images written with Rust and Python using Überzug. Features Display images in term

Moshe Sherman 73 Oct 12, 2022
CLI tool to computes CO2 emissions of HPC computations following green-algorithms.org methodology

gqueue gqueue is a CLI (command line interface) tool that computes carbon footprint of HPC computations on clusters running slurm. It follows the meth

4 Dec 10, 2021