projectlink

package
v0.5.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: PostgreSQL Imports: 9 Imported by: 0

Documentation

Overview

Package projectlink reads and writes .pgedge/link.yaml, the file that ties a project folder to one database. It holds identifiers only, never a credential or a profile name, so it can be committed.

Index

Constants

View Source
const (
	Dir  = ".pgedge"
	File = "link.yaml"
)

Dir and File name the link inside a project folder. `.pgedge` is shared with other pgEdge tools, so the CLI owns only File within it.

View Source
const ModuleManaged = "starfleet/managed"

ModuleManaged is the one Module value v1 writes.

Variables

View Source
var CommandPaths = map[string][]string{
	ModuleManaged: {"starfleet", "managed", "database", "env", "pull"},
}

CommandPaths maps a link's Module to the command path, under root, of that module's `env pull`. Root `pgedge env pull` dispatches on it.

Functions

func AddEnvPullFlags

func AddEnvPullFlags(flags *pflag.FlagSet)

AddEnvPullFlags declares env pull's flags. Root `pgedge env pull` and each module's own verb both call it, and the root copies every flag it was given onto the module's command, so the two forms cannot drift apart.

func IsHome

func IsHome(dir string) bool

IsHome reports whether dir is the user's home folder.

func Remove

func Remove(dir string) (bool, error)

Remove deletes the link in dir, and Dir with it when nothing else is left there. It reports whether a link existed.

func Write

func Write(dir string, l Link) (string, error)

Write stores l in dir/Dir/File through a temporary file in the same folder, so an interrupted write never leaves a truncated link.

Types

type Found

type Found struct {
	Link
	// Path is the link file; Root is the project folder holding Dir.
	Path string
	Root string
}

Found is a link and where it was read from.

func Find

func Find(start, home string) (*Found, error)

Find walks up from start to the nearest folder holding Dir/File. It stops after the first folder holding a .git entry, and never examines home itself: ~/.pgedge is the shared config root, not a project. A nil Found with a nil error means no link applies.

func Read

func Read(dir string) (*Found, error)

Read returns the link in dir itself, without walking up.

type Link struct {
	Module     string `yaml:"module"`
	DatabaseID string `yaml:"database_id"`
	BranchID   string `yaml:"branch_id,omitempty"`
}

Link is the file's content.

func (Link) Validate

func (l Link) Validate() error

Validate refuses a link naming an unknown module or a malformed ID, so a hand-edited file fails here rather than as an API 400.

Jump to

Keyboard shortcuts

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