Skip to content

Commit

Permalink
feat: add initial support for mutiple deployment targets
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Sep 6, 2021
1 parent 7e953c6 commit c830b6e
Show file tree
Hide file tree
Showing 17 changed files with 1,348 additions and 347 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module github.com/amazeeio/lagoon

go 1.14
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ mutation PopulateApi {
input: {
id: 2001
name: "ci-local-control-k8s"
consoleUrl: "${CONSOLE_URL}" # make-host-docker-internal
routerPattern: "${project}.${environment}.${INGRESS_IP}.nip.io"
consoleUrl: "https://172.17.0.1:16643/" # make-host-docker-internal
routerPattern: "${project}.${environment}.172.17.0.1.nip.io"
sshHost: "172.17.0.1"
sshPort: "2020"
token: "${TOKEN}" # make-kubernetes-token
token: "eyJhbGciOiJSUzI1NiIsImtpZCI6IjZWamZLTzEzZ2lPSGFtc0d6QXVkWXpDYi1fcmlfLWVBd3JtbEEydGItTHcifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJsYWdvb24iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlY3JldC5uYW1lIjoia3ViZXJuZXRlc2J1aWxkZGVwbG95LXRva2VuLXJxNDg1Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Imt1YmVybmV0ZXNidWlsZGRlcGxveSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjA3YzViODAxLTI5ZDgtNDU5Ni1hODBlLTZlMmU3MmY3YmMwMCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpsYWdvb246a3ViZXJuZXRlc2J1aWxkZGVwbG95In0.srj-zZguNXCQbeTIS5GtJw7Jl61k_miC8hXED70NQULm6OAMkImHrURRCfD4kjKPy-jbwEI88m5TNLFP8_0sMfdwj2vr2Gv8fTC55qoAJ589ff_dwv8THSKdKNj6VaHynzEzQ4IfZscd3ogP4HYF9alt-X4mMcJ2BApBt4F13Hg-bE2-4uzO0b_u13pJhzn0XrH8JGXWP0_oMPtE7M0zJL9BfOrBph_MgSb2djSbVBNbhPJ0fs9-eIB5aAu0NmqPhpxj6WL4UOAKX178IsDAq4vtRZrScZwvZxRcaDUxZ-MgwewWI8Ll0yg7UCxtZTdkLglkCgpjTK33Ei0PXWdE4A" # make-kubernetes-token
}
) {
id
Expand Down
75 changes: 72 additions & 3 deletions node-packages/commons/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ export async function getEmailInfoForProject(
}

interface GetActiveSystemForProjectResult {
id: number;
branches: string;
pullrequests: string;
activeSystemsDeploy: string;
Expand All @@ -824,6 +825,7 @@ export async function getActiveSystemForProject(
const result = await graphqlapi.query(`
{
project:projectByName(name: "${project}"){
id
activeSystemsDeploy
activeSystemsPromote
activeSystemsRemove
Expand Down Expand Up @@ -975,21 +977,25 @@ export const addOrUpdateEnvironment = (
deployBaseRef: string,
environmentType: string,
openshiftProjectName: string,
openshift: number,
openshiftProjectPattern: string,
deployHeadRef: string = null,
deployTitle: string = null
): Promise<any> =>
graphqlapi.mutate(
`
($name: String!, $project: Int!, $deployType: DeployType!, $deployBaseRef: String!, $deployHeadRef: String, $deployTitle: String, $environmentType: EnvType!, $openshiftProjectName: String!) {
($name: String!, $project: Int!, $openshift: Int, $openshiftProjectPattern: String, $deployType: DeployType!, $deployBaseRef: String!, $deployHeadRef: String, $deployTitle: String, $environmentType: EnvType!, $openshiftProjectName: String!) {
addOrUpdateEnvironment(input: {
name: $name,
project: $project,
openshift: $openshift,
deployType: $deployType,
deployBaseRef: $deployBaseRef,
deployHeadRef: $deployHeadRef,
deployTitle: $deployTitle,
environmentType: $environmentType,
openshiftProjectName: $openshiftProjectName
openshiftProjectPattern: $openshiftProjectPattern
}) {
id
name
Expand All @@ -999,6 +1005,7 @@ export const addOrUpdateEnvironment = (
deployType
environmentType
openshiftProjectName
openshiftProjectPattern
envVariables {
name
value
Expand All @@ -1015,7 +1022,9 @@ export const addOrUpdateEnvironment = (
deployHeadRef,
deployTitle,
environmentType,
openshiftProjectName
openshiftProjectName,
openshift,
openshiftProjectPattern
}
);

Expand Down Expand Up @@ -1064,13 +1073,16 @@ export const getOpenShiftInfoForProject = (project: string): Promise<any> =>
project:projectByName(name: "${project}"){
id
openshift {
id
name
consoleUrl
token
projectUser
routerPattern
monitoringConfig
}
branches
pullrequests
availability
gitUrl
privateKey
Expand All @@ -1092,6 +1104,49 @@ export const getOpenShiftInfoForProject = (project: string): Promise<any> =>
}
`);

export const getDeployTargetConfigsForProject = (project: number): Promise<any> =>
graphqlapi.query(`
{
targets:deployTargetConfigsByProjectId(project: ${project}){
id
weight
branches
pullrequests
weight
deployTargetProjectPattern
deployTarget{
id
name
consoleUrl
token
projectUser
routerPattern
monitoringConfig
}
}
}
`);

export const getOpenShiftInfoForEnvironment = (environment: number): Promise<any> =>
graphqlapi.query(`
{
environment:environmentById(id: ${environment}){
id
name
openshiftProjectPattern
openshift {
id
name
consoleUrl
token
projectUser
routerPattern
monitoringConfig
}
}
}
`);

export const getBillingGroupForProject = (project: string): Promise<any> =>
graphqlapi.query(`
{
Expand All @@ -1108,10 +1163,14 @@ export const getBillingGroupForProject = (project: string): Promise<any> =>

interface GetEnvironentsForProjectEnvironmentResult {
name: string;
id: number;
environmentType: EnvType;
openshiftProjectPattern: string;
openshift: any;
}

interface GetEnvironentsForProjectProjectResult {
id: number;
developmentEnvironmentsLimit: number;
productionEnvironment: string;
standbyProductionEnvironment: string;
Expand All @@ -1128,10 +1187,20 @@ export const getEnvironmentsForProject = (
graphqlapi.query(`
{
project:projectByName(name: "${project}"){
id
developmentEnvironmentsLimit
productionEnvironment
standbyProductionEnvironment
environments(includeDeleted:false) { name, environmentType }
environments(includeDeleted:false) {
name
id
environmentType
openshiftProjectPattern
openshift{
id
name
}
}
}
}
`);
Expand Down
Loading

0 comments on commit c830b6e

Please sign in to comment.