Skip to content

Migrate from JSON Build Specs to YAML Image Templates#26

Merged
arodage merged 3 commits intomainfrom
schema-for-image-template
Jun 3, 2025
Merged

Migrate from JSON Build Specs to YAML Image Templates#26
arodage merged 3 commits intomainfrom
schema-for-image-template

Conversation

@arodage
Copy link
Copy Markdown
Contributor

@arodage arodage commented Jun 1, 2025

Merge Checklist

All boxes should be checked before merging the PR

  • [*] The changes in the PR have been built and tested
  • [] Ready to merge

Description

This PR migrates the Image Composer Tool from JSON build specifications to YAML image templates as the primary input format, simplifying the architecture and improving usability.

Key Changes

1. New YAML Template Format

  • Introduced ImageTemplate struct with image, target, and systemConfigs sections
  • Added helper methods for clean data access (GetProviderName(), GetPackages(), etc.)
  • Focused schema on core functionality (packages, kernel, target configuration)

2. Simplified Architecture

  • Eliminated BuildSpec and used templates directly throughout pipeline
  • Removed JSON parsing and validation complexity

3. Provider Updates

  • Modified all providers (AzureLinux3, eLxr12, EMT3.0) to accept *ImageTemplate
  • Updated Init() method signatures across provider interface
  • Maintained existing package resolution and validation logic

4. Command Updates

  • Updated build and validate commands to work with YAML templates
  • Changed file completion to suggest only YAML files
  • Enhanced validation output with template structure details

5. Documentation & Tests

  • Updated CLI specification and README with YAML examples
  • Comprehensive test coverage for template validation and processing
  • Removed cache disabling options (caching always enabled)

Usage

New command format:

./image-composer build image-templates/azl3-x86_64-edge-raw.yml
./image-composer validate image-templates/azl3-x86_64-edge-raw.yml


<!-- Fixes # (issue) -->

#### Any Newly Introduced Dependencies
<!-- Please describe any newly introduced 3rd party dependencies in this change.
List their name, license information and how they are used in the project. -->

#### How Has This Been Tested? <!-- REQUIRED -->
<!-- Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details for your
test configuration. -->

@arodage arodage changed the title created schema for new image template Migrate from JSON Build Specs to YAML Image Templates Jun 2, 2025
Comment thread internal/config/config_test.go
Comment thread internal/config/config.go
}

// GetProviderName returns the provider name for the given template
func (t *ImageTemplate) GetProviderName() string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why hard-coding these in the code rather than putting the valid combinations in the json schema itself and validate against the schema?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is not for validation. Used in logging to get the provider name and, more importantly, for initializing the correct registered provider in executeBuild(). I still agree that this should not be hardcoded.
Would it be better to keep this mapping in a separate file?

Comment thread internal/config/config.go Outdated
Comment thread schema/os-image-template.schema.json
Copy link
Copy Markdown
Contributor

@magerstam magerstam left a comment

Choose a reason for hiding this comment

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

few minor comments to address

@arodage arodage merged commit 80e6f33 into main Jun 3, 2025
1 check passed
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.

2 participants