How to create a Rego bundle¶
Create the Installation Guidance bundle by using OPA (Open Policy Agent) and the required file structure.
What an Installation Guidance bundle contains¶
An Installation Guidance bundle is a .tar.gz file that contains Rego-based policy rules. These rules can define the following conditions:
- Application dependencies
- Version requirements
- Update conditions
- Warning and blocking behavior during installation
These rules help control how IEM handles the installation process.
Mandatory file¶
bundle.rego: Contains the application rules and logic. This file is required. If required details are missing, bundle validation fails.
For examples, see Sample Rego files.
Optional file¶
data.json: Contains language support and localization data. This file is optional.
Bundle Creation Steps¶
- Download the OPA tool Download OPA v1 and place it in your working directory. It is recommended to use the latest version. For release files, see OPA Releases.
Use the appropriate OPA file for your operating system:
- Windows
- Download
opa_windows_amd64.exefor 64-bit Windows systems.
- Download
- Linux
- Download
opa_linux_amd64_staticfor 64-bit Linux systems. This is the recommended option because it is statically linked and has no external dependencies. - Alternatively, download
opa_linux_amd64if you prefer the dynamically linked version.
- Download
- macOS
- Download
opa_darwin_amd64for Intel-based Mac systems. - Download
opa_darwin_arm64_staticfor Apple Silicon systems such as M1, M2, and M3.
- Download
Alternatively you can also download from here Download OPA and select operating system.
-
Prepare Bundle Files
- Create
bundle.regowith your application rules. - Create
data.jsonfor language support, if required. - Place both the files in the same directory.
- Create
-
Generate Bundle
```bash cd <directory-with-files> opa build -b . ``` -
Verify Bundle Contents
- Verify that the generated file is
bundle.tar.gz. - Verify that the bundle size is less than 2 MB.
- Verify that the bundle contains
bundle.regoand a.manifestfile. - Verify that
data.jsonis included only if required.
- Verify that the generated file is
NOTICE
Run the opa build command from the directory that contains bundle.rego. Otherwise, bundle validation can fail.
Important Requirements¶
-
Bundle Structure:
- Files must be in the root directory of the bundle
- Do not create nested folder structures
- Run
opa buildcommand from the directory containing your files
-
File requirements - the
bundle.regomust include:- Package information
- UI display messages
- Required validation rules
- Application logic implementation
Testing your Rego Rules¶
To assist you in crafting and testing your policies, the following options are available:
- Rego Playground: An interactive online tool that enables you to write, test, and share rules and input directly in your browser. This is an excellent choice for experimentation and debugging. For more information, see Open Policy Agent Playground.
- OPA CLI: Designed for local development and automation, the OPA Command-Line Interface allows you to evaluate policies against local input files.
- For OPA CLI commands such as
opa check,opa build,opa eval,opa test, andopa inspect, see the OPA CLI Reference.
NOTICE
As of now, testing rules within Industrial Edge is not supported. Stay tuned for future updates.
For more information, see the Open Policy Agent documentation.
Validation¶
- Bundle format validation will be performed
- Missing mandatory elements will cause validation failure
- Incorrect directory structure will result in processing errors