Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pluralsh/console-client-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.80
Choose a base ref
...
head repository: pluralsh/console-client-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.0.81
Choose a head ref
  • 2 commits
  • 6 files changed
  • 2 contributors

Commits on Jan 29, 2024

  1. update schema

    maciaszczykm committed Jan 29, 2024
    Copy the full SHA
    f0760d1 View commit details

Commits on Jan 30, 2024

  1. add backup/restore

    zreigz committed Jan 30, 2024
    Copy the full SHA
    399c4bd View commit details
Showing with 872 additions and 46 deletions.
  1. +168 −0 client.go
  2. +5 −5 example/main.go
  3. +24 −0 graph/backup.graphql
  4. +12 −0 graph/models.graphql
  5. +406 −37 models_gen.go
  6. +257 −4 schema/schema.graphql
168 changes: 168 additions & 0 deletions client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions example/main.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ type authedTransport struct {
}

func (t *authedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Set("Authorization", "Bearer "+t.key)
req.Header.Set("Authorization", "Token "+t.key)
return t.wrapped.RoundTrip(req)
}

@@ -28,19 +28,19 @@ func main() {
}
}()

key := "PASTE YOUR KEY HERE FROM https://app.plural.sh/profile/tokens"
key := "deploy-h89xne0p2efknbud7n26nzc2rym9anhwppj3mifwrc2bzyiafe"

httpClient := http.Client{
Transport: &authedTransport{
key: key,
wrapped: http.DefaultTransport,
},
}
graphqlClient := gqlclient.NewClient(&httpClient, "https://app.plural.sh/gql")
meResp, err := graphqlClient.MyCluster(context.Background())
graphqlClient := gqlclient.NewClient(&httpClient, "https://console.cdaws.onplural.sh/gql/ext")
meResp, err := graphqlClient.ListClusterRestore(context.Background(), "daa2b5f7-a0e7-4e11-896a-6e5389b3d8aa")
if err != nil {
return
}
fmt.Println("my cluster", meResp.MyCluster.Name)
fmt.Println("my cluster", meResp)

}
24 changes: 24 additions & 0 deletions graph/backup.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
mutation CreateClusterBackup($attributes: BackupAttributes!) {
createClusterBackup(attributes: $attributes) {
... ClusterBackupFragment
}
}

mutation UpdateClusterRestore($id: ID!, $attributes: RestoreAttributes!) {
updateClusterRestore(id: $id, attributes: $attributes) {
... ClusterRestoreFragment
}
}

mutation CreateClusterRestore($backupId: ID!) {
createClusterRestore(backupId: $backupId) {
... ClusterRestoreFragment
}
}

query GetClusterRestore($id: ID!) {
clusterRestore(id: $id) {
... ClusterRestoreFragment
}
}

12 changes: 12 additions & 0 deletions graph/models.graphql
Original file line number Diff line number Diff line change
@@ -310,4 +310,16 @@ fragment GlobalServiceFragment on GlobalService {
provider { id }
service { id }
tags { ...ClusterTags }
}

fragment ClusterBackupFragment on ClusterBackup {
id
name
cluster { id }
}

fragment ClusterRestoreFragment on ClusterRestore {
id
status
backup { ... ClusterBackupFragment}
}
443 changes: 406 additions & 37 deletions models_gen.go

Large diffs are not rendered by default.

