Skip to content

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

  1. 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.exe for 64-bit Windows systems.
  • Linux
    • Download opa_linux_amd64_static for 64-bit Linux systems. This is the recommended option because it is statically linked and has no external dependencies.
    • Alternatively, download opa_linux_amd64 if you prefer the dynamically linked version.
  • macOS
    • Download opa_darwin_amd64 for Intel-based Mac systems.
    • Download opa_darwin_arm64_static for Apple Silicon systems such as M1, M2, and M3.

Alternatively you can also download from here Download OPA and select operating system.

  1. Prepare Bundle Files

    • Create bundle.rego with your application rules.
    • Create data.json for language support, if required.
    • Place both the files in the same directory.
  2. Generate Bundle

     ```bash
     cd <directory-with-files>
     opa build -b .
     ```
    
  3. 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.rego and a .manifest file.
    • Verify that data.json is included only if required.

NOTICE

Run the opa build command from the directory that contains bundle.rego. Otherwise, bundle validation can fail.

Important Requirements

  1. Bundle Structure:

    • Files must be in the root directory of the bundle
    • Do not create nested folder structures
    • Run opa build command from the directory containing your files
  2. 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, and opa 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