Something went wrong. Try again.
Hands pods short-lived GitHub, Gitea, and atproto credentials for their ServiceAccount tokens
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384package v1alpha1
import ( "strings"
"github.com/liken-sh/liken/kubernetes/conditions" "github.com/liken-sh/liken/kubernetes/memo")
const ( // GitHubAppKind is the GitHubApp's kind. GitHubAppKind = "GitHubApp" // GitHubAppPlural is the GitHubApp's resource name. GitHubAppPlural = "githubapps")
// The reasons of a GitHubApp's Ready condition. A GiteaAccount's// condition has Accepted and Refused too.const ( // ReasonAccepted means GitHub accepted a statement signed with the // App's key, or Gitea accepted the account's password. ReasonAccepted = "Accepted" // ReasonKeyMissing means no Secret in lanyard's namespace holds the // key the App names. ReasonKeyMissing = "KeyMissing" // ReasonKeyInvalid means the Secret's value is not an RSA private key. ReasonKeyInvalid = "KeyInvalid" // ReasonRefused means GitHub refused a statement signed with the key, // as it does for a key that is not the App's or that was deleted, or // Gitea refused the account's password. ReasonRefused = "Refused" // ReasonAppUnknown means GitHub knows no App of the client ID. ReasonAppUnknown = "AppUnknown")
// GitHubApp is one GitHub App that lanyard makes tokens from. It is// cluster-scoped, and its name is the login of the user or organization// the App is installed on, in lower case.type GitHubApp struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` Metadata ObjectMeta `json:"metadata"` Spec GitHubAppSpec `json:"spec"` Status GitHubAppStatus `json:"status,omitzero"`}
// GetObjectMeta answers the App's metadata, so liken's informer reads// and memo can key and version it.func (a *GitHubApp) GetObjectMeta() memo.Meta { return &a.Metadata }
// GitHubAppSpec is what a person declares about the App.type GitHubAppSpec struct { // ClientID is the App's client ID, which names the App in each // statement lanyard signs. ClientID string `json:"clientID"` // PrivateKey is where the App's private key is. PrivateKey PrivateKey `json:"privateKey"`}
// PrivateKey names the App's private key.type PrivateKey struct { // SecretKeyRef is the key of a Secret in lanyard's own namespace // that holds the private key in PEM. SecretKeyRef SecretKeySelector `json:"secretKeyRef"`}
// GitHubAppStatus is what lanyard reports.type GitHubAppStatus struct { ObservedGeneration int64 `json:"observedGeneration,omitempty"` Conditions []conditions.Condition `json:"conditions,omitempty"` // Slug is the App's name in GitHub's addresses, which GitHub answers // once it accepts the key. Slug string `json:"slug,omitempty"`}
// GitHubAppName answers the name of the GitHubApp of an owner. GitHub// compares logins without regard to case, and an object's name is lower// case.func GitHubAppName(owner string) string { return strings.ToLower(owner) }
// GitHubAppPath answers the API path of one GitHubApp, or of the// collection when name is empty.func GitHubAppPath(name string) string { return path("", GitHubAppPlural, name) }