projectref

package
v1.0.42868-pre Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package projectref reads and writes .circleci/info.yml — the per-checkout file that records which CircleCI project this directory is bound to.

It is consulted by slug-resolution code so that repository renames and non-VCS-derived slugs (e.g. standalone projects) work without forcing every caller to pass --project explicitly.

Index

Constants

View Source
const FilePath = ".circleci/info.yml"

FilePath is the path to the info file relative to the checkout root.

Variables

View Source
var ErrNotFound = errors.New("projectref: .circleci/info.yml not found")

ErrNotFound is returned by Read when no info file exists.

Functions

func Path

func Path(workDir string) string

Path returns the absolute path to the info file inside workDir.

func Write

func Write(workDir string, info *Info) error

Write serialises info to .circleci/info.yml inside workDir, creating the .circleci directory if needed.

Types

type Info

type Info struct {
	Organization Organization `yaml:"organization"`
	Project      Project      `yaml:"project"`
}

Info is the on-disk record written by `circleci project link`.

Schema:

organization:
  id: <uuid>          # required
  name: <string>      # optional, populated from API when available
project:
  id: <uuid>          # required
  slug: <string>      # required — VCS-style or canonical "circleci/<orgID>/<projectID>"
  name: <string>      # optional, populated from API when available

Project.Slug is always populated. Organization.ID and Project.ID are also populated when the slug was verified against the CircleCI API at link time; they let callers reference the project by its stable UUID even after a repo rename.

func Read

func Read(workDir string) (*Info, error)

Read parses .circleci/info.yml from workDir. Returns ErrNotFound if the file does not exist; other errors signal a malformed file or I/O failure.

func (*Info) EffectiveSlug

func (i *Info) EffectiveSlug() string

EffectiveSlug returns the slug to use when calling the CircleCI API. When both Project.ID and Organization.ID are known, the canonical "circleci/<orgID>/<projectID>" form is returned so the lookup is stable across VCS-side renames; otherwise the stored Project.Slug is returned as-is.

type Organization

type Organization struct {
	ID   string `yaml:"id,omitempty"`
	Name string `yaml:"name,omitempty"`
}

Organization is the CircleCI organization that owns the project.

type Project

type Project struct {
	ID   string `yaml:"id,omitempty"`
	Slug string `yaml:"slug"`
	Name string `yaml:"name,omitempty"`
}

Project identifies a CircleCI project.

Jump to

Keyboard shortcuts

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