Skip to content

Commit

Permalink
Merge pull request #1 from teg/layout
Browse files Browse the repository at this point in the history
tree-wide: use a standard project layout
  • Loading branch information
msehnout authored Sep 24, 2019
2 parents 11af3f0 + 3533597 commit b700cd7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 18 deletions.
6 changes: 3 additions & 3 deletions main.go → cmd/osbuild-composer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"os/signal"
"path/filepath"

"osbuild-composer/rpmmd"
"osbuild-composer/weldr"
"osbuild-composer/internal/rpmmd"
"osbuild-composer/internal/weldr"
)

const StateFile = "/var/lib/osbuild-composer/weldr-state.json"
Expand Down Expand Up @@ -90,7 +90,7 @@ func main() {
func writeFileAtomically(filename string, data []byte, mode os.FileMode) error {
dir, name := filepath.Dir(filename), filepath.Base(filename)

tmpfile, err := ioutil.TempFile(dir, name + "-*.tmp")
tmpfile, err := ioutil.TempFile(dir, name+"-*.tmp")
if err != nil {
return err
}
Expand Down
10 changes: 10 additions & 0 deletions init/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=OSBuild Composer Worker (%i)

[Service]
PrivateTmp=true
ExecStart=/usr/local/lib/osbuild-composer/osbuild-composer-worker -C /var/lib/osbuild

[Install]
DefaultInstance=1
WantedBy=default.target
File renamed without changes.
8 changes: 4 additions & 4 deletions weldr/api.go → internal/weldr/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/julienschmidt/httprouter"

"osbuild-composer/rpmmd"
"osbuild-composer/internal/rpmmd"
)

type API struct {
Expand Down Expand Up @@ -405,8 +405,8 @@ func (api *API) blueprintsInfoHandler(writer http.ResponseWriter, request *http.

json.NewEncoder(writer).Encode(reply{
Blueprints: blueprints,
Changes: changes,
Errors: []string{},
Changes: changes,
Errors: []string{},
})
}

Expand Down Expand Up @@ -449,7 +449,7 @@ func (api *API) blueprintsDepsolveHandler(writer http.ResponseWriter, request *h

json.NewEncoder(writer).Encode(reply{
Blueprints: blueprints,
Errors: []string{},
Errors: []string{},
})
}

Expand Down
20 changes: 10 additions & 10 deletions weldr/api_test.go → internal/weldr/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"strings"
"testing"

"osbuild-composer/rpmmd"
"osbuild-composer/weldr"
"osbuild-composer/internal/rpmmd"
"osbuild-composer/internal/weldr"
)

var repo = rpmmd.RepoConfig{
Expand All @@ -20,9 +20,9 @@ var repo = rpmmd.RepoConfig{
BaseURL: "http://example.com/test/os",
}

var packages = rpmmd.PackageList {
{ Name: "package1" },
{ Name: "package2" },
var packages = rpmmd.PackageList{
{Name: "package1"},
{Name: "package2"},
}

func testRoute(t *testing.T, api *weldr.API, method, path, body string, expectedStatus int, expectedJSON string) {
Expand Down Expand Up @@ -110,28 +110,28 @@ func TestBasic(t *testing.T) {
{"/api/v0/blueprints/info/example", http.StatusOK, `*`},
}

for _, c:= range cases {
api := weldr.New(repo, packages, nil)
for _, c := range cases {
api := weldr.New(repo, packages, nil, nil, nil)
testRoute(t, api, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
}
}

func TestBlueprints(t *testing.T) {
api := weldr.New(repo, packages, nil)
api := weldr.New(repo, packages, nil, nil, nil)

testRoute(t, api, "POST", "/api/v0/blueprints/new",
`{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0"}`,
http.StatusOK, `{"status":true}`)

testRoute(t, api, "GET", "/api/v0/blueprints/info/test", ``,
http.StatusOK, `{"blueprints":[{"name":"test","description":"Test","modules":[],"packages":[{"name":"httpd","version":"2.4.*"}],"version":"0"}],
http.StatusOK, `{"blueprints":[{"name":"test","description":"Test","modules":[],"packages":[{"name":"httpd","version":"2.4.*"}],"version":"0"}],
"changes":[{"name":"test","changed":false}], "errors":[]}`)

testRoute(t, api, "POST", "/api/v0/blueprints/workspace",
`{"name":"test","description":"Test","packages":[{"name":"systemd","version":"123"}],"version":"0"}`,
http.StatusOK, `{"status":true}`)

testRoute(t, api, "GET", "/api/v0/blueprints/info/test", ``,
http.StatusOK, `{"blueprints":[{"name":"test","description":"Test","modules":[],"packages":[{"name":"systemd","version":"123"}],"version":"0"}],
http.StatusOK, `{"blueprints":[{"name":"test","description":"Test","modules":[],"packages":[{"name":"systemd","version":"123"}],"version":"0"}],
"changes":[{"name":"test","changed":true}], "errors":[]}`)
}
2 changes: 1 addition & 1 deletion weldr/store.go → internal/weldr/store.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package weldr

import (
"log"
"encoding/json"
"log"
"sort"
"sync"
)
Expand Down
File renamed without changes.

0 comments on commit b700cd7

Please sign in to comment.