261 changes: 257 additions & 4 deletions schema/schema.graphql
Original file line number Diff line number Diff line change
@@ -171,19 +171,21 @@ type RootQueryType {

scmConnections(after: String, first: Int, before: String, last: Int): ScmConnectionConnection

scmConnection(id: ID!): ScmConnection
scmConnection(id: ID, name: String): ScmConnection

prAutomations(after: String, first: Int, before: String, last: Int): PrAutomationConnection

prAutomation(id: ID!): PrAutomation
prAutomation(id: ID, name: String): PrAutomation

pullRequests(after: String, first: Int, before: String, last: Int, clusterId: ID, serviceId: ID): PullRequestConnection

"exchanges a kubeconfig token for user info"
tokenExchange(token: String!): User

"a relay connection of all clusters visible to the current user"
clusters(after: String, first: Int, before: String, last: Int, q: String, healthy: Boolean, tag: TagInput): ClusterConnection
clusters(
after: String, first: Int, before: String, last: Int, q: String, healthy: Boolean, tag: TagInput, tagQuery: TagQuery
): ClusterConnection

"gets summary information for all healthy\/unhealthy clusters in your fleet"
clusterStatuses(q: String, tag: TagInput): [ClusterStatusInfo]
@@ -246,10 +248,14 @@ type RootQueryType {

globalService(id: ID!): GlobalService

serviceContext(name: String!): ServiceContext

pipelines(after: String, first: Int, before: String, last: Int): PipelineConnection

pipeline(id: ID!): Pipeline

objectStores(after: String, first: Int, before: String, last: Int): ObjectStoreConnection

"the services deployed in the current cluster, to be polled by the deploy operator"
clusterServices: [ServiceDeployment]

@@ -268,6 +274,10 @@ type RootQueryType {

clusterGates: [PipelineGate]

clusterGate(id: ID!): PipelineGate

clusterRestore(id: ID!): ClusterRestore

deploymentSettings: DeploymentSettings
}

@@ -385,6 +395,9 @@ type RootMutationType {
context: Json
): PullRequest

"just registers a pointer record to a PR after it was created externally be some other automation"
createPullRequestPointer(attributes: PullRequestAttributes): PullRequest

createCluster(attributes: ClusterAttributes!): Cluster

updateCluster(id: ID!, attributes: ClusterUpdateAttributes!): Cluster
@@ -430,6 +443,9 @@ type RootMutationType {

deleteServiceDeployment(id: ID!): ServiceDeployment

"removes a service from storage, but bypasses waiting for the agent to fully drain it from its hosting cluster"
detachServiceDeployment(id: ID!): ServiceDeployment

"merges configuration for a service"
mergeService(id: ID!, configuration: [ConfigAttributes]): ServiceDeployment

@@ -488,6 +504,10 @@ type RootMutationType {

deleteGlobalService(id: ID!): GlobalService

saveServiceContext(name: String!, attributes: ServiceContextAttributes!): ServiceContext

deleteServiceContext(id: ID!): ServiceContext

"upserts a pipeline with a given name"
savePipeline(name: String!, attributes: PipelineAttributes!): Pipeline

@@ -497,7 +517,15 @@ type RootMutationType {
approveGate(id: ID!): PipelineGate

"forces a pipeline gate to be in open state"
forceGate(id: ID!): PipelineGate
forceGate(id: ID!, state: GateState): PipelineGate

createObjectStore(attributes: ObjectStoreAttributes!): ObjectStore

updateObjectStore(id: ID!, attributes: ObjectStoreAttributes!): ObjectStore

deleteObjectStore(id: ID!): ObjectStore

createClusterRestore(backupId: ID!): ClusterRestore

"a regular status ping to be sent by the deploy operator"
pingCluster(attributes: ClusterPing!): Cluster
@@ -510,6 +538,10 @@ type RootMutationType {

updateGate(id: ID!, attributes: GateUpdateAttributes!): PipelineGate

createClusterBackup(attributes: BackupAttributes!): ClusterBackup

updateClusterRestore(id: ID!, attributes: RestoreAttributes!): ClusterRestore

"a reusable mutation for updating rbac settings on core services"
updateRbac(rbac: RbacAttributes!, serviceId: ID, clusterId: ID, providerId: ID): Boolean

@@ -625,6 +657,102 @@ input RbacAttributes {
writeBindings: [PolicyBindingAttributes]
}

enum RestoreStatus {
CREATED
PENDING
SUCCESSFUL
FAILED
}

input ObjectStoreAttributes {
name: String!
s3: S3StoreAttributes
gcs: GcsStoreAttributes
azure: AzureStoreAttributes
}

input BackupAttributes {
name: String!
}

input RestoreAttributes {
status: RestoreStatus!
}

input S3StoreAttributes {
bucket: String!
region: String
endpoint: String
accessKeyId: String!
secretAccessKey: String!
}

input GcsStoreAttributes {
bucket: String!
region: String!
applicationCredentials: String!
}

input AzureStoreAttributes {
storageAccount: String!
container: String!
subscriptionId: String!
tenantId: String!
clientId: String!
clientSecret: String!
}

type ObjectStore {
id: ID!
name: String!
s3: S3Store
gcs: GcsStore
azure: AzureStore
insertedAt: DateTime
updatedAt: DateTime
}

type ClusterBackup {
id: ID!
name: String!
cluster: Cluster
insertedAt: DateTime
updatedAt: DateTime
}

type ClusterRestore {
id: ID!
status: RestoreStatus!
backup: ClusterBackup
insertedAt: DateTime
updatedAt: DateTime
}

type S3Store {
bucket: String!
region: String
endpoint: String
accessKeyId: String!
}

type GcsStore {
bucket: String!
region: String!
}

type AzureStore {
storageAccount: String!
container: String!
subscriptionId: String!
tenantId: String!
clientId: String!
}

type ObjectStoreConnection {
pageInfo: PageInfo!
edges: [ObjectStoreEdge]
}

enum GateState {
PENDING
OPEN
@@ -1000,6 +1128,7 @@ input ServiceDeploymentAttributes {
configuration: [ConfigAttributes]
readBindings: [PolicyBindingAttributes]
writeBindings: [PolicyBindingAttributes]
contextBindings: [ContextBindingAttributes]
}

input SyncConfigAttributes {
@@ -1037,6 +1166,9 @@ input ServiceUpdateAttributes {
helm: HelmConfigAttributes
configuration: [ConfigAttributes]
kustomize: KustomizeAttributes
readBindings: [PolicyBindingAttributes]
writeBindings: [PolicyBindingAttributes]
contextBindings: [ContextBindingAttributes]
}

input ServiceCloneAttributes {
@@ -1079,6 +1211,17 @@ input ServiceErrorAttributes {
message: String!
}

"A reusable configuration context, useful for plumbing data from external tools like terraform\/pulumi\/etc"
input ServiceContextAttributes {
configuration: Json
secrets: [ConfigAttributes]
}

"a binding from a service to a service context"
input ContextBindingAttributes {
contextId: String!
}

"A reference for a globalized service, which targets clusters based on the configured criteria"
input GlobalServiceAttributes {
"name for this global service"
@@ -1190,6 +1333,9 @@ type ServiceDeployment {
"whether this service is controlled by a global service"
owner: GlobalService

"bound contexts for this service"
contexts: [ServiceContext]

"a relay connection of all revisions of this service, these are periodically pruned up to a history limit"
revisions(after: String, first: Int, before: String, last: Int): RevisionConnection

@@ -1402,6 +1548,16 @@ type NamespaceMetadata {
annotations: Map
}

"A reusable bundle of configuration designed to make it easy to communicate between tools like tf\/pulumi and k8s"
type ServiceContext {
id: ID!
name: String!
configuration: Map
secrets: [ServiceConfiguration]
insertedAt: DateTime
updatedAt: DateTime
}

type ServiceDeploymentConnection {
pageInfo: PageInfo!
edges: [ServiceDeploymentEdge]
@@ -1421,6 +1577,11 @@ enum ClusterDistro {
K3S
}

enum Conjunction {
AND
OR
}

input ClusterAttributes {
name: String!

@@ -1601,6 +1762,11 @@ input TagInput {
value: String!
}

input TagQuery {
op: Conjunction!
tags: [TagInput]
}

"a CAPI provider for a cluster, cloud is inferred from name if not provided manually"
type ClusterProvider {
"the id of this provider"
@@ -1729,6 +1895,9 @@ type Cluster {
"a custom git repository if you want to define your own CAPI manifests"
repository: GitRepository

"pr automations that are relevant to managing this cluster"
prAutomations: [PrAutomation]

"list cached nodes for a cluster, this can be stale up to 5m"
nodes: [Node]

@@ -2025,6 +2194,28 @@ enum MatchStrategy {
RECURSIVE
}

enum ConfigurationType {
STRING
INT
BOOL
DOMAIN
BUCKET
FILE
FUNCTION
PASSWORD
}

enum Operation {
NOT
GT
LT
EQ
GTE
LTE
PREFIX
SUFFIX
}

input GitAttributes {
"the url of this repository"
url: String!
@@ -2090,22 +2281,68 @@ input PrAutomationAttributes {
"the scm connection to use for pr generation"
connectionId: ID

configuration: [PrConfigurationAttributes]

"users who can update this automation"
writeBindings: [PolicyBindingAttributes]

"users who can create prs with this automation"
createBindings: [PolicyBindingAttributes]
}

"the a configuration item for creating a new pr"
input PrConfigurationAttributes {
type: ConfigurationType!
name: String!
default: String
documentation: String
longform: String
placeholder: String
optional: Boolean
condition: ConditionAttributes
}

"attributes for declaratively specifying whether a config item is relevant given prior config"
input ConditionAttributes {
operation: Operation!
field: String!
value: String
}

"The operations to be performed on the files w\/in the pr"
input PrAutomationUpdateSpecAttributes {
regexes: [String]

"list of regex scope replacement templates, useful for ANY strategies"
regexReplacements: [RegexReplacementAttributes]

files: [String]

replaceTemplate: String

yq: String

matchStrategy: MatchStrategy
}

"a fully specify regex\/replace flow"
input RegexReplacementAttributes {
regex: String!
replacement: String!
}

"attributes for a pull request pointer record"
input PullRequestAttributes {
url: String!
title: String!
creator: String
labels: [String]
serviceId: ID
clusterId: ID
service: NamespacedName
cluster: NamespacedName
}

"a git repository available for deployments"
type GitRepository {
"internal id of this repository"
@@ -2263,12 +2500,21 @@ type PrAutomation {
"existing file updates that can be performed in a PR"
type PrUpdateSpec {
regexes: [String]
regexReplacements: [RegexReplacement]
files: [String]
replaceTemplate: String
yq: String
matchStrategy: MatchStrategy
}

"a fully specified regex\/replace flow"
type RegexReplacement {
regex: String!

"template string to replace any match with"
replacement: String!
}

"A reference to a pull request for your kubernetes related IaC"
type PullRequest {
id: ID!
@@ -2277,6 +2523,8 @@ type PullRequest {

title: String

labels: [String]

"the cluster this pr is meant to modify"
cluster: Cluster

@@ -4001,3 +4249,8 @@ type PipelineEdge {
node: Pipeline
cursor: String
}

type ObjectStoreEdge {
node: ObjectStore
cursor: String
}