Documentation
¶
Overview ¶
Package orbinit scaffolds a new orb project for "circleci orb init". It downloads the CircleCI Orb-Template repository, extracts it, rewrites the template placeholders, and initializes a local git repository. It performs no CircleCI API calls; the orb command layer owns those.
Index ¶
- func ApplyTemplate(orbPath, projectName, org, orbName, namespace string) error
- func CheckoutAlpha(w *git.Worktree) error
- func FetchTemplate(ctx context.Context, orbPath string) (err error)
- func InitRepo(orbPath, remoteURL, branch string) (*git.Repository, *git.Worktree, error)
- func IsRepo(orbPath string) bool
- func ProjectNameFromRemote(remoteURL string) string
- func RemovePrivateLicense(orbPath string) error
- func Substitute(contents, projectName, org, orbName, namespace string) string
- type ExistingRepo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyTemplate ¶
ApplyTemplate rewrites the placeholder tokens in every template file under orbPath with the given project details.
func CheckoutAlpha ¶
CheckoutAlpha creates and switches to the "alpha" branch.
func FetchTemplate ¶
FetchTemplate downloads the latest release of the orb template repository and extracts it into orbPath. The GitHub zipball nests everything under a top-level directory; that wrapper directory is stripped during extraction so the template lands directly in orbPath.
func InitRepo ¶
InitRepo prepares the git repository at orbPath for the orb's initial commit: it stages every file and commits. It returns the repository and its worktree.
An existing repository is adopted rather than refused. remoteURL and branch are only applied to what is missing — a repository that already has an origin keeps it, and one that already has commits keeps its current branch. Cloning an empty repository and initialising the orb into it is a reasonable way to work, and is the only way when repository creation is restricted to admins.
func ProjectNameFromRemote ¶
ProjectNameFromRemote derives a project name from a git remote URL by taking the last path segment and trimming any ".git" suffix.
func RemovePrivateLicense ¶
RemovePrivateLicense deletes the MIT LICENSE file from a private orb project. A missing file is not an error.
func Substitute ¶
Substitute replaces the orb template placeholder tokens in a file's contents.
Types ¶
type ExistingRepo ¶
type ExistingRepo struct {
// RemoteURL is origin's URL, empty if there is no origin remote.
RemoteURL string
// Branch is the checked-out branch, empty if HEAD cannot be resolved.
Branch string
}
ExistingRepo describes a git repository that is already present at the orb path. Both fields are best-effort: a freshly cloned empty repository has an origin but no commits, so no branch can be resolved from HEAD.
func InspectRepo ¶
func InspectRepo(orbPath string) (ExistingRepo, error)
InspectRepo reads what is already configured in the repository at orbPath, so orb init can adopt it instead of asking for details that are on disk.
Cloning an empty repository and running `orb init .` inside it is the obvious way to use this command when only admins may create repositories — and it is the case that used to dead-end.