Documentation ¶
Overview ¶
Go functions that expose the Context-related calls in the GraphQL API.
Index ¶
- func AddOrRemoveOrbCategorization(cl *graphql.Client, namespace string, orb string, categoryName string, ...) error
- func OrbLatestVersion(cl *graphql.Client, namespace string, orb string) (string, error)
- func OrbSetOrbListStatus(cl *graphql.Client, namespace string, orb string, list bool) (*bool, error)
- func OrbSource(cl *graphql.Client, orbRef string) (string, error)
- type AddOrRemoveOrbCategorizationData
- type AddOrRemoveOrbCategorizationResponse
- type BuildConfigResponse
- type ConfigResponse
- type Context
- type ContextInterface
- type ContextRestClient
- func (c *ContextRestClient) ContextByName(vcs, org, name string) (*Context, error)
- func (c *ContextRestClient) Contexts(vcs, org string) (*[]Context, error)
- func (c *ContextRestClient) CreateContext(vcs, org, name string) error
- func (c *ContextRestClient) CreateEnvironmentVariable(contextID, variable, value string) error
- func (c *ContextRestClient) DeleteContext(contextID string) error
- func (c *ContextRestClient) DeleteEnvironmentVariable(contextID, variable string) error
- func (c *ContextRestClient) EnsureExists() error
- func (c *ContextRestClient) EnvironmentVariables(contextID string) (*[]EnvironmentVariable, error)
- type CreateNamespaceResponse
- type CreateOrbResponse
- type EnvironmentVariable
- type FollowedProject
- type GQLErrorsCollection
- type GQLResponseError
- type GetNamespaceResponse
- type GetOrganizationResponse
- type GraphQLContextClient
- func (c *GraphQLContextClient) ContextByName(vcs, org, name string) (*Context, error)
- func (c *GraphQLContextClient) Contexts(vcsType, orgName string) (*[]Context, error)
- func (c *GraphQLContextClient) CreateContext(vcsType, orgName, contextName string) error
- func (c *GraphQLContextClient) CreateEnvironmentVariable(contextId, variableName, secretValue string) error
- func (c *GraphQLContextClient) DeleteContext(contextId string) error
- func (c *GraphQLContextClient) DeleteEnvironmentVariable(contextId, variableName string) error
- func (c *GraphQLContextClient) EnvironmentVariables(contextID string) (*[]EnvironmentVariable, error)
- type IntrospectionResponse
- type NamespaceOrbResponse
- type Orb
- func OrbIncrementVersion(cl *graphql.Client, configPath string, namespace string, orb string, ...) (*Orb, error)
- func OrbPromote(cl *graphql.Client, namespace string, orb string, label string, segment string) (*Orb, error)
- func OrbPublishByID(cl *graphql.Client, configPath string, orbID string, orbVersion string) (*Orb, error)
- type OrbBase
- type OrbCategoriesForListing
- type OrbCategory
- type OrbCategoryIDResponse
- type OrbCategoryListResponse
- type OrbConfigResponse
- type OrbElement
- type OrbElementParameter
- type OrbIDResponse
- type OrbLatestVersionResponse
- type OrbListResponse
- type OrbPromoteResponse
- type OrbPublishResponse
- type OrbSetOrbListStatusResponse
- type OrbStatistics
- type OrbVersion
- type OrbWithData
- type OrbsForListing
- type RealOrbElement
- type UpdateOrbCategorizationRequestType
- type WhoamiResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddOrRemoveOrbCategorization ¶ added in v0.1.9399
func AddOrRemoveOrbCategorization(cl *graphql.Client, namespace string, orb string, categoryName string, updateType UpdateOrbCategorizationRequestType) error
AddOrRemoveOrbCategorization adds or removes an orb categorization
func OrbLatestVersion ¶ added in v0.1.1813
OrbLatestVersion finds the latest published version of an orb and returns it. If it doesn't find a version, it will return 0.0.0 for the orb's version
Types ¶
type AddOrRemoveOrbCategorizationData ¶ added in v0.1.9399
type AddOrRemoveOrbCategorizationData struct { CategoryId string OrbId string Errors GQLErrorsCollection }
type AddOrRemoveOrbCategorizationResponse ¶ added in v0.1.9399
type AddOrRemoveOrbCategorizationResponse map[string]AddOrRemoveOrbCategorizationData
AddOrRemoveOrbCategorizationResponse type matches the data shape of the GQL response for adding or removing an orb categorization
type BuildConfigResponse ¶ added in v0.1.2969
type BuildConfigResponse struct { BuildConfig struct { ConfigResponse } }
BuildConfigResponse wraps the GQL result of the ConfigQuery
type ConfigResponse ¶
type ConfigResponse struct { Valid bool SourceYaml string OutputYaml string Errors GQLErrorsCollection }
ConfigResponse is a structure that matches the result of the GQL query, so that we can use mapstructure to convert from nested maps to a strongly typed struct.
func ConfigQuery ¶
func ConfigQuery(cl *graphql.Client, configPath string, pipelineValues pipeline.Values) (*ConfigResponse, error)
ConfigQuery calls the GQL API to validate and process config
type Context ¶ added in v0.1.9321
type Context struct { CreatedAt time.Time `json:"created_at"` ID string `json:"id"` Name string `json:"name"` }
A Context is the owner of EnvironmentVariables.
type ContextInterface ¶ added in v0.1.9321
type ContextInterface interface { Contexts(vcs, org string) (*[]Context, error) ContextByName(vcs, org, name string) (*Context, error) DeleteContext(contextID string) error CreateContext(vcs, org, name string) error EnvironmentVariables(contextID string) (*[]EnvironmentVariable, error) CreateEnvironmentVariable(contextID, variable, value string) error DeleteEnvironmentVariable(contextID, variable string) error }
ContextInterface is the interface to interact with contexts and environment variables.
type ContextRestClient ¶ added in v0.1.9321
type ContextRestClient struct {
// contains filtered or unexported fields
}
ContextRestClient communicates with the CircleCI REST API to ask questions about contexts. It satisfies api.ContextInterface.
func NewContextRestClient ¶ added in v0.1.9321
func NewContextRestClient(host, endpoint, token string) (*ContextRestClient, error)
NewContextRestClient returns a new client satisfying the api.ContextInterface interface via the REST API.
func (*ContextRestClient) ContextByName ¶ added in v0.1.9321
func (c *ContextRestClient) ContextByName(vcs, org, name string) (*Context, error)
ContextByName finds a single context by its name and returns it.
func (*ContextRestClient) Contexts ¶ added in v0.1.9321
func (c *ContextRestClient) Contexts(vcs, org string) (*[]Context, error)
Contexts returns all of the contexts owned by the given org. Note that pagination is not currently supported - we get all pages of contexts and return them all.
func (*ContextRestClient) CreateContext ¶ added in v0.1.9321
func (c *ContextRestClient) CreateContext(vcs, org, name string) error
CreateContext creates a new context in the supplied organization.
func (*ContextRestClient) CreateEnvironmentVariable ¶ added in v0.1.9321
func (c *ContextRestClient) CreateEnvironmentVariable(contextID, variable, value string) error
CreateEnvironmentVariable creates OR UPDATES an environment variable.
func (*ContextRestClient) DeleteContext ¶ added in v0.1.9321
func (c *ContextRestClient) DeleteContext(contextID string) error
DeleteContext deletes the context with the given ID.
func (*ContextRestClient) DeleteEnvironmentVariable ¶ added in v0.1.9321
func (c *ContextRestClient) DeleteEnvironmentVariable(contextID, variable string) error
DeleteEnvironmentVariable deletes the environment variable in the context. It does not return an error if the environment variable did not exist.
func (*ContextRestClient) EnsureExists ¶ added in v0.1.9321
func (c *ContextRestClient) EnsureExists() error
EnsureExists verifies that the REST API exists and has the necessary endpoints to interact with contexts and env vars.
func (*ContextRestClient) EnvironmentVariables ¶ added in v0.1.9321
func (c *ContextRestClient) EnvironmentVariables(contextID string) (*[]EnvironmentVariable, error)
EnvironmentVariables returns all of the environment variables owned by the given context. Note that pagination is not currently supported - we get all pages of env vars and return them all.
type CreateNamespaceResponse ¶
type CreateNamespaceResponse struct { CreateNamespace struct { Namespace struct { CreatedAt string ID string } Errors GQLErrorsCollection } }
CreateNamespaceResponse type matches the data shape of the GQL response for creating a namespace
func CreateNamespace ¶
func CreateNamespace(cl *graphql.Client, name string, organizationName string, organizationVcs string) (*CreateNamespaceResponse, error)
CreateNamespace creates (reserves) a namespace for an organization
type CreateOrbResponse ¶
type CreateOrbResponse struct { CreateOrb struct { Orb Orb Errors GQLErrorsCollection } }
CreateOrbResponse type matches the data shape of the GQL response for creating an orb
type EnvironmentVariable ¶ added in v0.1.9321
An EnvironmentVariable has a Variable, a ContextID (its owner), and a CreatedAt date.
type FollowedProject ¶ added in v0.1.9988
func FollowProject ¶ added in v0.1.9988
func FollowProject(restEndpoint string, vcs string, owner string, projectName string, cciToken string) (FollowedProject, error)
FollowProject initiates an API request to follow a specific project on CircleCI. Project slugs are case-sensitive.
type GQLErrorsCollection ¶ added in v0.1.2969
type GQLErrorsCollection []GQLResponseError
GQLErrorsCollection is a slice of errors returned by the GraphQL server. Each error is made up of a GQLResponseError type.
func (GQLErrorsCollection) Error ¶ added in v0.1.2969
func (errs GQLErrorsCollection) Error() string
Error turns a GQLErrorsCollection into an acceptable error string that can be printed to the user.
type GQLResponseError ¶ added in v0.1.2969
type GQLResponseError struct { Message string Value string AllowedValues []string EnumType string Type string }
GQLResponseError is a mapping of the data returned by the GraphQL server of key-value pairs. Typically used with the structure "Message: string", but other response errors provide additional fields.
type GetNamespaceResponse ¶ added in v0.1.2969
type GetNamespaceResponse struct { RegistryNamespace struct { ID string } }
GetNamespaceResponse type wraps the GQL response for fetching a namespace
func GetNamespace ¶ added in v0.1.9988
func GetNamespace(cl *graphql.Client, name string) (*GetNamespaceResponse, error)
type GetOrganizationResponse ¶ added in v0.1.2969
type GetOrganizationResponse struct { Organization struct { ID string } }
GetOrganizationResponse type wraps the GQL response for fetching an organization and ID.
type GraphQLContextClient ¶ added in v0.1.9321
func NewContextGraphqlClient ¶ added in v0.1.9321
func NewContextGraphqlClient(host, endpoint, token string, debug bool) *GraphQLContextClient
NewContextGraphqlClient returns a new client satisfying the api.ContextInterface interface via the GraphQL API.
func (*GraphQLContextClient) ContextByName ¶ added in v0.1.9321
func (c *GraphQLContextClient) ContextByName(vcs, org, name string) (*Context, error)
ContextByName returns the Context in the given organization with the given name.
func (*GraphQLContextClient) Contexts ¶ added in v0.1.9321
func (c *GraphQLContextClient) Contexts(vcsType, orgName string) (*[]Context, error)
Contexts returns all of the Contexts owned by this organization.
func (*GraphQLContextClient) CreateContext ¶ added in v0.1.9321
func (c *GraphQLContextClient) CreateContext(vcsType, orgName, contextName string) error
CreateContext creates a new Context in the supplied organization.
func (*GraphQLContextClient) CreateEnvironmentVariable ¶ added in v0.1.9321
func (c *GraphQLContextClient) CreateEnvironmentVariable(contextId, variableName, secretValue string) error
CreateEnvironmentVariable creates a new environment variable in the given context. Note that the GraphQL API does not support upsert, so an error will be returned if the env var already exists.
func (*GraphQLContextClient) DeleteContext ¶ added in v0.1.9321
func (c *GraphQLContextClient) DeleteContext(contextId string) error
DeleteContext will delete the context with the given ID.
func (*GraphQLContextClient) DeleteEnvironmentVariable ¶ added in v0.1.9321
func (c *GraphQLContextClient) DeleteEnvironmentVariable(contextId, variableName string) error
DeleteEnvironmentVariable deletes the environment variable from the context. It returns an error if one occurred. It does not return an error if the environment variable did not exist.
func (*GraphQLContextClient) EnvironmentVariables ¶ added in v0.1.9321
func (c *GraphQLContextClient) EnvironmentVariables(contextID string) (*[]EnvironmentVariable, error)
EnvironmentVariables returns all of the environment variables in this context.
type IntrospectionResponse ¶ added in v0.1.2001
type IntrospectionResponse struct { Schema struct { MutationType struct { Name string } QueryType struct { Name string } Types []struct { Description string Fields []struct { Name string } Kind string Name string } } `json:"__schema"` }
IntrospectionResponse matches the result from making an introspection query
func IntrospectionQuery ¶ added in v0.1.2001
func IntrospectionQuery(cl *graphql.Client) (*IntrospectionResponse, error)
IntrospectionQuery makes a query on the API asking for bits of the schema This query isn't intended to get the entire schema, there are better tools for that.
type NamespaceOrbResponse ¶ added in v0.1.2969
type NamespaceOrbResponse struct { RegistryNamespace struct { Name string ID string Orbs struct { Edges []struct { Cursor string Node OrbWithData } TotalCount int PageInfo struct { HasNextPage bool } } } }
NamespaceOrbResponse type matches the result from GQL. So that we can use mapstructure to convert from nested maps to a strongly typed struct.
type Orb ¶ added in v0.1.1845
type Orb struct { ID string Name string Namespace string CreatedAt string Source string HighestVersion string `json:"version"` Statistics struct { Last30DaysBuildCount int Last30DaysProjectCount int Last30DaysOrganizationCount int } Commands map[string]OrbElement Jobs map[string]OrbElement Executors map[string]OrbElement Versions []OrbVersion Categories []OrbCategory }
Orb is a struct for containing the yaml-unmarshaled contents of an orb
func OrbIncrementVersion ¶ added in v0.1.1813
func OrbIncrementVersion(cl *graphql.Client, configPath string, namespace string, orb string, segment string) (*Orb, error)
OrbIncrementVersion accepts an orb and segment to increment the orb.
type OrbBase ¶ added in v0.1.4555
type OrbBase struct { Name string `json:"name"` HighestVersion string `json:"version"` Statistics OrbStatistics `json:"statistics"` Versions []struct { Version string `json:"version"` Source string `json:"source"` } `json:"versions"` }
OrbBase represents the minimum fields we wish to serialize for orbs. This type can be embedded for extending orbs with more data. e.g. OrbWithData
type OrbCategoriesForListing ¶ added in v0.1.9399
type OrbCategoriesForListing struct {
OrbCategories []OrbCategory `json:"orbCategories"`
}
OrbCategoriesForListing is a container type for multiple orb categories for deserializing back into JSON.
func ListOrbCategories ¶ added in v0.1.9399
func ListOrbCategories(cl *graphql.Client) (*OrbCategoriesForListing, error)
ListOrbCategories queries the API to find all categories. Returns a collection of OrbCategory objects containing their relevant data.
type OrbCategory ¶ added in v0.1.9399
type OrbCategoryIDResponse ¶ added in v0.1.9399
type OrbCategoryIDResponse struct { OrbCategoryByName struct { ID string } }
OrbCategoryIDResponse matches the GQL response for fetching an Orb category's id
func OrbCategoryID ¶ added in v0.1.9399
func OrbCategoryID(cl *graphql.Client, name string) (*OrbCategoryIDResponse, error)
OrbCategoryID fetches an orb returning the ID
type OrbCategoryListResponse ¶ added in v0.1.9399
type OrbCategoryListResponse struct { OrbCategories struct { TotalCount int Edges []struct { Cursor string Node OrbCategory } PageInfo struct { HasNextPage bool } } }
OrbCategoryListResponse type matches the result from GQL. So that we can use mapstructure to convert from nested maps to a strongly typed struct.
type OrbConfigResponse ¶ added in v0.1.2969
type OrbConfigResponse struct { OrbConfig struct { ConfigResponse } }
OrbConfigResponse wraps the GQL result for OrbQuery.
type OrbElement ¶ added in v0.1.3541
type OrbElement RealOrbElement
OrbElement implements RealOrbElement interface and allows us to deserialize by hand.
func (*OrbElement) UnmarshalYAML ¶ added in v0.1.4180
func (orbElement *OrbElement) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML method allows OrbElement to be a string or a map. For now, don't even try to dereference the string, just return what is essentially an empty OrbElement (no description or parameters)
type OrbElementParameter ¶ added in v0.1.3541
type OrbElementParameter struct { Description string `json:"-"` Type string `json:"-"` Default interface{} `json:"-"` }
OrbElementParameter represents the yaml-unmarshled contents of a parameter for a command/job/executor
type OrbIDResponse ¶ added in v0.1.2969
OrbIDResponse matches the GQL response for fetching an Orb and ID
type OrbLatestVersionResponse ¶ added in v0.1.2969
type OrbLatestVersionResponse struct { Orb struct { Versions []OrbVersion } }
OrbLatestVersionResponse wraps the GQL result of fetching an Orb and latest version
type OrbListResponse ¶ added in v0.1.2969
type OrbListResponse struct { Orbs struct { TotalCount int Edges []struct { Cursor string Node OrbWithData } PageInfo struct { HasNextPage bool } } }
OrbListResponse type matches the result from GQL. So that we can use mapstructure to convert from nested maps to a strongly typed struct.
type OrbPromoteResponse ¶ added in v0.1.1813
type OrbPromoteResponse struct { PromoteOrb struct { Orb Orb Errors GQLErrorsCollection } }
The OrbPromoteResponse type matches the data shape of the GQL response for promoting an orb.
type OrbPublishResponse ¶ added in v0.1.1813
type OrbPublishResponse struct { PublishOrb struct { Orb Orb Errors GQLErrorsCollection } }
The OrbPublishResponse type matches the data shape of the GQL response for publishing an orb.
type OrbSetOrbListStatusResponse ¶ added in v0.1.5879
type OrbSetOrbListStatusResponse struct { SetOrbListStatus struct { Listed bool Errors GQLErrorsCollection } }
The OrbSetOrbListStatusResponse type matches the data shape of the GQL response for setting the list status of an orb.
type OrbStatistics ¶ added in v0.1.4766
type OrbStatistics struct { Last30DaysBuildCount int `json:"last30DaysBuildCount"` Last30DaysProjectCount int `json:"last30DaysProjectCount"` Last30DaysOrganizationCount int `json:"last30DaysOrganizationCount"` }
OrbStatistics represents the data we retrieve for orb usage in the last thirty days.
type OrbVersion ¶ added in v0.1.2331
OrbVersion wraps the GQL result used by OrbSource and OrbInfo
type OrbWithData ¶ added in v0.1.3923
type OrbWithData struct { OrbBase Commands map[string]OrbElement Jobs map[string]OrbElement Executors map[string]OrbElement }
OrbWithData extends the OrbBase type with additional data used for printing.
func (OrbWithData) MarshalJSON ¶ added in v0.1.4555
func (orb OrbWithData) MarshalJSON() ([]byte, error)
MarshalJSON allows us to leave out excess fields we don't want to serialize. As is the case with commands/jobs/executors and now statistics.
type OrbsForListing ¶ added in v0.1.3923
type OrbsForListing struct { Orbs []OrbWithData `json:"orbs"` Namespace string `json:"namespace,omitempty"` }
OrbsForListing is a container type for multiple orbs that includes the namespace and orbs for deserializing back into JSON.
func ListNamespaceOrbs ¶ added in v0.1.1845
func ListNamespaceOrbs(cl *graphql.Client, namespace string) (*OrbsForListing, error)
ListNamespaceOrbs queries the API to find all orbs belonging to the given namespace. Returns a collection of Orb objects containing their relevant data.
func ListOrbs ¶ added in v0.1.2113
func ListOrbs(cl *graphql.Client, uncertified bool) (*OrbsForListing, error)
ListOrbs queries the API to find all orbs. Returns a collection of Orb objects containing their relevant data.
func (*OrbsForListing) SortBy ¶ added in v0.1.4555
func (orbs *OrbsForListing) SortBy(sortBy string)
SortBy allows us to sort a collection of orbs by builds, projects, or orgs from the last 30 days of data.
type RealOrbElement ¶ added in v0.1.4180
type RealOrbElement struct { Description string `json:"-"` Parameters map[string]OrbElementParameter `json:"-"` }
RealOrbElement represents the yaml-unmarshled contents of a named element under a command/job/executor
type UpdateOrbCategorizationRequestType ¶ added in v0.1.9399
type UpdateOrbCategorizationRequestType int
const ( Add UpdateOrbCategorizationRequestType = iota Remove )
type WhoamiResponse ¶ added in v0.1.2295
type WhoamiResponse struct { Me struct { Name string } }
WhoamiResponse type matches the data shape of the GQL response for the current user
func WhoamiQuery ¶ added in v0.1.2295
func WhoamiQuery(cl *graphql.Client) (*WhoamiResponse, error)
WhoamiQuery returns the result of querying the `/me` endpoint of the API