Skip to content

Commit

Permalink
some scaffolding while on a plane
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredallard committed Mar 15, 2024
1 parent e8a91c4 commit af5042d
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 37 additions & 0 deletions internal/db/db.go
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

// 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 }
38 changes: 38 additions & 0 deletions internal/packages/packages.go
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

// 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
}
28 changes: 28 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

// 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
}

0 comments on commit af5042d

Please sign in to comment.