tag v0.149.0 Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com> Changes with 0.149.0 ---------------- * Update dependencies 2025-05-25 (osbuild/images#1560) * Author: SchutzBot, Reviewers: Simon de Vlieger, Tomáš Hozza * Update osbuild dependency commit ID to latest (osbuild/images#1522) * Author: SchutzBot, Reviewers: Simon de Vlieger, Tomáš Hozza * Update snapshots to 20250515 (osbuild/images#1524) * Author: SchutzBot, Reviewers: Simon de Vlieger, Tomáš Hozza * `vagrant-libvirt` implementation (HMS-6116) (osbuild/images#1548) * Author: Simon de Vlieger, Reviewers: Achilleas Koutsou, Tomáš Hozza * fedora: tweaks after all imageTypes are YAML (osbuild/images#1518) * Author: Michael Vogt, Reviewers: Simon de Vlieger, Tomáš Hozza * gha: do not break gobump output (osbuild/images#1561) * Author: Lukáš Zapletal, Reviewers: Simon de Vlieger, Tomáš Hozza * repositories: AlmaLinux 10 (osbuild/images#1567) * Author: Simon de Vlieger, Reviewers: Achilleas Koutsou, Lukáš Zapletal, Neal Gompa (ニール・ゴンパ) * vagrant: image config for default vagrant user (HMS-6116) (osbuild/images#1565) * Author: Simon de Vlieger, Reviewers: Achilleas Koutsou, Michael Vogt — Somewhere on the Internet, 2025-05-27 --- tag v0.150.0 Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com> Changes with 0.150.0 ---------------- * Replace hardcoded kickstart %post scripts with new stage options and bootc switch with custom kickstart content (HMS-6051) (osbuild/images#1527) * Author: Achilleas Koutsou, Reviewers: Simon de Vlieger, Tomáš Hozza * test: install yamllint for tests (osbuild/images#1572) * Author: Achilleas Koutsou, Reviewers: Lukáš Zapletal, Simon de Vlieger, Tomáš Hozza — Somewhere on the Internet, 2025-06-02 --- tag v0.151.0 Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com> Changes with 0.151.0 ---------------- * Introduce new Azure CVM image type (HMS-5636) (osbuild/images#1318) * Author: Achilleas Koutsou, Reviewers: Nobody * Many: support using string with unit for byte-sized partitioning fields in YAML distro definitions (osbuild/images#1579) * Author: Tomáš Hozza, Reviewers: Achilleas Koutsou, Brian C. Lane * Update osbuild dependency commit ID to latest (osbuild/images#1587) * Author: SchutzBot, Reviewers: Achilleas Koutsou, Tomáš Hozza * Update snapshots to 20250601 (osbuild/images#1573) * Author: SchutzBot, Reviewers: Achilleas Koutsou, Lukáš Zapletal * bootc: Make installed rootfs configurable (osbuild/images#1555) * Author: Mbarak Bujra, Reviewers: Michael Vogt, Tomáš Hozza * distro: create new ImageConfig.DNFConfig (osbuild/images#1583) * Author: Michael Vogt, Reviewers: Simon de Vlieger, Tomáš Hozza * distro: make "fedora" a "generic" distro (osbuild/images#1563) * Author: Michael Vogt, Reviewers: Nobody * image: If using a separate build container, copy bootc customization to it (osbuild/images#1571) * Author: Alexander Larsson, Reviewers: Achilleas Koutsou, Tomáš Hozza * manifest/ostree: explicitly include shadow-utils (osbuild/images#1585) * Author: Simon de Vlieger, Reviewers: Achilleas Koutsou, Michael Vogt * osbuild/tar: explicit compression (HMS-8573, HMS-6116) (osbuild/images#1581) * Author: Simon de Vlieger, Reviewers: Achilleas Koutsou, Tomáš Hozza * tests: bump fedora versions to 41 (osbuild/images#1438) * Author: Lukáš Zapletal, Reviewers: Brian C. Lane, Michael Vogt — Somewhere on the Internet, 2025-06-09 ---
70 lines
1.9 KiB
Go
70 lines
1.9 KiB
Go
package distroidparser
|
|
|
|
import (
|
|
"github.com/osbuild/images/pkg/distro"
|
|
"github.com/osbuild/images/pkg/distro/rhel/rhel10"
|
|
"github.com/osbuild/images/pkg/distro/rhel/rhel7"
|
|
"github.com/osbuild/images/pkg/distro/rhel/rhel8"
|
|
"github.com/osbuild/images/pkg/distro/rhel/rhel9"
|
|
)
|
|
|
|
var DefaultParser = NewDefaultParser()
|
|
|
|
type ParserFunc func(idStr string) (*distro.ID, error)
|
|
|
|
// Parser is a list of distro-specific idStr parsers.
|
|
type Parser struct {
|
|
parsers []ParserFunc
|
|
}
|
|
|
|
func New(parsers ...ParserFunc) *Parser {
|
|
return &Parser{parsers: parsers}
|
|
}
|
|
|
|
// Parse returns the distro.ID that matches the given distro ID string. If no
|
|
// distro.ID matches the given distro ID string, it returns nil. If multiple
|
|
// distro.IDs match the given distro ID string, it panics.
|
|
// If no distro-specific parser matches the given distro ID string, it falls back
|
|
// to the default parser.
|
|
//
|
|
// The fact that the Parser returns a distro.ID does not mean that the distro is
|
|
// actually supported or implemented. This functionality is provided as an easy
|
|
// and consistent way to parse distro IDs, while allowing distro-specific parsers.
|
|
func (p *Parser) Parse(idStr string) (*distro.ID, error) {
|
|
var match *distro.ID
|
|
for _, f := range p.parsers {
|
|
if d, err := f(idStr); err == nil {
|
|
if match != nil {
|
|
panic("distro ID was matched by multiple parsers")
|
|
}
|
|
match = d
|
|
}
|
|
}
|
|
|
|
// Fall back to the default parser
|
|
if match == nil {
|
|
return distro.ParseID(idStr)
|
|
}
|
|
|
|
return match, nil
|
|
}
|
|
|
|
// Standardize returns the standardized distro ID string for the given distro ID
|
|
// string. If the given distro ID string is not valid, it returns an error.
|
|
func (p *Parser) Standardize(idStr string) (string, error) {
|
|
id, err := p.Parse(idStr)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return id.String(), nil
|
|
}
|
|
|
|
func NewDefaultParser() *Parser {
|
|
return New(
|
|
rhel7.ParseID,
|
|
rhel8.ParseID,
|
|
rhel9.ParseID,
|
|
rhel10.ParseID,
|
|
)
|
|
}
|