hostprovider

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Overview

Package hostprovider names the cloud or VPS provider this server runs on, from DMI strings first and a short link-local metadata probe second, and holds the provider-specific steps for opening web ports in a firewall the control plane cannot change.

Index

Constants

View Source
const (
	SourceDMI      = "dmi"
	SourceMetadata = "metadata"
)

Detection sources.

View Source
const EnvDataFile = "LEVELRAIL_HOSTPROVIDER_DATA_FILE"

EnvDataFile names an optional JSON file whose provider entries replace the embedded defaults, so links and steps change without a rebuild.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data map[string]Entry

Data maps a provider id to its entry.

func LoadData

func LoadData() (Data, error)

LoadData returns the embedded defaults merged with the optional override file. A broken override keeps the defaults and is reported as the error.

type Deps

type Deps struct {
	ReadFile func(path string) ([]byte, error)
	// Get performs one GET and returns the status code and a bounded body.
	Get func(ctx context.Context, url string, header http.Header) (int, []byte, error)
}

Deps are the host seams; tests replace both.

func SystemDeps

func SystemDeps() Deps

SystemDeps reads the real host and uses a one second metadata timeout.

type Entry

type Entry struct {
	Name    string   `json:"name"`
	DocsURL string   `json:"docs_url"`
	Steps   []string `json:"steps"`
	Note    string   `json:"note,omitempty"`
}

Entry is the editable text for one provider.

type Guidance

type Guidance struct {
	ID      ID         `json:"id"`
	Name    string     `json:"name"`
	Source  string     `json:"source"`
	DocsURL string     `json:"docs_url"`
	Ports   []PortRule `json:"ports"`
	Steps   []string   `json:"steps"`
	Note    string     `json:"note,omitempty"`
}

Guidance is the exact manual procedure for one provider's firewall.

func Detect

func Detect(ctx context.Context, d Deps) (Guidance, bool)

Detect returns the provider guidance for this host, or false when none is recognised.

func For

func For(id ID, source string) Guidance

For returns the guidance for id, tagged with how it was detected. A bad override file is ignored here; LoadData reports it as a warning.

type ID

type ID string

ID names a provider.

const (
	DigitalOcean ID = "digitalocean"
	AWS          ID = "aws"
	GCP          ID = "gcp"
	Hetzner      ID = "hetzner"
	Azure        ID = "azure"
	Oracle       ID = "oracle"
	Vultr        ID = "vultr"
	Linode       ID = "linode"
)

Provider IDs.

type PortRule

type PortRule struct {
	Port     int    `json:"port"`
	Protocol string `json:"protocol"`
	Source   string `json:"source"`
}

PortRule is one inbound rule to create.

Jump to

Keyboard shortcuts

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