koji

package
v0.231.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKojiTransport

func CreateKojiTransport(relaxTimeout time.Duration, logger rh.LeveledLogger) http.RoundTripper

func CreateRetryableTransport

func CreateRetryableTransport(logger rh.LeveledLogger) *rh.RoundTripper

Types

type Build added in v0.40.2

type Build struct {
	BuildID   uint64 `json:"build_id"`
	TaskID    uint64 `json:"task_id"`
	Name      string `json:"name"`
	Version   string `json:"version"`
	Release   string `json:"release"`
	Source    string `json:"source"`
	StartTime int64  `json:"start_time"`
	EndTime   int64  `json:"end_time"`
	// NOTE: This is the struct that ends up shown in the buildinfo and webui in Koji.
	Extra BuildExtra `json:"extra"`
}

Build represents a Koji build and holds metadata about it.

type BuildExtra added in v0.40.2

type BuildExtra struct {
	TypeInfo TypeInfoBuild `json:"typeinfo"`
	// Manifest holds extra metadata about osbuild manifests attached to the build.
	// It is a map whose keys are the filenames of the manifests, and
	// the values are the extra metadata for the manifest.
	Manifest map[string]*ManifestExtraInfo `json:"osbuild_manifest,omitempty"`
}

BuildExtra holds extra metadata associated with the build. It is a free-form map, but must contain at least the 'typeinfo' key.

type BuildOutput added in v0.40.2

type BuildOutput struct {
	BuildRootID  uint64            `json:"buildroot_id"`
	Filename     string            `json:"filename"`
	FileSize     uint64            `json:"filesize"`
	Arch         string            `json:"arch"` // can be 'noarch' or a specific arch
	ChecksumType ChecksumType      `json:"checksum_type"`
	Checksum     string            `json:"checksum"`
	Type         BuildOutputType   `json:"type"`
	RPMs         []RPM             `json:"components,omitempty"`
	Extra        *BuildOutputExtra `json:"extra,omitempty"`
}

BuildOutput represents an output from the OSBuild content generator. The output can be a file of various types, which is imported to Koji. Examples of types are "image", "log" or other.

type BuildOutputExtra added in v0.40.2

type BuildOutputExtra struct {
	// ImageOutput holds extra metadata about a single "image" output.
	// "image" in this context is the "build type" in the Koji terminology,
	// not necessarily an actual image. It can and must be used also for
	// other supplementary files related to the image, such as osbuild manifest.
	// The only exception are logs, which do not need to specify any "typeinfo".
	ImageOutput ImageOutputTypeExtraInfo `json:"image"`
}

BuildOutputExtra holds extra metadata associated with the build output.

type BuildOutputType added in v0.40.2

type BuildOutputType string

BuildOutputType represents the type of a BuildOutput.

const (
	BuildOutputTypeImage    BuildOutputType = "image"
	BuildOutputTypeLog      BuildOutputType = "log"
	BuildOutputTypeManifest BuildOutputType = "osbuild-manifest"
	BuildOutputTypeSbomDoc  BuildOutputType = "sbom-doc"
)

type BuildRoot

type BuildRoot struct {
	ID               uint64           `json:"id"`
	Host             Host             `json:"host"`
	ContentGenerator ContentGenerator `json:"content_generator"`
	Container        Container        `json:"container"`
	Tools            []Tool           `json:"tools"`
	RPMs             []RPM            `json:"components"`
}

BuildRoot represents a buildroot used for the build.

type CGImportResult

type CGImportResult struct {
	BuildID int `xmlrpc:"build_id"`
}

type CGInitBuildResult

type CGInitBuildResult struct {
	BuildID int    `xmlrpc:"build_id"`
	Token   string `xmlrpc:"token"`
}

type ChecksumType added in v0.40.2

type ChecksumType string

ChecksumType represents the type of a checksum used for a BuildOutput.

const (
	ChecksumTypeMD5     ChecksumType = "md5"
	ChecksumTypeAdler32 ChecksumType = "adler32"
	ChecksumTypeSHA256  ChecksumType = "sha256"
)

type Container

type Container struct {
	// Type of the container that was used, e.g. 'none', 'chroot', 'kvm', 'docker', etc.
	Type string `json:"type"`
	Arch string `json:"arch"`
}

Container holds information about the container in which the build was run.

type ContentGenerator

type ContentGenerator struct {
	Name    string `json:"name"` // Must be 'osbuild'.
	Version string `json:"version"`
}

ContentGenerator holds information about the content generator which run the build.

type GSSAPICredentials

type GSSAPICredentials struct {
	Principal string
	KeyTab    string
}

type Host

type Host struct {
	Os   string `json:"os"`
	Arch string `json:"arch"`
}

Host holds information about the host where the build was run.

type ImageExtraInfo

type ImageExtraInfo struct {
	Arch string `json:"arch"`
	// Boot mode of the image
	BootMode string `json:"boot_mode,omitempty"`
	// Configuration used to produce this image using osbuild
	OSBuildArtifact *OsbuildArtifact `json:"osbuild_artifact,omitempty"`
	// Version of the osbuild binary used by the worker to build the image
	OSBuildVersion string `json:"osbuild_version,omitempty"`
	// Results from any upload targets associated with the image
	// The structure of the data does not need to be known by the consumer,
	// it is just a list of JSON objects.
	UploadTargetResults []interface{} `json:"upload_target_results,omitempty"`
}

ImageExtraInfo holds extra metadata about the image. This structure is shared for the Extra metadata of the output and the build.

