Documentation
¶
Overview ¶
Package db provides a simple JSON file-backed database.
Index ¶
- Constants
- type Artifact
- type ArtifactName
- type ArtifactRef
- type ArtifactStore
- type ArtifactView
- type Data
- type DataView
- func (v DataView) AsStruct() *Data
- func (v DataView) DataVersion() int
- func (v DataView) DockerNetworks() views.MapFn[string, *DockerNetwork, DockerNetworkView]
- func (v DataView) Images() views.MapFn[ImageRepoName, *ImageRepo, ImageRepoView]
- func (v DataView) MarshalJSON() ([]byte, error)
- func (v DataView) Services() views.MapFn[string, *Service, ServiceView]
- func (v *DataView) UnmarshalJSON(b []byte) error
- func (v DataView) Valid() bool
- func (v DataView) Volumes() views.MapFn[string, *Volume, VolumeView]
- type DockerEndpoint
- type DockerEndpointView
- func (v DockerEndpointView) AsStruct() *DockerEndpoint
- func (v DockerEndpointView) EndpointID() string
- func (v DockerEndpointView) IPv4() netip.Prefix
- func (v DockerEndpointView) MarshalJSON() ([]byte, error)
- func (v *DockerEndpointView) UnmarshalJSON(b []byte) error
- func (v DockerEndpointView) Valid() bool
- type DockerNetwork
- type DockerNetworkView
- func (v DockerNetworkView) AsStruct() *DockerNetwork
- func (v DockerNetworkView) EndpointAddrs() views.Map[string, netip.Prefix]
- func (v DockerNetworkView) Endpoints() views.MapFn[string, *DockerEndpoint, DockerEndpointView]
- func (v DockerNetworkView) IPv4Gateway() netip.Prefix
- func (v DockerNetworkView) IPv4Range() netip.Prefix
- func (v DockerNetworkView) MarshalJSON() ([]byte, error)
- func (v DockerNetworkView) NetNS() string
- func (v DockerNetworkView) NetworkID() string
- func (v DockerNetworkView) PortMap() views.MapFn[string, *EndpointPort, EndpointPortView]
- func (v *DockerNetworkView) UnmarshalJSON(b []byte) error
- func (v DockerNetworkView) Valid() bool
- type EndpointPort
- type EndpointPortView
- type ImageManifest
- type ImageRef
- type ImageRepo
- type ImageRepoName
- type ImageRepoView
- type MacvlanNetwork
- type ProtoPort
- type Service
- type ServiceType
- type ServiceView
- func (v ServiceView) Artifacts() views.MapFn[ArtifactName, *Artifact, ArtifactView]
- func (v ServiceView) AsStruct() *Service
- func (v ServiceView) Generation() int
- func (v ServiceView) LatestGeneration() int
- func (v ServiceView) Macvlan() views.ValuePointer[MacvlanNetwork]
- func (v ServiceView) MarshalJSON() ([]byte, error)
- func (v ServiceView) Name() string
- func (v ServiceView) ServiceType() ServiceType
- func (v ServiceView) SvcNetwork() views.ValuePointer[SvcNetwork]
- func (v ServiceView) TSNet() TailscaleNetworkView
- func (v *ServiceView) UnmarshalJSON(b []byte) error
- func (v ServiceView) Valid() bool
- type Store
- type SvcNetwork
- type TailscaleNetwork
- type TailscaleNetworkView
- func (v TailscaleNetworkView) AsStruct() *TailscaleNetwork
- func (v TailscaleNetworkView) ExitNode() string
- func (v TailscaleNetworkView) Interface() string
- func (v TailscaleNetworkView) MarshalJSON() ([]byte, error)
- func (v TailscaleNetworkView) StableID() tailcfg.StableNodeID
- func (v TailscaleNetworkView) Tags() views.Slice[string]
- func (v *TailscaleNetworkView) UnmarshalJSON(b []byte) error
- func (v TailscaleNetworkView) Valid() bool
- func (v TailscaleNetworkView) Version() string
- type Volume
- type VolumeView
- func (v VolumeView) AsStruct() *Volume
- func (v VolumeView) Deps() string
- func (v VolumeView) MarshalJSON() ([]byte, error)
- func (v VolumeView) Name() string
- func (v VolumeView) Opts() string
- func (v VolumeView) Path() string
- func (v VolumeView) Src() string
- func (v VolumeView) Type() string
- func (v *VolumeView) UnmarshalJSON(b []byte) error
- func (v VolumeView) Valid() bool
Constants ¶
const CurrentDataVersion = 5
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Artifact ¶
type Artifact struct {
Refs map[ArtifactRef]string // path on disk
}
func (*Artifact) Clone ¶
Clone makes a deep copy of Artifact. The result aliases no memory with the original.
func (*Artifact) View ¶
func (p *Artifact) View() ArtifactView
View returns a read-only view of Artifact.
type ArtifactName ¶
type ArtifactName string
const ( ArtifactBinary ArtifactName = "binary" ArtifactEnvFile ArtifactName = "env" ArtifactDockerComposeFile ArtifactName = "compose.yml" ArtifactDockerComposeNetwork ArtifactName = "compose.network" ArtifactTypeScriptFile ArtifactName = "main.ts" ArtifactPythonFile ArtifactName = "main.py" ArtifactSystemdUnit ArtifactName = "systemd.service" ArtifactSystemdTimerFile ArtifactName = "systemd.timer" ArtifactNetNSService ArtifactName = "netns.service" ArtifactNetNSEnv ArtifactName = "netns.env" ArtifactTSService ArtifactName = "tailscale.service" ArtifactTSEnv ArtifactName = "tailscale.env" ArtifactTSBinary ArtifactName = "tailscaled" ArtifactTSConfig ArtifactName = "tailscaled.json" ArtifactNetNSResolv ArtifactName = "resolv.conf" )
type ArtifactRef ¶
type ArtifactRef string
ArtifactRef is a reference to an artifact.
It's either "latest", "staged", or a generation number like "gen-23".
func Gen ¶
func Gen(gen int) ArtifactRef
type ArtifactStore ¶
type ArtifactStore map[ArtifactName]*Artifact
func (ArtifactStore) Gen ¶
func (as ArtifactStore) Gen(name ArtifactName, gen int) (string, bool)
func (ArtifactStore) Latest ¶
func (as ArtifactStore) Latest(name ArtifactName) (string, bool)
func (ArtifactStore) Staged ¶
func (as ArtifactStore) Staged(name ArtifactName) (string, bool)
type ArtifactView ¶
type ArtifactView struct {
// contains filtered or unexported fields
}
ArtifactView provides a read-only view over Artifact.
Its methods should only be called if `Valid()` returns true.
func (ArtifactView) AsStruct ¶
func (v ArtifactView) AsStruct() *Artifact
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (ArtifactView) MarshalJSON ¶
func (v ArtifactView) MarshalJSON() ([]byte, error)
func (ArtifactView) Refs ¶
func (v ArtifactView) Refs() views.Map[ArtifactRef, string]
func (*ArtifactView) UnmarshalJSON ¶
func (v *ArtifactView) UnmarshalJSON(b []byte) error
func (ArtifactView) Valid ¶
func (v ArtifactView) Valid() bool
Valid reports whether v's underlying value is non-nil.
type Data ¶
type Data struct {
// DataVersion is the version of the data format. This is used to determine
// how to parse the data.
DataVersion int `json:",omitempty"`
Services map[string]*Service
Images map[ImageRepoName]*ImageRepo
Volumes map[string]*Volume
DockerNetworks map[string]*DockerNetwork
}
Data is the full JSON structure of the database.
type DataView ¶
type DataView struct {
// contains filtered or unexported fields
}
DataView provides a read-only view over Data.
Its methods should only be called if `Valid()` returns true.
func (DataView) AsStruct ¶
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (DataView) DataVersion ¶
func (DataView) DockerNetworks ¶
func (v DataView) DockerNetworks() views.MapFn[string, *DockerNetwork, DockerNetworkView]
func (DataView) Images ¶
func (v DataView) Images() views.MapFn[ImageRepoName, *ImageRepo, ImageRepoView]
func (DataView) MarshalJSON ¶
func (*DataView) UnmarshalJSON ¶
type DockerEndpoint ¶
func (*DockerEndpoint) Clone ¶
func (src *DockerEndpoint) Clone() *DockerEndpoint
Clone makes a deep copy of DockerEndpoint. The result aliases no memory with the original.
func (*DockerEndpoint) View ¶
func (p *DockerEndpoint) View() DockerEndpointView
View returns a read-only view of DockerEndpoint.
type DockerEndpointView ¶
type DockerEndpointView struct {
// contains filtered or unexported fields
}
DockerEndpointView provides a read-only view over DockerEndpoint.
Its methods should only be called if `Valid()` returns true.
func (DockerEndpointView) AsStruct ¶
func (v DockerEndpointView) AsStruct() *DockerEndpoint
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (DockerEndpointView) EndpointID ¶
func (v DockerEndpointView) EndpointID() string
func (DockerEndpointView) IPv4 ¶
func (v DockerEndpointView) IPv4() netip.Prefix
func (DockerEndpointView) MarshalJSON ¶
func (v DockerEndpointView) MarshalJSON() ([]byte, error)
func (*DockerEndpointView) UnmarshalJSON ¶
func (v *DockerEndpointView) UnmarshalJSON(b []byte) error
func (DockerEndpointView) Valid ¶
func (v DockerEndpointView) Valid() bool
Valid reports whether v's underlying value is non-nil.
type DockerNetwork ¶
type DockerNetwork struct {
NetworkID string
NetNS string
IPv4Gateway netip.Prefix
IPv4Range netip.Prefix
Endpoints map[string]*DockerEndpoint
// Deprecated: use Endpoints instead.
EndpointAddrs map[string]netip.Prefix
PortMap map[string]*EndpointPort // key is "proto/hostport"
}
func (*DockerNetwork) Clone ¶
func (src *DockerNetwork) Clone() *DockerNetwork
Clone makes a deep copy of DockerNetwork. The result aliases no memory with the original.
func (*DockerNetwork) View ¶
func (p *DockerNetwork) View() DockerNetworkView
View returns a read-only view of DockerNetwork.
type DockerNetworkView ¶
type DockerNetworkView struct {
// contains filtered or unexported fields
}
DockerNetworkView provides a read-only view over DockerNetwork.
Its methods should only be called if `Valid()` returns true.
func (DockerNetworkView) AsStruct ¶
func (v DockerNetworkView) AsStruct() *DockerNetwork
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (DockerNetworkView) EndpointAddrs ¶
func (DockerNetworkView) Endpoints ¶
func (v DockerNetworkView) Endpoints() views.MapFn[string, *DockerEndpoint, DockerEndpointView]
func (DockerNetworkView) IPv4Gateway ¶
func (v DockerNetworkView) IPv4Gateway() netip.Prefix
func (DockerNetworkView) IPv4Range ¶
func (v DockerNetworkView) IPv4Range() netip.Prefix
func (DockerNetworkView) MarshalJSON ¶
func (v DockerNetworkView) MarshalJSON() ([]byte, error)
func (DockerNetworkView) NetNS ¶
func (v DockerNetworkView) NetNS() string
func (DockerNetworkView) NetworkID ¶
func (v DockerNetworkView) NetworkID() string
func (DockerNetworkView) PortMap ¶
func (v DockerNetworkView) PortMap() views.MapFn[string, *EndpointPort, EndpointPortView]
func (*DockerNetworkView) UnmarshalJSON ¶
func (v *DockerNetworkView) UnmarshalJSON(b []byte) error
func (DockerNetworkView) Valid ¶
func (v DockerNetworkView) Valid() bool
Valid reports whether v's underlying value is non-nil.
type EndpointPort ¶
func (*EndpointPort) Clone ¶
func (src *EndpointPort) Clone() *EndpointPort
Clone makes a deep copy of EndpointPort. The result aliases no memory with the original.
func (*EndpointPort) View ¶
func (p *EndpointPort) View() EndpointPortView
View returns a read-only view of EndpointPort.
type EndpointPortView ¶
type EndpointPortView struct {
// contains filtered or unexported fields
}
EndpointPortView provides a read-only view over EndpointPort.
Its methods should only be called if `Valid()` returns true.
func (EndpointPortView) AsStruct ¶
func (v EndpointPortView) AsStruct() *EndpointPort
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (EndpointPortView) EndpointID ¶
func (v EndpointPortView) EndpointID() string
func (EndpointPortView) MarshalJSON ¶
func (v EndpointPortView) MarshalJSON() ([]byte, error)
func (EndpointPortView) Port ¶
func (v EndpointPortView) Port() uint16
func (*EndpointPortView) UnmarshalJSON ¶
func (v *EndpointPortView) UnmarshalJSON(b []byte) error
func (EndpointPortView) Valid ¶
func (v EndpointPortView) Valid() bool
Valid reports whether v's underlying value is non-nil.
type ImageManifest ¶
type ImageRepo ¶
type ImageRepo struct {
Refs map[ImageRef]ImageManifest `json:",omitempty"`
}
func (*ImageRepo) Clone ¶
Clone makes a deep copy of ImageRepo. The result aliases no memory with the original.
func (*ImageRepo) View ¶
func (p *ImageRepo) View() ImageRepoView
View returns a read-only view of ImageRepo.
type ImageRepoName ¶
type ImageRepoName string
type ImageRepoView ¶
type ImageRepoView struct {
// contains filtered or unexported fields
}
ImageRepoView provides a read-only view over ImageRepo.
Its methods should only be called if `Valid()` returns true.
func (ImageRepoView) AsStruct ¶
func (v ImageRepoView) AsStruct() *ImageRepo
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (ImageRepoView) MarshalJSON ¶
func (v ImageRepoView) MarshalJSON() ([]byte, error)
func (ImageRepoView) Refs ¶
func (v ImageRepoView) Refs() views.Map[ImageRef, ImageManifest]
func (*ImageRepoView) UnmarshalJSON ¶
func (v *ImageRepoView) UnmarshalJSON(b []byte) error
func (ImageRepoView) Valid ¶
func (v ImageRepoView) Valid() bool
Valid reports whether v's underlying value is non-nil.
type MacvlanNetwork ¶
type Service ¶
type Service struct {
// Name is the name of the service.
Name string
ServiceType ServiceType
// Generation is the current generation of the service.
Generation int `json:",omitempty"`
// LatestGeneration is the latest generation of the service.
LatestGeneration int `json:",omitempty"`
// Artifacts are the artifacts generated for this service.
Artifacts ArtifactStore
SvcNetwork *SvcNetwork
Macvlan *MacvlanNetwork
TSNet *TailscaleNetwork
}
Service is the configuration for one service.
func (*Service) Clone ¶
Clone makes a deep copy of Service. The result aliases no memory with the original.
func (*Service) View ¶
func (p *Service) View() ServiceView
View returns a read-only view of Service.
type ServiceType ¶
type ServiceType string
const ( ServiceTypeDockerCompose ServiceType = "docker-compose" ServiceTypeSystemd ServiceType = "systemd" )
type ServiceView ¶
type ServiceView struct {
// contains filtered or unexported fields
}
ServiceView provides a read-only view over Service.
Its methods should only be called if `Valid()` returns true.
func (ServiceView) Artifacts ¶
func (v ServiceView) Artifacts() views.MapFn[ArtifactName, *Artifact, ArtifactView]
func (ServiceView) AsStruct ¶
func (v ServiceView) AsStruct() *Service
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (ServiceView) Generation ¶
func (v ServiceView) Generation() int
func (ServiceView) LatestGeneration ¶
func (v ServiceView) LatestGeneration() int
func (ServiceView) Macvlan ¶
func (v ServiceView) Macvlan() views.ValuePointer[MacvlanNetwork]
func (ServiceView) MarshalJSON ¶
func (v ServiceView) MarshalJSON() ([]byte, error)
func (ServiceView) Name ¶
func (v ServiceView) Name() string
func (ServiceView) ServiceType ¶
func (v ServiceView) ServiceType() ServiceType
func (ServiceView) SvcNetwork ¶
func (v ServiceView) SvcNetwork() views.ValuePointer[SvcNetwork]
func (ServiceView) TSNet ¶
func (v ServiceView) TSNet() TailscaleNetworkView
func (*ServiceView) UnmarshalJSON ¶
func (v *ServiceView) UnmarshalJSON(b []byte) error
func (ServiceView) Valid ¶
func (v ServiceView) Valid() bool
Valid reports whether v's underlying value is non-nil.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) MutateService ¶
type SvcNetwork ¶
type TailscaleNetwork ¶
type TailscaleNetwork struct {
Interface string
Version string
ExitNode string `json:",omitempty"`
Tags []string
StableID tailcfg.StableNodeID
}
func (*TailscaleNetwork) Clone ¶
func (src *TailscaleNetwork) Clone() *TailscaleNetwork
Clone makes a deep copy of TailscaleNetwork. The result aliases no memory with the original.
func (*TailscaleNetwork) View ¶
func (p *TailscaleNetwork) View() TailscaleNetworkView
View returns a read-only view of TailscaleNetwork.
type TailscaleNetworkView ¶
type TailscaleNetworkView struct {
// contains filtered or unexported fields
}
TailscaleNetworkView provides a read-only view over TailscaleNetwork.
Its methods should only be called if `Valid()` returns true.
func (TailscaleNetworkView) AsStruct ¶
func (v TailscaleNetworkView) AsStruct() *TailscaleNetwork
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (TailscaleNetworkView) ExitNode ¶
func (v TailscaleNetworkView) ExitNode() string
func (TailscaleNetworkView) Interface ¶
func (v TailscaleNetworkView) Interface() string
func (TailscaleNetworkView) MarshalJSON ¶
func (v TailscaleNetworkView) MarshalJSON() ([]byte, error)
func (TailscaleNetworkView) StableID ¶
func (v TailscaleNetworkView) StableID() tailcfg.StableNodeID
func (*TailscaleNetworkView) UnmarshalJSON ¶
func (v *TailscaleNetworkView) UnmarshalJSON(b []byte) error
func (TailscaleNetworkView) Valid ¶
func (v TailscaleNetworkView) Valid() bool
Valid reports whether v's underlying value is non-nil.
func (TailscaleNetworkView) Version ¶
func (v TailscaleNetworkView) Version() string
type Volume ¶
type VolumeView ¶
type VolumeView struct {
// contains filtered or unexported fields
}
VolumeView provides a read-only view over Volume.
Its methods should only be called if `Valid()` returns true.
func (VolumeView) AsStruct ¶
func (v VolumeView) AsStruct() *Volume
AsStruct returns a clone of the underlying value which aliases no memory with the original.
func (VolumeView) Deps ¶
func (v VolumeView) Deps() string
func (VolumeView) MarshalJSON ¶
func (v VolumeView) MarshalJSON() ([]byte, error)
func (VolumeView) Name ¶
func (v VolumeView) Name() string
func (VolumeView) Opts ¶
func (v VolumeView) Opts() string
func (VolumeView) Path ¶
func (v VolumeView) Path() string
func (VolumeView) Src ¶
func (v VolumeView) Src() string
func (VolumeView) Type ¶
func (v VolumeView) Type() string
func (*VolumeView) UnmarshalJSON ¶
func (v *VolumeView) UnmarshalJSON(b []byte) error
func (VolumeView) Valid ¶
func (v VolumeView) Valid() bool
Valid reports whether v's underlying value is non-nil.