sitesclient

package
v0.16.521 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sitesclient deploys sites over the API of internal/sites without importing the server. The runtime and the agent publish with it.

Index

Constants

This section is empty.

Variables

View Source
var ErrNameTaken = errors.New("the site name is taken")

ErrNameTaken: the name belongs to a site this caller did not make for this origin.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Base is the server's address (https://hub.example.com), Token a deploy token, a publishing session or an
	// administrator's token.
	Base  string
	Token string
	HTTP  *http.Client
}

Client deploys sites to a server over the API (docs/hub/sites.md): the protocol of `harnessly site deploy`, for the code that has the files in memory, such as the runtime publishing a Sinopia project.

func (*Client) Claim

func (c *Client) Claim(ctx context.Context, space, name, access, origin string) error

Claim gets the site ready for a deployment of the thing named origin: it makes the site when there is none, and takes it over only when it was made for the same origin by this caller. A site of anybody else, or of another origin, is ErrNameTaken, and nothing of it is touched. access is used for a new site only.

func (*Client) Deploy

func (c *Client) Deploy(ctx context.Context, space, name, source string, files []DeployFile) (Deployed, error)

Deploy sends the files as a new version of the site, which becomes the current one. Only the files the server does not have yet travel.

func (*Client) FindByOrigin added in v0.16.123

func (c *Client) FindByOrigin(ctx context.Context, space, origin string) (*Site, error)

FindByOrigin is the caller's site made from origin (sinopia:<project>), or nil when there is none. The server lists a machine its own sites only.

func (*Client) SetAccess

func (c *Client) SetAccess(ctx context.Context, space, name, access string) error

SetAccess changes who may open the site.

type ClientError

type ClientError struct {
	Status  int
	Code    string
	Message string
}

ClientError is a refusal of the server, with the words it gave.

func (*ClientError) Error

func (e *ClientError) Error() string

type DeployFile

type DeployFile struct {
	Path string
	Data []byte
}

DeployFile is one file of a deployment.

type Deployed

type Deployed struct {
	Version int    `json:"version"`
	URL     string `json:"url"`
}

Deployed is what the server answers to a finished deployment.

type Site added in v0.16.123

type Site struct {
	Name           string `json:"name"`
	Address        string `json:"address"`
	Access         string `json:"access"`
	CurrentVersion int    `json:"currentVersion"`
	Origin         string `json:"origin"`
}

Site is a site as the server lists it: what «Поделиться» shows of a published design.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL