Skip to content

Commit

Permalink
internal/otkostree: move resolved ostree struct to new package
Browse files Browse the repository at this point in the history
Move the struct that defines the output of the otk-resolve-ostree-commit
command to an internal package and reuse it as the input for the
otk-make-ostree-source command.
  • Loading branch information
achilleas-k authored and mvo5 committed Oct 11, 2024
1 parent 66f21b1 commit a522740
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 35 deletions.
20 changes: 2 additions & 18 deletions cmd/otk/osbuild-make-ostree-source/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,17 @@ import (
"io"
"os"

"github.com/osbuild/images/internal/otkostree"
"github.com/osbuild/images/pkg/osbuild"
"github.com/osbuild/images/pkg/ostree"
)

// TODO: move structs to common package with resolver external

type Input struct {
Tree InputTree `json:"tree"`
}

type InputTree struct {
Const InputConst `json:"const"`
}

type InputConst struct {
// Ref of the commit (can be empty).
Ref string `json:"ref,omitempty"`

// URL of the repo where the commit can be fetched.
URL string `json:"url"`

// Secrets type to use when pulling the ostree commit content
// (e.g. org.osbuild.rhsm.consumer).
Secrets string `json:"secrets,omitempty"`

// Checksum of the commit.
Checksum string `json:"checksum"`
Const otkostree.ResolvedConst `json:"const"`
}

type Output struct {
Expand Down
20 changes: 3 additions & 17 deletions cmd/otk/osbuild-resolve-ostree-commit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"

"github.com/osbuild/images/internal/cmdutil"
"github.com/osbuild/images/internal/otkostree"
"github.com/osbuild/images/pkg/ostree"
)

Expand All @@ -31,22 +32,7 @@ type Input struct {
// Output contains everything needed to write a manifest that requires pulling
// an ostree commit.
type Output struct {
Const OutputConst `json:"const"`
}

type OutputConst struct {
// Ref of the commit (can be empty).
Ref string `json:"ref,omitempty"`

// URL of the repo where the commit can be fetched.
URL string `json:"url"`

// Secrets type to use when pulling the ostree commit content
// (e.g. org.osbuild.rhsm.consumer).
Secrets string `json:"secrets,omitempty"`

// Checksum of the commit.
Checksum string `json:"checksum"`
Const otkostree.ResolvedConst `json:"const"`
}

// for mocking in testing
Expand Down Expand Up @@ -78,7 +64,7 @@ func run(r io.Reader, w io.Writer) error {

output := map[string]Output{
"tree": {
Const: OutputConst{
Const: otkostree.ResolvedConst{
Ref: commitSpec.Ref,
URL: commitSpec.URL,
Secrets: commitSpec.Secrets,
Expand Down
16 changes: 16 additions & 0 deletions internal/otkostree/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package otkostree

type ResolvedConst struct {
// Ref of the commit (can be empty).
Ref string `json:"ref,omitempty"`

// URL of the repo where the commit can be fetched.
URL string `json:"url"`

// Secrets type to use when pulling the ostree commit content
// (e.g. org.osbuild.rhsm.consumer).
Secrets string `json:"secrets,omitempty"`

// Checksum of the commit.
Checksum string `json:"checksum"`
}

0 comments on commit a522740

Please sign in to comment.