diff --git a/cmd/otk/osbuild-make-ostree-source/main.go b/cmd/otk/osbuild-make-ostree-source/main.go index 1c47648fd1..0cda5b9911 100644 --- a/cmd/otk/osbuild-make-ostree-source/main.go +++ b/cmd/otk/osbuild-make-ostree-source/main.go @@ -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 { diff --git a/cmd/otk/osbuild-resolve-ostree-commit/main.go b/cmd/otk/osbuild-resolve-ostree-commit/main.go index ee051ce9a3..b99b3346a9 100644 --- a/cmd/otk/osbuild-resolve-ostree-commit/main.go +++ b/cmd/otk/osbuild-resolve-ostree-commit/main.go @@ -7,6 +7,7 @@ import ( "os" "github.com/osbuild/images/internal/cmdutil" + "github.com/osbuild/images/internal/otkostree" "github.com/osbuild/images/pkg/ostree" ) @@ -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 @@ -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, diff --git a/internal/otkostree/types.go b/internal/otkostree/types.go new file mode 100644 index 0000000000..a3c66e91ce --- /dev/null +++ b/internal/otkostree/types.go @@ -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"` +}