cloudproject

package
v0.147.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cloudproject reads a DataTug Cloud project owned by a Space through the DataTug backend's /v0/datatug/* endpoints, the same reads datatug.app makes. It never talks to Firestore: the backend checks the caller's Space membership and the project's access on every read (spec/features/cli/cloud-projects).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is a 404: the project does not exist or was deleted.
	ErrNotFound = errors.New("project not found, or it was deleted")
	// ErrUnauthorized is a 401: the login expired or was revoked.
	ErrUnauthorized = errors.New("DataTug sign-in expired")
	// ErrForbidden is a 403: the account may not read the project.
	ErrForbidden = errors.New("no access to this project")
	// ErrUnavailable wraps a network failure or a 5xx answer.
	ErrUnavailable = errors.New("can't reach DataTug Cloud")
)

Errors of a read. Each maps to one exit code and one line of the CLI.

Functions

func ValidIdentifier

func ValidIdentifier(s string) bool

ValidIdentifier reports whether s is a valid Space or project id: the rule of datatug.app's isSharedProjectIdentifier and the backend's ValidateSharedProjectIdentifier.

Types

type Client

type Client struct {
	// BaseURL ends with "/v0/".
	BaseURL string
	// HTTP must not follow redirects, so a bearer never reaches another host.
	HTTP *http.Client
	// Token returns the current bearer.
	Token func(context.Context) (string, error)
}

Client sends authenticated GET requests to the backend.

type Item

type Item struct {
	ID    string `json:"id"`
	Title string `json:"title,omitempty"`
}

Item is an id with an optional title.

type Project

type Project struct {
	Ref          Ref
	ID, Title    string
	Environments []Item
	EnvsErr      error
	Databases    []Item
	DBsErr       error
	// Queries are ids, with "<folder>/<id>" for a query in a folder.
	Queries    []Item
	QueriesErr error
}

Project is what the terminal UI shows of a cloud project. A list that failed to load carries its error, shown in its own panel.

func Load

func Load(ctx context.Context, c *Client, ref Ref) (Project, error)

Load reads the project. Only a failing summary is an error: a failing list is kept on the project.

type Ref

type Ref struct {
	SpaceID, ProjectID string
}

Ref names a Space-owned cloud project.

func (Ref) Address

func (r Ref) Address() string

Address is the project's canonical datatug.app address.

func (Ref) Validate

func (r Ref) Validate() error

Validate returns which part of the reference is invalid, or nil.

Jump to

Keyboard shortcuts

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