diff --git a/internal/client/blueprints.go b/internal/client/blueprints.go index 2df7e8381..15731462b 100644 --- a/internal/client/blueprints.go +++ b/internal/client/blueprints.go @@ -7,6 +7,8 @@ import ( "fmt" "net/http" "strings" + + "github.com/osbuild/osbuild-composer/internal/weldr" ) // PostTOMLBlueprintV0 sends a TOML blueprint string to the API @@ -73,7 +75,7 @@ func ListBlueprintsV0(socket *http.Client) ([]string, *APIResponse, error) { if resp != nil || err != nil { return nil, resp, err } - var list BlueprintsListV0 + var list weldr.BlueprintsListV0 err = json.Unmarshal(body, &list) if err != nil { return nil, nil, err @@ -91,30 +93,30 @@ func GetBlueprintInfoTOMLV0(socket *http.Client, bpName string) (string, *APIRes } // GetBlueprintsInfoJSONV0 returns the requested blueprints and their changed state -func GetBlueprintsInfoJSONV0(socket *http.Client, bpName string) (BlueprintsInfoV0, *APIResponse, error) { +func GetBlueprintsInfoJSONV0(socket *http.Client, bpName string) (weldr.BlueprintsInfoV0, *APIResponse, error) { body, resp, err := GetRaw(socket, "GET", "/api/v0/blueprints/info/"+bpName) if resp != nil || err != nil { - return BlueprintsInfoV0{}, resp, err + return weldr.BlueprintsInfoV0{}, resp, err } - var info BlueprintsInfoV0 + var info weldr.BlueprintsInfoV0 err = json.Unmarshal(body, &info) if err != nil { - return BlueprintsInfoV0{}, nil, err + return weldr.BlueprintsInfoV0{}, nil, err } return info, nil, nil } // GetBlueprintsChangesV0 returns the changes to the listed blueprints -func GetBlueprintsChangesV0(socket *http.Client, bpNames []string) (BlueprintsChangesV0, *APIResponse, error) { +func GetBlueprintsChangesV0(socket *http.Client, bpNames []string) (weldr.BlueprintsChangesV0, *APIResponse, error) { names := strings.Join(bpNames, ",") body, resp, err := GetRaw(socket, "GET", "/api/v0/blueprints/changes/"+names) if resp != nil || err != nil { - return BlueprintsChangesV0{}, resp, err + return weldr.BlueprintsChangesV0{}, resp, err } - var changes BlueprintsChangesV0 + var changes weldr.BlueprintsChangesV0 err = json.Unmarshal(body, &changes) if err != nil { - return BlueprintsChangesV0{}, nil, err + return weldr.BlueprintsChangesV0{}, nil, err } return changes, nil, nil } @@ -139,30 +141,30 @@ func TagBlueprintV0(socket *http.Client, blueprint string) (*APIResponse, error) } // DepsolveBlueprintV0 depsolves the listed blueprint -func DepsolveBlueprintV0(socket *http.Client, blueprint string) (BlueprintsDepsolveV0, *APIResponse, error) { +func DepsolveBlueprintV0(socket *http.Client, blueprint string) (weldr.BlueprintsDepsolveV0, *APIResponse, error) { body, resp, err := GetRaw(socket, "GET", "/api/v0/blueprints/depsolve/"+blueprint) if resp != nil || err != nil { - return BlueprintsDepsolveV0{}, resp, err + return weldr.BlueprintsDepsolveV0{}, resp, err } - var deps BlueprintsDepsolveV0 + var deps weldr.BlueprintsDepsolveV0 err = json.Unmarshal(body, &deps) if err != nil { - return BlueprintsDepsolveV0{}, nil, err + return weldr.BlueprintsDepsolveV0{}, nil, err } return deps, nil, nil } // FreezeBlueprintV0 depsolves the listed blueprint and returns the blueprint with frozen package // versions -func FreezeBlueprintV0(socket *http.Client, blueprint string) (BlueprintsFreezeV0, *APIResponse, error) { +func FreezeBlueprintV0(socket *http.Client, blueprint string) (weldr.BlueprintsFreezeV0, *APIResponse, error) { body, resp, err := GetRaw(socket, "GET", "/api/v0/blueprints/freeze/"+blueprint) if resp != nil || err != nil { - return BlueprintsFreezeV0{}, resp, err + return weldr.BlueprintsFreezeV0{}, resp, err } - var frozen BlueprintsFreezeV0 + var frozen weldr.BlueprintsFreezeV0 err = json.Unmarshal(body, &frozen) if err != nil { - return BlueprintsFreezeV0{}, nil, err + return weldr.BlueprintsFreezeV0{}, nil, err } return frozen, nil, nil } diff --git a/internal/client/weldr.go b/internal/client/weldr.go index dcb9feede..1090ee96a 100644 --- a/internal/client/weldr.go +++ b/internal/client/weldr.go @@ -5,10 +5,12 @@ package client import ( "encoding/json" "net/http" + + "github.com/osbuild/osbuild-composer/internal/weldr" ) // GetStatusV0 makes a GET request to /api/status and returns the v0 response as a StatusResponseV0 -func GetStatusV0(socket *http.Client) (reply StatusV0, resp *APIResponse, err error) { +func GetStatusV0(socket *http.Client) (reply weldr.StatusV0, resp *APIResponse, err error) { body, resp, err := GetRaw(socket, "GET", "/api/status") if resp != nil || err != nil { return reply, resp, err diff --git a/internal/client/json.go b/internal/weldr/json.go similarity index 96% rename from internal/client/json.go rename to internal/weldr/json.go index 4cf955342..bbd37b6ca 100644 --- a/internal/client/json.go +++ b/internal/weldr/json.go @@ -1,6 +1,6 @@ -// Package client - json contains Exported API response structures +// Package weldr - json contains Exported API request/response structures // Copyright (C) 2020 by Red Hat, Inc. -package client +package weldr import ( "github.com/osbuild/osbuild-composer/internal/blueprint"