type ImageOutputTypeExtraInfo added in v0.40.2

type ImageOutputTypeExtraInfo interface {
	// contains filtered or unexported methods
}

type Koji

type Koji struct {
	// contains filtered or unexported fields
}

func NewFromGSSAPI

func NewFromGSSAPI(
	server string,
	credentials *GSSAPICredentials,
	transport http.RoundTripper,
	logger rh.LeveledLogger) (*Koji, error)

NewFromGSSAPI creates a new Koji session authenticated using GSSAPI. Principal and keytab used for the session is passed using credentials parameter.

func (*Koji) CGCancelBuild

func (k *Koji) CGCancelBuild(buildID int, token string) error

CGCancelBuild marks an in-progress build as cancelled, and

func (*Koji) CGFailBuild

func (k *Koji) CGFailBuild(buildID int, token string) error

CGFailBuild marks an in-progress build as failed

func (*Koji) CGImport

func (k *Koji) CGImport(build Build, buildRoots []BuildRoot, outputs []BuildOutput, directory, token string) (*CGImportResult, error)

CGImport imports previously uploaded content, by specifying its metadata, and the temporary directory where it is located.

func (*Koji) CGInitBuild

func (k *Koji) CGInitBuild(name, version, release string) (*CGInitBuildResult, error)

CGInitBuild reserves a build ID and initializes a build

func (*Koji) GetAPIVersion

func (k *Koji) GetAPIVersion() (int, error)

GetAPIVersion gets the version of the API of the remote Koji instance

func (*Koji) Logout

func (k *Koji) Logout() error

Logout ends the session

func (*Koji) Upload

func (k *Koji) Upload(file io.Reader, filepath, filename string) (string, uint64, error)

Upload uploads file to the temporary filepath on the kojiserver under the name filename The md5sum and size of the file is returned on success.

type ManifestExtraInfo added in v0.40.2

type ManifestExtraInfo struct {
	Arch string        `json:"arch"`
	Info *ManifestInfo `json:"info,omitempty"`
}

ManifestExtraInfo holds extra metadata about the osbuild manifest.

type ManifestInfo added in v0.40.2

type ManifestInfo struct {
	OSBuildComposerVersion string `json:"osbuild_composer_version"`
	// List of relevant modules used by osbuild-composer which
	// could affect the manifest content.
	OSBuildComposerDeps []*OSBuildComposerDepModule `json:"osbuild_composer_deps,omitempty"`
}

ManifestInfo holds information about the environment in which the manifest was produced and which could affect its content.

type Metadata

type Metadata struct {
	MetadataVersion int           `json:"metadata_version"` // must be '0'
	Build           Build         `json:"build"`
	BuildRoots      []BuildRoot   `json:"buildroots"`
	Outputs         []BuildOutput `json:"output"`
}

Metadata holds Koji Content Generator metadata. This is passed to the CGImport call. For more information, see https://docs.pagure.org/koji/content_generator_metadata/

type OSBuildComposerDepModule added in v0.40.2

type OSBuildComposerDepModule struct {
	Path    string                    `json:"path"`
	Version string                    `json:"version"`
	Replace *OSBuildComposerDepModule `json:"replace,omitempty"`
}

type OsbuildArtifact added in v0.40.2

type OsbuildArtifact struct {
	// Filename of the image as produced by osbuild
	ExportFilename string `json:"export_filename"`
	// Name of the osbuild pipeline, which was exported to produce this image
	ExportName string `json:"export_name"`
}

OsbuildArtifact represents a configuration to produce the image using osbuild.

type RPM added in v0.40.2

type RPM struct {
	Type      string  `json:"type"` // must be 'rpm'
	Name      string  `json:"name"`
	Version   string  `json:"version"`
	Release   string  `json:"release"`
	Epoch     *string `json:"epoch,omitempty"`
	Arch      string  `json:"arch"`
	Sigmd5    string  `json:"sigmd5"`
	Signature *string `json:"signature"`
}

RPM represents an RPM package in the Koji metadata format. It contains the necessary fields to uniquely identify an RPM package, when desdribing the build metadata in Koji.

func DeduplicateRPMs added in v0.40.2

func DeduplicateRPMs(rpms []RPM) []RPM

Deduplicate a list of RPMs based on NEVRA string

func OSBuildMetadataToRPMs added in v0.40.2

func OSBuildMetadataToRPMs(stagesMetadata map[string]osbuild.StageMetadata) []RPM

func (RPM) String added in v0.40.2

func (r RPM) String() string

NEVRA string for the package

type SbomDocExtraInfo added in v0.40.2

type SbomDocExtraInfo struct {
	Arch string `json:"arch"`
}

type Tool

type Tool struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Tool holds information about a tool used to run build.

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

func (*Transport) RoundTrip

func (rt *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface, using the default transport. When a session has been established, also pass along the session credentials. This may not be how the RoundTripper interface is meant to be used, but the underlying XML-RPC helpers don't allow us to adjust the URL per-call (these arguments should really be in the body).

type TypeInfoBuild added in v0.40.2

type TypeInfoBuild struct {
	// Image holds extra metadata about all images built by the build.
	// It is a map whose keys are the filenames of the images, and
	// the values are the extra metadata for the image.
	// There can't be more than one image with the same filename.
	Image map[string]ImageExtraInfo `json:"image"`
}

TypeInfoBuild is a map whose entries are the names of the build types used for the build, and the values are free-form maps containing type-specific information for the build.