Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harness.io integration #787

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions backend/src/integrations/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
INTEGRATION_GITHUB,
INTEGRATION_GITLAB,
INTEGRATION_GITLAB_API_URL,
INTEGRATION_HARNESS,
INTEGRATION_HARNESS_API_URL,
INTEGRATION_HEROKU,
INTEGRATION_HEROKU_API_URL,
INTEGRATION_LARAVELFORGE,
Expand Down Expand Up @@ -176,6 +178,11 @@ const getApps = async ({
accessToken,
});
break;
case INTEGRATION_HARNESS:
apps = await getAppsHarness({
accessToken,
});
break;
}

return apps;
Expand Down Expand Up @@ -957,4 +964,48 @@ const getAppsCloud66 = async ({ accessToken }: { accessToken: string }) => {
return apps;
};


/**
* Return list of applications for Cloud66 integration
* @param {Object} obj
* @param {String} obj.accessToken - personal access token for Cloud66 API
* @returns {Object[]} apps - Cloud66 apps
* @returns {String} apps.name - name of Cloud66 app
* @returns {String} apps.appId - uid of Cloud66 app
*/
const getAppsHarness = async ({ accessToken }: { accessToken: string }) => {
interface HarnessApp {
project: {
orgIdentifier: string;
identifier: string;
name: string;
color: string;
modules: string[];
description: string;
tags: any;
};
createdAt: number;
lastModifiedAt: number;
isFavorite: boolean;
}

const projects = (
await standardRequest.get(`${INTEGRATION_HARNESS_API_URL}/ng/api/projects`, {
headers: {
"x-api-key": accessToken,
"Accept-Encoding": "application/json"
}
})
).data.data.content as HarnessApp[];

const apps = projects.map((app) => ({
name: app.project.name,
appId: app.project.identifier,
organizationId: app.project.orgIdentifier
}));


return apps;
};

export { getApps };
41 changes: 41 additions & 0 deletions backend/src/integrations/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import {
INTEGRATION_GITHUB,
INTEGRATION_GITLAB,
INTEGRATION_GITLAB_API_URL,
INTEGRATION_HARNESS,
INTEGRATION_HARNESS_API_URL,
INTEGRATION_HASHICORP_VAULT,
INTEGRATION_HEROKU,
INTEGRATION_HEROKU_API_URL,
Expand Down Expand Up @@ -238,6 +240,13 @@ const syncSecrets = async ({
accessToken
});
break;
case INTEGRATION_HARNESS:
await syncSecretsHarness({
integration,
secrets,
accessToken
});
break;
}
};

Expand Down Expand Up @@ -2257,4 +2266,36 @@ const syncSecretsCloud66 = async ({
}
};

/**
* Sync/push [secrets] to Cloud66 application with name [integration.app]
* @param {Object} obj
* @param {IIntegration} obj.integration - integration details
* @param {IIntegrationAuth} obj.integrationAuth - integration auth details
* @param {Object} obj.secrets - secrets to push to integration (object where keys are secret keys and values are secret values)
* @param {String} obj.accessToken - access token for Cloud66 integration
*/
const syncSecretsHarness = async ({
integration,
secrets,
accessToken
}: {
integration: IIntegration;
secrets: any;
accessToken: string;
}) => {

// get all current secrets
const res = (
await standardRequest.get(
`${INTEGRATION_HARNESS_API_URL}/v1/orgs/default/projects/${integration.appId}/secrets`,
{
headers: {
"x-api-key": accessToken,
Accept: "application/json"
}
}
)
).data;
};

export { syncSecrets };
39 changes: 21 additions & 18 deletions backend/src/models/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
INTEGRATION_FLYIO,
INTEGRATION_GITHUB,
INTEGRATION_GITLAB,
INTEGRATION_HARNESS,
INTEGRATION_HASHICORP_VAULT,
INTEGRATION_HEROKU,
INTEGRATION_LARAVELFORGE,
Expand Down Expand Up @@ -63,6 +64,7 @@ export interface IIntegration {
| "codefresh"
| "digital-ocean-app-platform"
| "cloud-66"
| "harness";
integrationAuth: Types.ObjectId;
}

