hostprovider

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 6 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.

Variables

This section is empty.

Functions

This section is empty.

Types

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 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.

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