debian-forge-composer/internal/osbuild2/input.go
Tomas Hozza 8271910051 osbuild2: refactor files inputs
osbuild stage inputs were originally implemented in composer as
stage-specific inputs, while in reality, they are defined as individual
inputs, usually accepted by multiple stages. Therefore a single stage
input can be passed to any stage, as long as the stage accepts it.

Files inputs type was previously defined, but not used by any stage.
Creation of proper inputs type structures is currently handled in
`internal/distro/rhel85/stage_inputs.go` instead.

Refactor files inputs type to be usable directly as an input type
structure for stages, which accept it. For now, implement only the
`org.osbuild.pipeline` origin and related input reference.

Add unit tests for the `FilesInputs`.

Define input origin names as string constants, so that they can be used
by inputs implementations, instead of using string literals.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-08-02 19:05:09 +02:00

32 lines
653 B
Go

package osbuild2
// Collection of Inputs for a Stage
type Inputs interface {
isStageInputs()
}
// Single Input for a Stage
type Input interface {
isInput()
}
// TODO: define these using type aliases
const (
InputOriginSource string = "org.osbuild.source"
InputOriginPipeline string = "org.osbuild.pipeline"
)
// Fields shared between all Input types (should be embedded in each instance)
type inputCommon struct {
Type string `json:"type"`
// Origin should be either 'org.osbuild.source' or 'org.osbuild.pipeline'
Origin string `json:"origin"`
}
type StageInput interface {
isStageInput()
}
type References interface {
isReferences()
}