Documentation
¶
Overview ¶
Package forgejoconn connects a CircleCI organization to a self-hosted Forgejo instance from the terminal, for onboarding.
There is no browser install: the user creates a bot user and two integrations in Forgejo, gives CircleCI their audiences, and once the connection is stored creates the webhook it answers with. Each value comes from a flag, else a prompt, else an error naming the flag, so the flow also runs unattended.
Index ¶
- Constants
- func Connect(ctx context.Context, client *apiclient.Client, orgID string, ...) (*apiclient.ForgejoConnection, error)
- func FindConnection(conns []apiclient.ProviderConnection) (apiclient.ProviderConnection, bool)
- func ParseHeaders(raw []string) (map[string]string, error)
- func ServesHost(providerURL, host string) bool
- type Options
Constants ¶
const MaxRequestHeaders = 10
MaxRequestHeaders is the most request headers a connection may carry.
const ProviderName = "forgejo"
ProviderName is Forgejo's name in the provider registry.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect( ctx context.Context, client *apiclient.Client, orgID string, remote gitremote.RemoteRef, opts Options, ) (*apiclient.ForgejoConnection, error)
Connect connects the organization orgID to the Forgejo instance the checkout's remote is on, prints the webhook the user has to create, and, when interactive, waits for them to create it.
A value the API rejects is asked for again when interactive; otherwise the error names the flag that supplies it.
func FindConnection ¶
func FindConnection(conns []apiclient.ProviderConnection) (apiclient.ProviderConnection, bool)
FindConnection returns the organization's Forgejo connection, if it has one.
func ParseHeaders ¶
ParseHeaders parses -H/--header values, each "Name: Value". Names and values are trimmed, a header needs both, and a name is given once.
func ServesHost ¶
ServesHost reports whether a connection to the instance at providerURL is the one a git remote on host belongs to. Ports are ignored: an ssh remote's port says nothing about the port the instance serves HTTP on.
Types ¶
type Options ¶
type Options struct {
// URL is the instance URL. Defaults to https://<the remote's host>.
URL string
// Owner is the Forgejo organization or user. Defaults to the remote's owner.
Owner string
ConnectionAudience string
CheckoutAudience string
// Headers are "Name: Value" request headers. Optional, and asked about only
// when interactive and none were passed.
Headers []string
}
Options are the values passed by flag. Any left empty is prompted for when the session is interactive.