api

package
v0.1.2969 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2018 License: MIT Imports: 14 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvEndpointHost added in v0.1.1430

func EnvEndpointHost() (string, string)

EnvEndpointHost pulls the endpoint and host values from viper

func GraphQLServerAddress added in v0.1.1418

func GraphQLServerAddress(endpoint string, host string) (string, error)

GraphQLServerAddress returns the full address to CircleCI GraphQL API server

func OrbLatestVersion added in v0.1.1813

func OrbLatestVersion(ctx context.Context, logger *logger.Logger, namespace string, orb string) (string, error)

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

func OrbSource

func OrbSource(ctx context.Context, logger *logger.Logger, orbRef string) (string, error)

OrbSource gets the source or an orb

Types

type BuildConfigResponse added in v0.1.2969

type BuildConfigResponse struct {
	Data 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(ctx context.Context, logger *logger.Logger, configPath string) (*ConfigResponse, error)

ConfigQuery calls the GQL API to validate and process config

func OrbQuery

func OrbQuery(ctx context.Context, logger *logger.Logger, configPath string) (*ConfigResponse, error)

OrbQuery validated and processes an orb.

type CreateNamespaceResponse

type CreateNamespaceResponse struct {
	Data struct {
		CreateNamespace struct {
			Namespace struct {
				CreatedAt string
				ID        string
			}

			Errors GQLErrorsCollection
		}
	}

	Errors GQLErrorsCollection
}

CreateNamespaceResponse type matches the data shape of the GQL response for creating a namespace

func CreateNamespace

func CreateNamespace(ctx context.Context, logger *logger.Logger, name string, organizationName string, organizationVcs string) (*CreateNamespaceResponse, error)

CreateNamespace creates (reserves) a namespace for an organization

type CreateOrbResponse

type CreateOrbResponse struct {
	Data struct {
		CreateOrb struct {
			Orb    Orb
			Errors GQLErrorsCollection
		}
	}

	Errors GQLErrorsCollection
}

CreateOrbResponse type matches the data shape of the GQL response for creating an orb

func CreateOrb

func CreateOrb(ctx context.Context, logger *logger.Logger, namespace string, name string) (*CreateOrbResponse, error)

CreateOrb creates (reserves) an orb within a namespace

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 {
	Data struct {
		RegistryNamespace struct {
			ID string
		}
	}

	Errors GQLErrorsCollection
}

GetNamespaceResponse type wraps the GQL response for fetching a namespace

type GetOrganizationResponse added in v0.1.2969

type GetOrganizationResponse struct {
	Data struct {
		Organization struct {
			ID string
		}
	}

	Errors GQLErrorsCollection
}

GetOrganizationResponse type wraps the GQL response for fetching an organization and ID.

type IntrospectionResponse added in v0.1.2001

type IntrospectionResponse struct {
	Data 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(ctx context.Context, logger *logger.Logger) (*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 {
	Data struct {
		RegistryNamespace struct {
			Name string
			Orbs struct {
				Edges []struct {
					Cursor string
					Node   struct {
						Name     string
						Versions []struct {
							Version string
							Source  string
						}
					}
				}
				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 `json:"-"`
	Name      string `json:"name"`
	Namespace string `json:"-"`
	CreatedAt string `json:"-"`

	Source string `json:"-"`
	// Avoid "Version" since there is a "version" key in the orb source referring
	// to the orb schema version
	HighestVersion string              `json:"version"`
	Version        string              `json:"-"`
	Commands       map[string]struct{} `json:"-"`
	Jobs           map[string]struct{} `json:"-"`
	Executors      map[string]struct{} `json:"-"`
	Versions       []OrbVersion        `json:"versions"`
}

Orb is a struct for containing the yaml-unmarshaled contents of an orb

func OrbIncrementVersion added in v0.1.1813

func OrbIncrementVersion(ctx context.Context, logger *logger.Logger, configPath string, namespace string, orb string, segment string) (*Orb, error)

OrbIncrementVersion accepts an orb and segment to increment the orb.

func OrbPromote added in v0.1.1813

func OrbPromote(ctx context.Context, logger *logger.Logger, namespace string, orb string, label string, segment string) (*Orb, error)

OrbPromote takes an orb and a development version and increments a semantic release with the given segment.

func OrbPublishByID added in v0.1.1813

func OrbPublishByID(ctx context.Context, logger *logger.Logger,
	configPath string, orbID string, orbVersion string) (*Orb, error)

OrbPublishByID publishes a new version of an orb by id

func (Orb) String added in v0.1.1845

func (orb Orb) String() string

String returns a text representation of the Orb contents, intended for direct human use rather than machine use. This function will exclude orb source and orbs without any versions in its returned string.

type OrbCollection added in v0.1.2331

type OrbCollection struct {
	Orbs      []Orb  `json:"orbs"`
	Namespace string `json:"namespace,omitempty"`
}

OrbCollection is a container type for multiple orbs to share formatting functions on them.

func ListNamespaceOrbs added in v0.1.1845

func ListNamespaceOrbs(ctx context.Context, logger *logger.Logger, namespace string) (*OrbCollection, error)

ListNamespaceOrbs queries the API to find all orbs belonging to the given namespace. Returns a collection of Orb objects containing their relevant data. Logs request and parse errors to the supplied logger.

func ListOrbs added in v0.1.2113

func ListOrbs(ctx context.Context, logger *logger.Logger, uncertified bool) (*OrbCollection, error)

ListOrbs queries the API to find all orbs. Returns a collection of Orb objects containing their relevant data. Logs request and parse errors to the supplied logger.

func (OrbCollection) String added in v0.1.2331

func (orbCollection OrbCollection) String() string

String returns a text representation of all Orbs, intended for direct human use rather than machine use.

type OrbConfigResponse added in v0.1.2969

type OrbConfigResponse struct {
	Data struct {
		OrbConfig struct {
			ConfigResponse
		}
	}
}

OrbConfigResponse wraps the GQL result for OrbQuery.

type OrbIDResponse added in v0.1.2969

type OrbIDResponse struct {
	Data struct {
		Orb struct {
			ID string
		}
		RegistryNamespace struct {
			ID string
		}
	}
}

OrbIDResponse matches the GQL response for fetching an Orb and ID

func OrbID added in v0.1.1813

func OrbID(ctx context.Context, logger *logger.Logger, namespace string, orb string) (*OrbIDResponse, error)

OrbID fetches an orb returning the ID

type OrbLatestVersionResponse added in v0.1.2969

type OrbLatestVersionResponse struct {
	Data struct {
		Orb struct {
			Versions []struct {
				Version string
			}
		}
	}
}

OrbLatestVersionResponse wraps the GQL result of fetching an Orb and latest version

type OrbListResponse added in v0.1.2969

type OrbListResponse struct {
	Data struct {
		Orbs struct {
			TotalCount int
			Edges      []struct {
				Cursor string
				Node   struct {
					Name     string
					Versions []struct {
						Version string
						Source  string
					}
				}
			}
			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 {
	Data 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 {
	Data struct {
		PublishOrb struct {
			Orb Orb

			Errors GQLErrorsCollection
		}
	}
}

The OrbPublishResponse type matches the data shape of the GQL response for publishing an orb.

type OrbSourceResponse added in v0.1.2969

type OrbSourceResponse struct {
	Data struct {
		OrbVersion struct {
			ID      string
			Version string
			Orb     struct {
				ID string
			}
			Source string
		}
	}
}

OrbSourceResponse wraps the GQL result used by OrbSource

type OrbVersion added in v0.1.2331

type OrbVersion struct {
	Version string `json:"version"`
	Source  string `json:"source"`
}

OrbVersion represents a single orb version and its source

type WhoamiResponse added in v0.1.2295

type WhoamiResponse struct {
	Data struct {
		Me struct {
			Name string
		}
	}

	Errors GQLErrorsCollection
}

WhoamiResponse type matches the data shape of the GQL response for the current user

func WhoamiQuery added in v0.1.2295

func WhoamiQuery(ctx context.Context, logger *logger.Logger) (*WhoamiResponse, error)

WhoamiQuery returns the result of querying the `/me` endpoint of the API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL