diff --git a/README.md b/README.md index 2f4c3c2..2e69830 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,24 @@ A Gentoo binary host platform. Enables building and tracking various targets. +## API + +Loose documentation of the API provided by `binhost` is below. + +### `POST /v1/upload` + +Uploads the provided `gpkg`. If a `target` is not specified via URL +parameters, the `CHOST` is used as the target name. Errors if a target +doesn't exist. + +### `GET /v1/targets` + +Lists all of the available targets (package indexes). + +### `POST /v1/targets/:target` + +Creates the provided target. + ## License AGPL-3.0 diff --git a/internal/db/db.go b/internal/db/db.go new file mode 100644 index 0000000..469724b --- /dev/null +++ b/internal/db/db.go @@ -0,0 +1,37 @@ +// Copyright (C) 2024 Jared Allard +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// TODO(jaredallard): This probably should implement a "store" for also +// storing the packages themselves. Maybe S3 or something else backed? + +// Package db implements a thin wrapper around a DB for the purpose of +// storing package information. +package db + +// Client contains a DB client. +type Client struct{} + +// New creates a new DB client. +func New() (*Client, error) { return nil, nil } + +// TODO(jaredallard): package struct from somewhere? +// NewPackage creates a new package and stores it. +func (c *Client) NewPackage() error { return nil } + +func (c *Client) DeletePackage(id string) error { return nil } + +func (c *Client) CreateTarget(name string) error { return nil } + +func (p *Client) DeleteTarget(name string) error { return nil } diff --git a/internal/packages/packages.go b/internal/packages/packages.go new file mode 100644 index 0000000..5fd7cbd --- /dev/null +++ b/internal/packages/packages.go @@ -0,0 +1,38 @@ +// Copyright (C) 2024 Jared Allard +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Packages contains utilities for interacting with Gentoo packages. +package packages + +import ( + "archive/tar" + "io" +) + +type Package struct { + // TODO(jaredallard): Add fields for a package here. +} + +// New creates a new Package from the provided [io.ReadCloser]. +func New(r io.ReadCloser) (*Package, error) { + var p Package + + t := tar.NewReader(r) + + // TODO(jaredallard): Once we have internet, we should actually do + // something with the tar reader. + _ = t + return &p, nil +} diff --git a/internal/server/server.go b/internal/server/server.go new file mode 100644 index 0000000..fef006a --- /dev/null +++ b/internal/server/server.go @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Jared Allard +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Package server contains the code for creating an HTTP server for +// serving a binhost. +package server + +import "context" + +type Activity struct{} + +// Run starts the HTTP service activity. Blocks until the provided +// context is cancelled. +func (a *Activity) Run(_ context.Context) error { + return nil +}