diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 3797b6941c..fad502c979 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1,5 +1,3 @@ -// @flow - const gql = require('./util/gql'); // TODO: Split up this file @@ -102,6 +100,7 @@ const typeDefs = gql` ZAR } + type File { id: Int filename: String @@ -163,16 +162,47 @@ const typeDefs = gql` billingSoftware: String } - type Openshift { + # Alpha - Kubernetes may have different fields - Just for discussion + type Kubernetes { id: Int - name: String - consoleUrl: String + name: String # Must be unique + # type: ClusterType + environments: [Environment] #namespaces + api: String token: String - routerPattern: String - projectUser: String - sshHost: String - sshPort: String + autoGeneratedIngressPattern: String + remoteShellHost: String + remoteShellPort: String created: String + + #NOTES: We need to teach people to use kubernetes even though it's an openshift + + # Can we derive these based on the Cluster Type, branch, name? + + customSettings: JSON + + # """ + # Which internal Lagoon System is responsible for deploying + # 'lagoon_kubernetesBuildDeploy' | 'lagoon_openshiftBuildDeploy' + # """ + + # # TODO - TURN TO ENUMS - convert to a single field + # activeSystemsDeploy: String + # """ + # Which internal Lagoon System is responsible for promoting + # 'lagoon_kubernetesBuildDeploy' | 'lagoon_openshiftBuildDeploy' + # """ + # activeSystemsPromote: String + # """ + # Which internal Lagoon System is responsible for promoting + # 'lagoon_kubernetesBuildDeploy' | 'lagoon_openshiftBuildDeploy' + # """ + # activeSystemsRemove: String + # """ + # Which internal Lagoon System is responsible for tasks + # 'lagoon_kubernetesBuildDeploy' | 'lagoon_openshiftBuildDeploy' + # """ + # activeSystemsTask: String } type NotificationMicrosoftTeams { @@ -209,6 +239,14 @@ const typeDefs = gql` union Notification = NotificationRocketChat | NotificationSlack | NotificationMicrosoftTeams | NotificationEmail + + type KubernetesEnvironmentMap { + environmentType: EnvironmentType + kubernetes: Kubernetes + } + + # Someday... would like to suppor one project deploy in multiple places (clusters) + """ Lagoon Project (like a git repository) """ @@ -250,26 +288,6 @@ const typeDefs = gql` """ notifications(type: NotificationType): [Notification] """ - Which internal Lagoon System is responsible for deploying - Currently only 'lagoon_openshiftBuildDeploy' exists - """ - activeSystemsDeploy: String - """ - Which internal Lagoon System is responsible for promoting - Currently only 'lagoon_openshiftBuildDeploy' exists - """ - activeSystemsPromote: String - """ - Which internal Lagoon System is responsible for promoting - Currently only 'lagoon_openshiftRemove' exists - """ - activeSystemsRemove: String - """ - Which internal Lagoon System is responsible for tasks - Currently only 'lagoon_openshiftJob' exists - """ - activeSystemsTask: String - """ Which branches should be deployed, can be one of: - \`true\` - all branches are deployed - \`false\` - no branches are deployed @@ -296,14 +314,16 @@ const typeDefs = gql` Should storage for this environment be calculated (\`1\` or \`0\`) """ storageCalc: Int + """ - Reference to OpenShift Object this Project should be deployed to + Environment > Cluster """ - openshift: Openshift + kubernetesMap: [KubernetesMap] + """ - Pattern of OpenShift Project/Namespace that should be generated, default: \`$\{project}-$\{environmentname}\` + Kubernetes Namespace pattern that should be generated, default: \`$\{project}-$\{environmentname}\` """ - openshiftProjectPattern: String + kubernetesNamespacePattern: String """ How many environments can be deployed at one timeout """ @@ -330,7 +350,7 @@ const typeDefs = gql` """ envVariables: [EnvKeyValue] """ - Which groups are directly linked to project + Groups linked to a project """ groups: [GroupInterface] } @@ -344,14 +364,22 @@ const typeDefs = gql` """ id: Int """ - Name of this Environment + Name of this Environment (not unique) """ name: String """ + Unique Name (auto generated) environmentName.projectName.kubernetesName (ex. pr-104.drupal-example.ch1.amazee.io) + """ + uniqueName: String + """ Reference to the Project Object """ project: Project """ + Reference to the Kubernetes Object + """ + kubernetes: Kubernetes + """ Which Deployment Type this environment is, can be \`branch\`, \`pullrequest\`, \`promote\` """ deployType: String @@ -374,9 +402,13 @@ const typeDefs = gql` """ Which Environment Type this environment is, can be \`production\`, \`development\` """ - environmentType: String + environmentType: EnvironmentType + """ + Kubernetes Namespace + """ + kubernetesNamespace: String """ - Name of the OpenShift Project/Namespace this environment is deployed into + (DEPRECATED as of 2.0) Name of the OpenShift Project/Namespace this environment is deployed into """ openshiftProjectName: String """ @@ -502,7 +534,9 @@ const typeDefs = gql` input DeleteEnvironmentInput { name: String! project: String! - execute: Boolean + execute: Boolean # TODO: change to two separate mutations + # Anywhere you can delete anything, change the execute thing + # Internal - deleteEnvironmentFromOpenshift } type Query { @@ -515,6 +549,10 @@ const typeDefs = gql` """ projectByName(name: String!): Project """ + Returns Project Object by a display name + """ + projectByDisplayName(name: String!): Project + """ Returns Group Object by a given name """ groupByName(name: String!): Group @@ -522,16 +560,16 @@ const typeDefs = gql` Returns Project Object by a given gitUrl (only the first one if there are multiple) """ projectByGitUrl(gitUrl: String!): Project + environmentById(name: String!, project: Int!): Environment + """ + Returns Environment Object by a given names + """ environmentByName(name: String!, project: Int!): Environment """ - Returns Environment Object by a given openshiftProjectName + Returns Environment Object by a Cluster Name """ - environmentByOpenshiftProjectName( - openshiftProjectName: String! - ): Environment - userCanSshToEnvironment( - openshiftProjectName: String - ): Environment + environmentsByClusterName(name: String!): [Environment] + userCanSshToEnvironment(deploymentTargetName: String): Environment deploymentByRemoteId(id: String): Deployment taskByRemoteId(id: String): Task """ @@ -541,7 +579,7 @@ const typeDefs = gql` """ Returns all OpenShift Objects """ - allOpenshifts: [Openshift] + allDeploymentTargets: [Openshift | Kubernetes] """ Returns all Environments matching given filter (all if no filter defined) """ @@ -605,8 +643,8 @@ const typeDefs = gql` name: String! gitUrl: String! subfolder: String - openshift: Int! - openshiftProjectPattern: String + deploymentTarget: DeploymentTarget + namespaceEnvironment: String activeSystemsDeploy: String activeSystemsPromote: String activeSystemsRemove: String @@ -630,7 +668,7 @@ const typeDefs = gql` deployHeadRef: String deployTitle: String environmentType: EnvType! - openshiftProjectName: String! + deploymentTargetName: String! } input AddOrUpdateEnvironmentStorageInput { @@ -741,7 +779,7 @@ const typeDefs = gql` patch: UpdateTaskPatchInput! } - input AddOpenshiftInput { + input AddDeploymentTargetInput { id: Int name: String! consoleUrl: String! @@ -752,7 +790,7 @@ const typeDefs = gql` sshPort: String } - input DeleteOpenshiftInput { + input DeleteDeploymentTargetInput { name: String! } @@ -847,8 +885,8 @@ const typeDefs = gql` autoIdle: Int storageCalc: Int pullrequests: String - openshift: Int - openshiftProjectPattern: String + deploymentTarget: DeploymentTarget + namespaceEnvironment: String developmentEnvironmentsLimit: Int } @@ -857,7 +895,7 @@ const typeDefs = gql` patch: UpdateProjectPatchInput! } - input UpdateOpenshiftPatchInput { + input UpdateDeploymentTargetPatchInput { name: String consoleUrl: String token: String @@ -867,9 +905,9 @@ const typeDefs = gql` sshPort: String } - input UpdateOpenshiftInput { + input UpdateDeploymentTargetInput { id: Int! - patch: UpdateOpenshiftPatchInput! + patch: UpdateDeploymentTargetPatchInput! } input UpdateNotificationMicrosoftTeamsPatchInput { @@ -931,7 +969,7 @@ const typeDefs = gql` deployHeadRef: String deployTitle: String environmentType: EnvType - openshiftProjectName: String + deploymentTargetName: String route: String routes: String monitoringUrls: String @@ -1120,10 +1158,10 @@ const typeDefs = gql` input: RemoveNotificationFromProjectInput! ): Project removeAllNotificationsFromAllProjects: String - addOpenshift(input: AddOpenshiftInput!): Openshift - updateOpenshift(input: UpdateOpenshiftInput!): Openshift - deleteOpenshift(input: DeleteOpenshiftInput!): String - deleteAllOpenshifts: String + addDeploymentTarget(input: AddDeploymentTargetInput!): DeploymentTarget + updateDeploymentTarget(input: UpdateDeploymentTargetInput!): DeploymentTarget + deleteDeploymentTarget(input: DeleteDeploymentTargetInput!): String + deleteAllDeploymentTargets: String addProject(input: AddProjectInput!): Project updateProject(input: UpdateProjectInput!): Project deleteProject(input: DeleteProjectInput!): String