Skip to content
Permalink
Browse files

Remove atomist webhook handling from generators

This will now be handled by the installed rcca packs

[changelog:removed]
  • Loading branch information...
cdupuis committed Feb 3, 2019
1 parent 62eabc3 commit 498bc1c3f0c5c3b4c4fe970ad503c41611e33462
@@ -44,7 +44,6 @@ export function createCommand<PARAMS = NoParameters>(
const description = details.description || name;
const detailsToUse: CommandDetails = {
description,
intent: `do ${name}`,
...details,
};

@@ -15,8 +15,6 @@
*/

import {
addAtomistWebhook,
GitProject,
HandlerContext,
Maker,
OnCommand,
@@ -33,7 +31,6 @@ import { HandleCommand } from "@atomist/automation-client/lib/HandleCommand";
import { RedirectResult } from "@atomist/automation-client/lib/HandlerResult";
import { commandHandlerFrom } from "@atomist/automation-client/lib/onCommand";
import { CommandDetails } from "@atomist/automation-client/lib/operations/CommandDetails";
import { isGitHubRepoRef } from "@atomist/automation-client/lib/operations/common/GitHubRepoRef";
import { ProjectAction } from "@atomist/automation-client/lib/operations/common/projectAction";
import { isRemoteRepoRef } from "@atomist/automation-client/lib/operations/common/RepoId";
import { RepoLoader } from "@atomist/automation-client/lib/operations/common/repoLoader";
@@ -119,7 +116,6 @@ export function toGeneratorParametersMaker<PARAMS>(paramsMaker: Maker<PARAMS>,
const rawParms: PARAMS = toFactory(paramsMaker)();
const allParms = rawParms as SeedDrivenGeneratorParameters & PARAMS;
allParms.target = target;
allParms.addAtomistWebhook = allParms.addAtomistWebhook || false;
return allParms;
};
}
@@ -163,12 +159,6 @@ async function handle<P extends SeedDrivenGeneratorParameters>(ctx: HandlerConte
`Create Project`,
`Successfully created new project ${bold(`${params.target.repoRef.owner}/${
params.target.repoRef.repo}`)} at ${url(params.target.repoRef.url)}`));
if (isGitHubRepoRef(r.target.id) && params.addAtomistWebhook) {
const webhookInstalled = await hasOrgWebhook(params.target.repoRef.owner, ctx);
if (!webhookInstalled) {
await addAtomistWebhook((r.target as GitProject), params);
}
}
return {
code: 0,
// Redirect to local project page
@@ -189,26 +179,6 @@ ${codeBlock(err.message)}`,
}
}

const OrgWebhookQuery = `query OrgWebhook($owner: String!) {
Webhook(webhookType: organization) {
org(owner: $owner) @required {
owner
}
}
}`;

async function hasOrgWebhook(owner: string, ctx: HandlerContext): Promise<boolean> {
const orgHooks = await ctx.graphClient.query<any, any>({
query: OrgWebhookQuery,
variables: {
owner,
},
options: QueryNoCacheOptions,
});
const hookOwner = _.get(orgHooks, "Webhook[0].org.owner");
return hookOwner === owner;
}

/**
* Retrieve a seed. Set the seed location on the parameters if possible and necessary.
*/
@@ -26,8 +26,4 @@ export interface GeneratorConfig {
*/
seed: () => RemoteRepoRef;

/**
* Add an Atomist webhook to new repos?
*/
addAtomistWebhook?: boolean;
}
@@ -37,17 +37,6 @@ export class SeedDrivenGeneratorParametersSupport implements SeedDrivenGenerator
@MappedParameter(MappedParameters.SlackUserName)
public screenName: string;

@Parameter({
pattern: /^(?:true|false)$/,
type: "boolean",
displayName: "Add Atomist webhook",
description: "whether to add the Atomist webhook to the repository to allow updates",
validInput: "'true' or 'false'",
required: false,
displayable: true,
})
public addAtomistWebhook: boolean = false;

@Parameter({
...SemVerRegExp,
required: true,
@@ -98,10 +87,6 @@ export class SeedDrivenGeneratorParametersSupport implements SeedDrivenGenerator
return { repoRef };
}

public constructor(private readonly config?: GeneratorConfig) {
if (!!config && config.addAtomistWebhook !== undefined) {
this.addAtomistWebhook = config.addAtomistWebhook;
}
}
public constructor(private readonly config?: GeneratorConfig) {}

}
Oops, something went wrong.

0 comments on commit 498bc1c

Please sign in to comment.
You can’t perform that action at this time.