osbuild-composer: merge cloud API into main binary

This removes the osbuild-composer-cloud package, binary, systemd units,
the (unused) test binary, and the (only-run-on-RHEL) test in aws.sh.

Instead, move the cloud API into the main package, using the same
socket as the koji API, osbuild-composer-api.socket. Expose it next to
the koji API on route `/api/composer/v1`.

This is a backwards incompatible change, but only of the -cloud parts,
which have been marked as subject to change.
This commit is contained in:
Lars Karlitski 2020-10-03 09:58:39 +02:00 committed by Ondřej Budai
parent 835b556db7
commit b25a350502
14 changed files with 50 additions and 428 deletions

View file

@ -5,9 +5,9 @@ package cloudapi
import (
"encoding/json"
"fmt"
"net"
"net/http"
"github.com/go-chi/chi"
"github.com/google/uuid"
"github.com/osbuild/osbuild-composer/internal/blueprint"
@ -34,16 +34,16 @@ func NewServer(workers *worker.Server, rpmMetadata rpmmd.RPMMD, distros *distro.
return server
}
// Serve serves the cloud API over the provided listener socket
func (server *Server) Serve(listener net.Listener) error {
s := http.Server{Handler: Handler(server)}
// Create an http.Handler() for this server, that provides the composer API at
// the given path.
func (server *Server) Handler(path string) http.Handler {
r := chi.NewRouter()
err := s.Serve(listener)
if err != nil && err != http.ErrServerClosed {
return err
}
r.Route(path, func(r chi.Router) {
HandlerFromMux(server, r)
})
return nil
return r
}
// Compose handles a new /compose POST request
@ -150,7 +150,7 @@ func (server *Server) Compose(w http.ResponseWriter, r *http.Request) {
return
}
key := fmt.Sprintf("composer-cloudapi-%s", uuid.New().String())
key := fmt.Sprintf("composer-api-%s", uuid.New().String())
t := target.NewAWSTarget(&target.AWSTargetOptions{
Filename: imageType.Filename(),
Region: awsUploadOptions.Region,