Documentation ¶
Index ¶
Constants ¶
const BitbucketAcornName = "bitbucket"
const HostIPAcornName = "hostip"
const IdentityProviderAcornName = "idp"
const KafkaAcornName = "kafka"
const MetadataAcornName = "metadata"
const SshAuthProviderAcornName = "SshAuthProvider"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bitbucket ¶ added in v0.16.0
type Bitbucket interface { IsBitbucket() bool Setup(ctx context.Context) error GetBitbucketUser(ctx context.Context, username string) (BitbucketUser, error) GetBitbucketUsers(ctx context.Context, usernames []string) ([]BitbucketUser, error) FilterExistingUsernames(ctx context.Context, usernames []string) ([]string, error) }
type BitbucketUser ¶ added in v0.16.0
type CommitInfo ¶
type CommitInfo struct { CommitHash string TimeStamp time.Time Message string FilesChanged []string }
CommitInfo holds information about a commit.
type EventAffects ¶
type HostIP ¶
type HostIP interface { IsHostIP() bool // ObtainLocalIp gets the first non-localhost ipv4 address from your interfaces. // // In a k8s deployment, that'll be the pod ip. ObtainLocalIp() (net.IP, error) }
HostIP interacts with the local network interfaces.
type IdentityProvider ¶
type IdentityProvider interface { IsIdentityProvider() bool // Setup uses the configuration to set up Setup(ctx context.Context) error // ObtainKeySet calls the key set endpoint and converts the keys to PEM for use with the jwt package ObtainKeySet(ctx context.Context) error // GetKeySet returns the previously obtained KeySet GetKeySet(ctx context.Context) []string // VerifyToken ensures synchronously that a token has not been revoked and the account is current. // // You should do this for critical operations that cannot live with the usual token // expiry cycle. VerifyToken(ctx context.Context, token string) error }
IdentityProvider is the central singleton representing an Open ID Connect Identity Provider.
We use this to obtain a JWT keyset and to check its id endpoint to synchronously validate JWT tokens.
type Kafka ¶
type Kafka interface { IsKafka() bool // SubscribeIncoming allows you to register a callback that is called whenever a message is received from the Kafka bus. // // Note, we currently only allow a single callback, so calling this multiple times will overwrite the callback. // Use this during application setup. SubscribeIncoming(ctx context.Context, callback ReceiverCallback) error // Send sends an UpdateEvent that originates in this application to the Kafka bus. Send(ctx context.Context, event UpdateEvent) error // StartReceiveLoop starts a background goroutine that calls the subscribed callback when messages come in StartReceiveLoop(ctx context.Context) error }
Kafka is the central singleton representing the kafka messaging bus.
type Metadata ¶
type Metadata interface { IsMetadata() bool // Clone performs an initial in-memory clone of the metadata repository on the mainline Clone(ctx context.Context) error // Pull updates the in-memory clone of the metadata repository on the mainline // // Any new commits that were not previously seen can now be obtained by NewPulledCommits. Pull(ctx context.Context) error // Commit performs a local add all and commit and returns the commit hash and the timestamp // // note: if this fails, the repository may be in an inconsistent state, so you should // Discard and Clone it again. Commit(ctx context.Context, message string) (CommitInfo, error) // Push sends commits from the in-memory clone to the upstream Push(ctx context.Context) error // Discard the in-memory clone (cannot fail, but will leave memory allocated until garbage collection) // // note: doing a new Clone implicitly discards Discard(ctx context.Context) // LastUpdated gives the time the git repo was last pulled (or pushed, which also ensures it is up-to-date). LastUpdated() time.Time // NewPulledCommits gives the business logic access to information about the newly pulled commits. // // The list is available until the next call to Pull, which clears it and adds any new commits. NewPulledCommits() []CommitInfo // IsCommitKnown is true if the given commit has been cloned, pulled or locally committed, meaning, // a Pull would not generate new information if this commit hash is in the pull. IsCommitKnown(hash string) bool Stat(filename string) (os.FileInfo, error) ReadDir(path string) ([]os.FileInfo, error) // ReadFile returns the contents of a file, the commit hash, timestamp and message for the last change to the file ReadFile(filename string) ([]byte, CommitInfo, error) // WriteFile creates or overwrites a file in the local copy WriteFile(filename string, contents []byte) error // DeleteFile deletes a file in the local copy DeleteFile(filename string) error // Mkdir creates a new directory (and potentially all directories leading up to it). Does nothing if already exists. MkdirAll(path string) error }
Metadata is the central singleton representing the service-metadata git repository.
All operations are protected by a mutex, but of course this does not prevent multiple goroutines from making changes between operations, so you will probably need a higher level mutex to avoid inadvertently committing changes made by another goroutine.
type ReceiverCallback ¶
type ReceiverCallback func(event UpdateEvent)
type SshAuthProvider ¶ added in v0.23.0
type SshAuthProvider interface { IsSshAuthProvider() bool Setup(ctx context.Context) error ProvideSshAuth(ctx context.Context) (*ssh.PublicKeys, error) }
SshAuthProvider is an SshAuthProvider business logic component.
type UpdateEvent ¶
type UpdateEvent struct { Affected EventAffects `json:"affected"` // ISO-8601 UTC date time at which this information was committed. TimeStamp string `json:"timeStamp"` // The git commit hash this information was committed under. CommitHash string `json:"commitHash"` }