Documentation ¶
Index ¶
- Constants
- Variables
- func Client(atlasDomain string, connection Connection, log *zap.SugaredLogger) (mongodbatlas.Client, error)
- func DefaultListOptions(pageNum int) *mongodbatlas.ListOptions
- func TraversePages(reader PageReader, predicate PageItemPredicate) error
- type Connection
- type PageItemPredicate
- type PageReader
- type Paginated
Constants ¶
const ( // Error codes that Atlas may return that we are concerned about GroupExistsAPIErrorCode = "GROUP_ALREADY_EXISTS" // The error that Atlas API returns if the GET request is sent to read the project that either doesn't exist // or the user doesn't have permissions for NotInGroup = "NOT_IN_GROUP" // Error indicates that the project is being removed while it still has clusters CannotCloseGroupActiveAtlasCluster = "CANNOT_CLOSE_GROUP_ACTIVE_ATLAS_CLUSTERS" // Error indicates that the database user doesn't exist UsernameNotFound = "USERNAME_NOT_FOUND" // Error indicates that the cluster doesn't exist ClusterNotFound = "CLUSTER_NOT_FOUND" )
Variables ¶
var ProductVersion = "unknown"
ProductVersion is used for sending the current Operator version in the User-Agent string
Functions ¶
func Client ¶
func Client(atlasDomain string, connection Connection, log *zap.SugaredLogger) (mongodbatlas.Client, error)
Client is the central place to create a client for Atlas using specified API keys and a server URL. Note, that the default HTTP transport is reused globally by Go so all caching, keep-alive etc will be in action.
func DefaultListOptions ¶
func DefaultListOptions(pageNum int) *mongodbatlas.ListOptions
func TraversePages ¶
func TraversePages(reader PageReader, predicate PageItemPredicate) error
TraversePages reads page after page using 'reader' and applies the 'predicate' for each item on the page. Stops traversal when the 'predicate' returns true.
Types ¶
type Connection ¶
Connection encapsulates Atlas connectivity information that is necessary to perform API requests
func ReadConnection ¶
func ReadConnection(log *zap.SugaredLogger, kubeClient client.Client, operatorAPISecret client.ObjectKey, projectOverrideSecretRef *client.ObjectKey) (Connection, error)
ReadConnection reads Atlas API connection parameters from AtlasProject Secret or from the default Operator one if the former is not specified
type PageItemPredicate ¶
type PageItemPredicate func(entity interface{}) bool
PageItemPredicate is the function that processes single item on the page and returns true if no further processing needs to be done (usually it's the search logic)
type PageReader ¶
PageReader is the function that reads a single page by its number
type Paginated ¶
type Paginated interface { // HasNext returns if there are more pages HasNext() bool // Results returns the list of entities on a single page Results() []interface{} }
Paginated is the general interface for a single page returned by Atlas api.
func NewAtlasPaginated ¶
func NewAtlasPaginated(response *mongodbatlas.Response, entities interface{}) Paginated