cloudapi: Pass the RepoRegistry to the cloudapi Server
This commit is contained in:
parent
b8967d53bc
commit
01ba674cac
4 changed files with 16 additions and 6 deletions
|
|
@ -149,7 +149,7 @@ func (c *Composer) InitAPI(cert, key string, enableTLS bool, enableMTLS bool, en
|
||||||
TenantProviderFields: c.config.Koji.JWTTenantProviderFields,
|
TenantProviderFields: c.config.Koji.JWTTenantProviderFields,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.api = cloudapi.NewServer(c.workers, c.distros, config)
|
c.api = cloudapi.NewServer(c.workers, c.distros, c.repos, config)
|
||||||
|
|
||||||
if !enableTLS {
|
if !enableTLS {
|
||||||
c.apiListener = l
|
c.apiListener = l
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,19 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/osbuild/images/pkg/distrofactory"
|
"github.com/osbuild/images/pkg/distrofactory"
|
||||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
"github.com/osbuild/images/pkg/reporegistry"
|
||||||
|
|
||||||
v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2"
|
v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2"
|
||||||
|
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
v2 *v2.Server
|
v2 *v2.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(workers *worker.Server, distros *distrofactory.Factory, config v2.ServerConfig) *Server {
|
func NewServer(workers *worker.Server, distros *distrofactory.Factory, repos *reporegistry.RepoRegistry, config v2.ServerConfig) *Server {
|
||||||
server := &Server{
|
server := &Server{
|
||||||
v2: v2.NewServer(workers, distros, config),
|
v2: v2.NewServer(workers, distros, repos, config),
|
||||||
}
|
}
|
||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"github.com/osbuild/images/pkg/distrofactory"
|
"github.com/osbuild/images/pkg/distrofactory"
|
||||||
"github.com/osbuild/images/pkg/manifest"
|
"github.com/osbuild/images/pkg/manifest"
|
||||||
"github.com/osbuild/images/pkg/ostree"
|
"github.com/osbuild/images/pkg/ostree"
|
||||||
|
"github.com/osbuild/images/pkg/reporegistry"
|
||||||
"github.com/osbuild/osbuild-composer/internal/auth"
|
"github.com/osbuild/osbuild-composer/internal/auth"
|
||||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||||
"github.com/osbuild/osbuild-composer/internal/common"
|
"github.com/osbuild/osbuild-composer/internal/common"
|
||||||
|
|
@ -38,6 +39,7 @@ import (
|
||||||
type Server struct {
|
type Server struct {
|
||||||
workers *worker.Server
|
workers *worker.Server
|
||||||
distros *distrofactory.Factory
|
distros *distrofactory.Factory
|
||||||
|
repos *reporegistry.RepoRegistry
|
||||||
config ServerConfig
|
config ServerConfig
|
||||||
router routers.Router
|
router routers.Router
|
||||||
|
|
||||||
|
|
@ -51,7 +53,7 @@ type ServerConfig struct {
|
||||||
JWTEnabled bool
|
JWTEnabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(workers *worker.Server, distros *distrofactory.Factory, config ServerConfig) *Server {
|
func NewServer(workers *worker.Server, distros *distrofactory.Factory, repos *reporegistry.RepoRegistry, config ServerConfig) *Server {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
spec, err := GetSwagger()
|
spec, err := GetSwagger()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -71,6 +73,7 @@ func NewServer(workers *worker.Server, distros *distrofactory.Factory, config Se
|
||||||
server := &Server{
|
server := &Server{
|
||||||
workers: workers,
|
workers: workers,
|
||||||
distros: distros,
|
distros: distros,
|
||||||
|
repos: repos,
|
||||||
config: config,
|
config: config,
|
||||||
router: router,
|
router: router,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/osbuild/images/pkg/distrofactory"
|
"github.com/osbuild/images/pkg/distrofactory"
|
||||||
"github.com/osbuild/images/pkg/osbuild"
|
"github.com/osbuild/images/pkg/osbuild"
|
||||||
"github.com/osbuild/images/pkg/ostree/mock_ostree_repo"
|
"github.com/osbuild/images/pkg/ostree/mock_ostree_repo"
|
||||||
|
"github.com/osbuild/images/pkg/reporegistry"
|
||||||
"github.com/osbuild/images/pkg/rpmmd"
|
"github.com/osbuild/images/pkg/rpmmd"
|
||||||
v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2"
|
v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2"
|
||||||
"github.com/osbuild/osbuild-composer/internal/jobqueue/fsjobqueue"
|
"github.com/osbuild/osbuild-composer/internal/jobqueue/fsjobqueue"
|
||||||
|
|
@ -34,11 +35,16 @@ func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT
|
||||||
distros := distrofactory.NewTestDefault()
|
distros := distrofactory.NewTestDefault()
|
||||||
require.NotNil(t, distros)
|
require.NotNil(t, distros)
|
||||||
|
|
||||||
|
// TODO pass it a real path?
|
||||||
|
repos, err := reporegistry.NewTestedDefault()
|
||||||
|
require.Nil(t, err)
|
||||||
|
require.NotNil(t, repos)
|
||||||
|
|
||||||
config := v2.ServerConfig{
|
config := v2.ServerConfig{
|
||||||
JWTEnabled: enableJWT,
|
JWTEnabled: enableJWT,
|
||||||
TenantProviderFields: []string{"rh-org-id", "account_id"},
|
TenantProviderFields: []string{"rh-org-id", "account_id"},
|
||||||
}
|
}
|
||||||
v2Server := v2.NewServer(workerServer, distros, config)
|
v2Server := v2.NewServer(workerServer, distros, repos, config)
|
||||||
require.NotNil(t, v2Server)
|
require.NotNil(t, v2Server)
|
||||||
t.Cleanup(v2Server.Shutdown)
|
t.Cleanup(v2Server.Shutdown)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue