Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bitbucket ¶
type Bitbucket interface { IsBitbucket() bool Setup() error SetupClient(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) // GetChangedFilesOnPullRequest returns the file paths and contents list of changed files, and the // head commit hash of the pull request source for which the files were obtained. GetChangedFilesOnPullRequest(ctx context.Context, pullRequestId int) ([]File, string, error) AddCommitBuildStatus(ctx context.Context, commitHash string, url string, key string, success bool) error CreatePullRequestComment(ctx context.Context, pullRequestId int, comment string) error }
type BitbucketUser ¶
type Cache ¶ added in v0.36.0
type Cache interface { IsCache() bool Setup() error // SetOwnerListTimestamp lets you set or update the timestamp for the last full scan of the list of aliases. SetOwnerListTimestamp(ctx context.Context, timestamp string) error // GetOwnerListTimestamp gives you the timestamp of the last full scan of the list of aliases. GetOwnerListTimestamp(ctx context.Context) (string, error) // GetSortedOwnerAliases gives you a time snapshot copy of the slice of sorted owner names. // // This means you won't mess up the cache if you work with it in any way. GetSortedOwnerAliases(ctx context.Context) ([]string, error) // GetOwner gives you a time snapshot deep copy of the owner information. // // This means you won't mess up the data in the cache if you work with it in any way. // // Requesting an owner that is not in the cache is an error. GetOwner(ctx context.Context, alias string) (openapi.OwnerDto, error) // PutOwner creates or replaces the owner cache entry. // // This is an atomic operation. PutOwner(ctx context.Context, alias string, entry openapi.OwnerDto) error // DeleteOwner deletes the owner cache entry. // // This is an atomic operation. DeleteOwner(ctx context.Context, alias string) error // SetServiceListTimestamp lets you set or update the timestamp for the last full scan of the list of names. SetServiceListTimestamp(ctx context.Context, timestamp string) error // GetServiceListTimestamp gives you the timestamp of the last full scan of the list of names. GetServiceListTimestamp(ctx context.Context) (string, error) // GetSortedServiceNames gives you a time snapshot copy of the slice of sorted service names. // // This means you won't mess up the cache if you work with it in any way. GetSortedServiceNames(ctx context.Context) ([]string, error) // GetService gives you a time snapshot deep copy of the service information. // // This means you won't mess up the data in the cache if you work with it in any way. // // Requesting a service that is not in the cache is an error. GetService(ctx context.Context, name string) (openapi.ServiceDto, error) // PutService creates or replaces the service cache entry. // // This is an atomic operation. PutService(ctx context.Context, name string, entry openapi.ServiceDto) error // DeleteService deletes the service cache entry. // // This is an atomic operation. DeleteService(ctx context.Context, name string) error // SetRepositoryListTimestamp lets you set or update the timestamp for the last full scan of the list of keys. SetRepositoryListTimestamp(ctx context.Context, timestamp string) error // GetRepositoryListTimestamp gives you the timestamp of the last full scan of the list of keys. GetRepositoryListTimestamp(ctx context.Context) (string, error) // GetSortedRepositoryKeys gives you a time snapshot copy of the slice of sorted repository names. // // This means you won't mess up the cache if you work with it in any way. GetSortedRepositoryKeys(ctx context.Context) ([]string, error) // GetRepository gives you a time snapshot deep copy of the repository information. // // This means you won't mess up the data in the cache if you work with it in any way. // // Requesting an repository that is not in the cache is an error. GetRepository(ctx context.Context, key string) (openapi.RepositoryDto, error) // PutRepository creates or replaces the repository cache entry. // // This is an atomic operation. PutRepository(ctx context.Context, key string, entry openapi.RepositoryDto) error // DeleteRepository deletes the repository cache entry. // // This is an atomic operation. DeleteRepository(ctx context.Context, key string) error }
Cache is the central in-memory metadata cache, present to speed up read access to the current metadata.
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 Setup() error // 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() error // SetupConnector uses the configuration to set up the connector SetupConnector(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 // Setup only connects the producer, the consumer is connected with StartReceiveLoop. Setup() error // Teardown will close both producer and consumer if they have been connected. Teardown() // 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 Setup() error Teardown() // 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 Notifier ¶ added in v0.32.0
type Notifier interface { IsNotifier() bool Setup() error SetupNotifier(ctx context.Context) error PublishCreation(ctx context.Context, payloadName string, payload openapi.NotificationPayload) error PublishModification(ctx context.Context, payloadName string, payload openapi.NotificationPayload) error PublishDeletion(ctx context.Context, payloadName string, payloadType types.NotificationPayloadType) }
type ReceiverCallback ¶
type ReceiverCallback func(event UpdateEvent)
type SshAuthProvider ¶
type SshAuthProvider interface { IsSshAuthProvider() bool Setup() error SetupProvider(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"` }