Remove all the internal package that are now in the github.com/osbuild/images package and vendor it. A new function in internal/blueprint/ converts from an osbuild-composer blueprint to an images blueprint. This is necessary for keeping the blueprint implementation in both packages. In the future, the images package will change the blueprint (and most likely rename it) and it will only be part of the osbuild-composer internals and interface. The Convert() function will be responsible for converting the blueprint into the new configuration object.
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package rpmrepo
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
|
|
"github.com/osbuild/images/pkg/rpmmd"
|
|
"github.com/osbuild/osbuild-composer/internal/common"
|
|
)
|
|
|
|
type testRepoServer struct {
|
|
Server *httptest.Server
|
|
RepoConfig rpmmd.RepoConfig
|
|
}
|
|
|
|
func NewTestServer() *testRepoServer {
|
|
server := httptest.NewServer(http.FileServer(http.Dir("../../test/data/testrepo/")))
|
|
testrepo := rpmmd.RepoConfig{
|
|
Name: "cs9-baseos",
|
|
BaseURLs: []string{server.URL},
|
|
CheckGPG: common.ToPtr(false),
|
|
IgnoreSSL: common.ToPtr(true),
|
|
RHSM: false,
|
|
}
|
|
return &testRepoServer{Server: server, RepoConfig: testrepo}
|
|
}
|
|
|
|
func (trs *testRepoServer) Close() {
|
|
trs.Server.Close()
|
|
}
|
|
|
|
// WriteConfig writes the repository config to the file defined by the given
|
|
// path. Assumes the location already exists.
|
|
func (trs *testRepoServer) WriteConfig(path string) {
|
|
fp, err := os.Create(path)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
data, err := json.Marshal(trs.RepoConfig)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if _, err := fp.Write(data); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|