Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultExpirationTime defines the default expiration time for a GitHub App token // We set it to 3600 seconds (1 hour) to be sure the token is valid for the entire duration of the updatecli run DefaultExpirationTime int64 = 3600 // MinimumExpirationTime defines the minimum expiration time for a GitHub App token // We set it to 600 seconds (10 minutes) to be sure the token is valid for the entire duration of the updatecli run MinimumExpirationTime int64 = 600 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Spec ¶
type Spec struct {
// ClientID represents the GitHub App client ID
ClientID string `yaml:",omitempty"`
// PrivateKey represents a PEM encoded private key
// It is recommended to use PrivateKeyPath instead of PrivateKey
// to avoid putting sensitive information in the configuration file
// If both PrivateKey and PrivateKeyPath are set, PrivateKey takes precedence
PrivateKey string `yaml:",omitempty"`
// PrivateKeyPath represents the path to a PEM encoded private key
// If both PrivateKey and PrivateKeyPath are set, PrivateKey takes precedence
// It is recommended to use an environment variable to set the PrivateKeyPath value
// e.g. PrivateKeyPath: {{ requiredEnv "GITHUB_APP_PRIVATE_KEY_PATH" }}
// to avoid putting sensitive information in the configuration file
PrivateKeyPath string `yaml:",omitempty"`
// InstallationID represents the GitHub App installation ID
// It is the same ID that you can find in the GitHub endpoint:
// https://github.com/settings/installation/<ID>
InstallationID string `yaml:",omitempty"`
// Expiration represents the token expiration time in seconds
// The token is used during the entire execution of updatecli
// and should be valid for the entire duration of the run
// The minimum value is 600 seconds (10 minutes)
//
// Default: 3600 (1 hour)
ExpirationTime string `yaml:",omitempty"`
}
Spec defines the specification to authenticate with a GitHub App
func NewSpecFromEnv ¶
func NewSpecFromEnv() *Spec
NewSpecFromEnv creates a new Spec from environment variables It returns nil if the required environment variables are not set or if the configuration is invalid Required environment variables: - UPDATECLI_GITHUB_APP_CLIENT_ID - UPDATECLI_GITHUB_APP_PRIVATE_KEY or UPDATECLI_GITHUB_APP_PRIVATE_KEY_PATH - UPDATECLI_GITHUB_APP_INSTALLATION_ID
func (*Spec) Getoauth2TokenSource ¶
func (g *Spec) Getoauth2TokenSource() (oauth2.TokenSource, error)
Getoauth2TokenSource returns an oauth2.TokenSource to authenticate with GitHub using a GitHub App
Click to show internal directories.
Click to hide internal directories.