Expand All @@ -71,65 +73,65 @@ const integrationSchema = new Schema<IIntegration>(
workspace: {
type: Schema.Types.ObjectId,
ref: "Workspace",
required: true,
required: true
},
environment: {
type: String,
required: true,
required: true
},
isActive: {
type: Boolean,
required: true,
required: true
},
url: {
// for custom self-hosted integrations (e.g. self-hosted GitHub enterprise)
type: String,
default: null,
default: null
},
app: {
// name of app in provider
type: String,
default: null,
default: null
},
appId: {
// id of app in provider
type: String,
default: null,
default: null
},
targetEnvironment: {
// target environment
type: String,
default: null,
default: null
},
targetEnvironmentId: {
type: String,
default: null,
default: null
},
targetService: {
// railway-specific service
type: String,
default: null,
default: null
},
targetServiceId: {
// railway-specific service
type: String,
default: null,
default: null
},
owner: {
// github-specific repo owner-login
type: String,
default: null,
default: null
},
path: {
// aws-parameter-store-specific path
// (also) vercel preview-branch
type: String,
default: null,
default: null
},
region: {
// aws-parameter-store-specific path
type: String,
default: null,
default: null
},
integration: {
type: String,
Expand All @@ -156,22 +158,23 @@ const integrationSchema = new Schema<IIntegration>(
INTEGRATION_DIGITAL_OCEAN_APP_PLATFORM,
INTEGRATION_CODEFRESH,
INTEGRATION_CLOUD_66,
INTEGRATION_HARNESS
],
required: true,
required: true
},
integrationAuth: {
type: Schema.Types.ObjectId,
ref: "IntegrationAuth",
required: true,
required: true
},
secretPath: {
type: String,
required: true,
default: "/",
},
default: "/"
}
},
{
timestamps: true,
timestamps: true
}
);

Expand Down
3 changes: 3 additions & 0 deletions backend/src/models/integrationAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
INTEGRATION_FLYIO,
INTEGRATION_GITHUB,
INTEGRATION_GITLAB,
INTEGRATION_HARNESS,
INTEGRATION_HASHICORP_VAULT,
INTEGRATION_HEROKU,
INTEGRATION_LARAVELFORGE,
Expand Down Expand Up @@ -50,6 +51,7 @@ export interface IIntegrationAuth extends Document {
| "codefresh"
| "digital-ocean-app-platform"
| "bitbucket"
| "harness"
| "cloud-66";
teamId: string;
accountId: string;
Expand Down Expand Up @@ -100,6 +102,7 @@ const integrationAuthSchema = new Schema<IIntegrationAuth>(
INTEGRATION_DIGITAL_OCEAN_APP_PLATFORM,
INTEGRATION_CODEFRESH,
INTEGRATION_CLOUD_66,
INTEGRATION_HARNESS,
],
required: true,
},
Expand Down
14 changes: 13 additions & 1 deletion backend/src/variables/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const INTEGRATION_BITBUCKET = "bitbucket";
export const INTEGRATION_CODEFRESH = "codefresh";
export const INTEGRATION_DIGITAL_OCEAN_APP_PLATFORM = "digital-ocean-app-platform";
export const INTEGRATION_CLOUD_66 = "cloud-66";
export const INTEGRATION_HARNESS = "harness";
export const INTEGRATION_SET = new Set([
INTEGRATION_AZURE_KEY_VAULT,
INTEGRATION_HEROKU,
Expand All @@ -50,7 +51,8 @@ export const INTEGRATION_SET = new Set([
INTEGRATION_BITBUCKET,
INTEGRATION_DIGITAL_OCEAN_APP_PLATFORM,
INTEGRATION_CODEFRESH,
INTEGRATION_CLOUD_66
INTEGRATION_CLOUD_66,
INTEGRATION_HARNESS,
]);

// integration types
Expand Down Expand Up @@ -85,6 +87,7 @@ export const INTEGRATION_BITBUCKET_API_URL = "https://api.bitbucket.org";
export const INTEGRATION_CODEFRESH_API_URL = "https://g.codefresh.io/api";
export const INTEGRATION_DIGITAL_OCEAN_API_URL = "https://api.digitalocean.com";
export const INTEGRATION_CLOUD_66_API_URL = "https://app.cloud66.com/api";
export const INTEGRATION_HARNESS_API_URL = "https://app.harness.io";

export const getIntegrationOptions = async () => {
const INTEGRATION_OPTIONS = [
Expand Down Expand Up @@ -296,6 +299,15 @@ export const getIntegrationOptions = async () => {
clientId: "",
docsLink: "",
},
{
name: "Harness",
slug: "harness",
image: "Harness.png",
isAvailable: true,
type: "pat",
clientId: "",
docsLink: "",
},
]

return INTEGRATION_OPTIONS;
Expand Down
3 changes: 2 additions & 1 deletion frontend/public/data/frequentConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const integrationSlugNameMapping: Mapping = {
"codefresh": "Codefresh",
"digital-ocean-app-platform": "Digital Ocean App Platform",
bitbucket: "BitBucket",
"cloud-66": "Cloud 66"
"cloud-66": "Cloud 66",
harness: "Harness",
};

const envMapping: Mapping = {
Expand Down
Binary file added frontend/public/images/integrations/Harness.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const onboardingCheck = async ({
const orgUsers = await getOrganizationUsers({
orgId: orgId || ""
});
if (orgUsers.length > 1) {
if (orgUsers?.length > 1) {
countActions += 1;
}
if (setUsersInOrg) setUsersInOrg(orgUsers.length > 1);
Expand Down
Loading