From dcdd0e36f43e19643f7f9e3d4256a2b7508eb9a0 Mon Sep 17 00:00:00 2001 From: michaeljguarino Date: Thu, 4 Jul 2024 09:10:18 -0400 Subject: [PATCH] Schema refresh Have added some new graphql types that needs to be represented. --- models_gen.go | 85 ++++++++++++++++++++++++++++++++++++------- schema/schema.graphql | 76 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 13 deletions(-) diff --git a/models_gen.go b/models_gen.go index c727c64..834fe0a 100644 --- a/models_gen.go +++ b/models_gen.go @@ -1144,6 +1144,13 @@ type CrossVersionResourceTarget struct { Name *string `json:"name,omitempty"` } +type CustomRunStep struct { + Cmd string `json:"cmd"` + Args []*string `json:"args,omitempty"` + Stage StepStage `json:"stage"` + RequireApproval *bool `json:"requireApproval,omitempty"` +} + type CustomStackRun struct { ID string `json:"id"` // Name of the custom stack run @@ -1182,6 +1189,13 @@ type CustomStackRunEdge struct { Cursor *string `json:"cursor,omitempty"` } +type CustomStepAttributes struct { + Stage *StepStage `json:"stage,omitempty"` + Cmd string `json:"cmd"` + Args []*string `json:"args,omitempty"` + RequireApproval *bool `json:"requireApproval,omitempty"` +} + type DaemonSet struct { Metadata Metadata `json:"metadata"` Status DaemonSetStatus `json:"status"` @@ -1784,6 +1798,10 @@ type InfrastructureStack struct { Cluster *Cluster `json:"cluster,omitempty"` // the git repository you're sourcing IaC from Repository *GitRepository `json:"repository,omitempty"` + // the stack definition in-use by this stack + Definition *StackDefinition `json:"definition,omitempty"` + // a cron to spawn runs for this stack + Cron *StackCron `json:"cron,omitempty"` // the actor of this stack (defaults to root console user) Actor *User `json:"actor,omitempty"` CustomStackRuns *CustomStackRunConnection `json:"customStackRuns,omitempty"` @@ -3531,16 +3549,17 @@ type RunLogsDelta struct { } type RunStep struct { - ID string `json:"id"` - Status StepStatus `json:"status"` - Stage StepStage `json:"stage"` - Name string `json:"name"` - Cmd string `json:"cmd"` - Args []string `json:"args,omitempty"` - Index int64 `json:"index"` - Logs []*RunLogs `json:"logs,omitempty"` - InsertedAt *string `json:"insertedAt,omitempty"` - UpdatedAt *string `json:"updatedAt,omitempty"` + ID string `json:"id"` + Status StepStatus `json:"status"` + Stage StepStage `json:"stage"` + Name string `json:"name"` + Cmd string `json:"cmd"` + Args []string `json:"args,omitempty"` + RequireApproval *bool `json:"requireApproval,omitempty"` + Index int64 `json:"index"` + Logs []*RunLogs `json:"logs,omitempty"` + InsertedAt *string `json:"insertedAt,omitempty"` + UpdatedAt *string `json:"updatedAt,omitempty"` } type RunStepAttributes struct { @@ -4149,7 +4168,11 @@ type StackAttributes struct { // the project id this stack will belong to ProjectID *string `json:"projectId,omitempty"` // id of an scm connection to use for pr callbacks - ConnectionID *string `json:"connectionId,omitempty"` + ConnectionID *string `json:"connectionId,omitempty"` + // the id of a stack definition to use + DefinitionID *string `json:"definitionId,omitempty"` + // a cron to spawn runs for this stack + Cron *StackCronAttributes `json:"cron,omitempty"` ReadBindings []*PolicyBindingAttributes `json:"readBindings,omitempty"` WriteBindings []*PolicyBindingAttributes `json:"writeBindings,omitempty"` Tags []*TagAttributes `json:"tags,omitempty"` @@ -4189,6 +4212,37 @@ type StackConfigurationAttributes struct { Hooks []*StackHookAttributes `json:"hooks,omitempty"` } +type StackCron struct { + // the crontab used to independently spawn runs for this stack + Crontab string `json:"crontab"` + // whether you want any cron-derived runs to automatically approve changes + AutoApprove *bool `json:"autoApprove,omitempty"` +} + +type StackCronAttributes struct { + // the crontab to use for spawning stack runs + Crontab string `json:"crontab"` + // whether you want to auto approve any changes spawned by the cron worker + AutoApprove *bool `json:"autoApprove,omitempty"` +} + +type StackDefinition struct { + ID string `json:"id"` + Name string `json:"name"` + Description *string `json:"description,omitempty"` + Configuration StackConfiguration `json:"configuration"` + Steps []*CustomRunStep `json:"steps,omitempty"` + InsertedAt *string `json:"insertedAt,omitempty"` + UpdatedAt *string `json:"updatedAt,omitempty"` +} + +type StackDefinitionAttributes struct { + Name string `json:"name"` + Description *string `json:"description,omitempty"` + Steps []*CustomStepAttributes `json:"steps,omitempty"` + Configuration *StackConfigurationAttributes `json:"configuration,omitempty"` +} + type StackEnvironment struct { Name string `json:"name"` Value string `json:"value"` @@ -4437,12 +4491,15 @@ type StatusCondition struct { // Advanced configuration of how to sync resources type SyncConfig struct { // whether the agent should auto-create the namespace for this service - CreateNamespace *bool `json:"createNamespace,omitempty"` + CreateNamespace *bool `json:"createNamespace,omitempty"` + // Whether to require all resources are placed in the same namespace + EnforceNamespace *bool `json:"enforceNamespace,omitempty"` NamespaceMetadata *NamespaceMetadata `json:"namespaceMetadata,omitempty"` } type SyncConfigAttributes struct { CreateNamespace *bool `json:"createNamespace,omitempty"` + EnforceNamespace *bool `json:"enforceNamespace,omitempty"` NamespaceMetadata *MetadataAttributes `json:"namespaceMetadata,omitempty"` } @@ -6156,16 +6213,18 @@ type StackType string const ( StackTypeTerraform StackType = "TERRAFORM" StackTypeAnsible StackType = "ANSIBLE" + StackTypeCustom StackType = "CUSTOM" ) var AllStackType = []StackType{ StackTypeTerraform, StackTypeAnsible, + StackTypeCustom, } func (e StackType) IsValid() bool { switch e { - case StackTypeTerraform, StackTypeAnsible: + case StackTypeTerraform, StackTypeAnsible, StackTypeCustom: return true } return false diff --git a/schema/schema.graphql b/schema/schema.graphql index dae32d1..97d493a 100644 --- a/schema/schema.graphql +++ b/schema/schema.graphql @@ -364,6 +364,8 @@ type RootQueryType { infrastructureStack(id: ID!): InfrastructureStack + stackDefinition(id: ID!): StackDefinition + infrastructureStacks(after: String, first: Int, before: String, last: Int, q: String, projectId: ID): InfrastructureStackConnection observabilityProvider(id: ID!): ObservabilityProvider @@ -743,9 +745,18 @@ type RootMutationType { deleteCustomStackRun(id: ID!): CustomStackRun + createStackDefinition(attributes: StackDefinitionAttributes!): StackDefinition + + updateStackDefinition(id: ID!, attributes: StackDefinitionAttributes!): StackDefinition + + deleteStackDefinition(id: ID!): StackDefinition + "Creates a custom run, with the given command list, to execute w\/in the stack's environment" onDemandRun(stackId: ID!, commands: [CommandAttributes], context: Json): StackRun + "start a new run from the newest sha in the stack's run history" + triggerRun(id: ID!): StackRun + upsertObservabilityProvider(attributes: ObservabilityProviderAttributes!): ObservabilityProvider deleteObservabilityProvider(id: ID!): ObservabilityProvider @@ -1020,6 +1031,7 @@ enum StackStatus { enum StackType { TERRAFORM ANSIBLE + CUSTOM } enum StepStatus { @@ -1077,6 +1089,12 @@ input StackAttributes { "id of an scm connection to use for pr callbacks" connectionId: ID + "the id of a stack definition to use" + definitionId: ID + + "a cron to spawn runs for this stack" + cron: StackCronAttributes + readBindings: [PolicyBindingAttributes] writeBindings: [PolicyBindingAttributes] @@ -1115,6 +1133,14 @@ input StackHookAttributes { afterStage: StepStage! } +input StackCronAttributes { + "the crontab to use for spawning stack runs" + crontab: String! + + "whether you want to auto approve any changes spawned by the cron worker" + autoApprove: Boolean +} + input StackRunAttributes { "The status of this run" status: StackStatus! @@ -1205,6 +1231,20 @@ input CommandAttributes { dir: String } +input StackDefinitionAttributes { + name: String! + description: String + steps: [CustomStepAttributes] + configuration: StackConfigurationAttributes +} + +input CustomStepAttributes { + stage: StepStage + cmd: String! + args: [String] + requireApproval: Boolean +} + type InfrastructureStack { id: ID @@ -1275,6 +1315,12 @@ type InfrastructureStack { "the git repository you're sourcing IaC from" repository: GitRepository + "the stack definition in-use by this stack" + definition: StackDefinition + + "a cron to spawn runs for this stack" + cron: StackCron + "the actor of this stack (defaults to root console user)" actor: User @@ -1292,6 +1338,14 @@ type InfrastructureStack { updatedAt: DateTime } +type StackCron { + "the crontab used to independently spawn runs for this stack" + crontab: String! + + "whether you want any cron-derived runs to automatically approve changes" + autoApprove: Boolean +} + "grab-bag of state configuration urls for supported tools" type StateUrls { terraform: TerraformStateUrls @@ -1435,6 +1489,7 @@ type RunStep { name: String! cmd: String! args: [String!] + requireApproval: Boolean index: Int! logs: [RunLogs] insertedAt: DateTime @@ -1510,6 +1565,23 @@ type CustomStackRun { updatedAt: DateTime } +type StackDefinition { + id: ID! + name: String! + description: String + configuration: StackConfiguration! + steps: [CustomRunStep] + insertedAt: DateTime + updatedAt: DateTime +} + +type CustomRunStep { + cmd: String! + args: [String] + stage: StepStage! + requireApproval: Boolean +} + type StackCommand { "the executable to call" cmd: String! @@ -2672,6 +2744,7 @@ input ServiceImportAttributes { input SyncConfigAttributes { createNamespace: Boolean + enforceNamespace: Boolean namespaceMetadata: MetadataAttributes } @@ -3105,6 +3178,9 @@ type SyncConfig { "whether the agent should auto-create the namespace for this service" createNamespace: Boolean + "Whether to require all resources are placed in the same namespace" + enforceNamespace: Boolean + namespaceMetadata: NamespaceMetadata }