Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Secret,
Secrets,
Success,
} from "@atomist/automation-client";
import { OnEvent } from "@atomist/automation-client/onEvent";
import { GitHubRepoRef } from "@atomist/automation-client/operations/common/GitHubRepoRef";
import { raiseIssue } from "@atomist/automation-client/util/gitHub";
import { RepoRefResolver } from "@atomist/sdm/spi/repo-ref/RepoRefResolver";
import { OnBuildCompleteForDryRun } from "../../../typings/types";
import { createStatus } from "../../../util/github/ghub";
import { DryRunContext } from "../dryRunEditorCommand";
@Parameters()
export class OnDryRunBuildCompleteParameters {
@Secret(Secrets.OrgToken)
public readonly githubToken: string;
}
/**
* React to result of a dry run build to raise a PR or issue
*/
export function onDryRunBuildComplete(repoRefResolver: RepoRefResolver)
: OnEvent {
return async (event: EventFired,
ctx: HandlerContext,
params: OnDryRunBuildCompleteParameters): Promise => {
const build = event.data.Build[0];
const commit = build.commit;
// TODO currently Github only
import {
BitBucketServerRepoRef,
MappedParameter,
MappedParameters,
ProjectOperationCredentials,
RemoteRepoRef,
Secret,
Secrets,
} from "@atomist/automation-client";
import { NewRepoCreationParameters } from "@atomist/automation-client/lib/operations/generate/NewRepoCreationParameters";
// TODO could this be universal
export class BitBucketRepoCreationParameters extends NewRepoCreationParameters {
@Secret(Secrets.userToken(["repo", "user:email", "read:user"]))
public githubToken: string;
// @MappedParameter(MappedParameters.GitHubWebHookUrl)
// public webhookUrl: string;
@MappedParameter(MappedParameters.GitHubApiUrl, false)
public apiUrl: string;
get credentials(): ProjectOperationCredentials {
throw new Error("Override this");
}
/**
* Return a single RepoRef or undefined if we're not identifying a single repo
* This implementation returns a GitHub.com repo but it can be overriden
* to return any kind of repo
export function k8AutomationDeployContext(target: K8Target): string {
return `${K8TargetBase}${target}`;
}
// TODO this class goes once we remove duplication
/**
* Deploy a published artifact identified in an ImageLinked event.
*/
@EventHandler("Request k8s deploy of linked artifact", GraphQL.subscriptionFromFile(
"../../../../../graphql/subscription/OnAnySuccessStatus",
__dirname),
)
export class RequestK8sDeployOnSuccessStatus1 implements HandleEvent {
@Secret(Secrets.OrgToken)
private githubToken: string;
constructor(private deployGoal: Goal,
private target: K8Target) {
}
public async handle(event: EventFired,
context: HandlerContext,
params: this): Promise {
const status = event.data.Status[0];
const commit = status.commit;
const image = status.commit.image;
const id = new GitHubRepoRef(commit.repo.owner, commit.repo.name, commit.sha);
const statusAndFriends: GitHubStatusAndFriends = {
context: status.context,
state: status.state,
Parameter,
Secret,
Secrets,
success,
Success,
} from "@atomist/automation-client";
import { Parameters } from "@atomist/automation-client/decorators";
import { commandHandlerFrom } from "@atomist/automation-client/onCommand";
import { GitHubRepoRef } from "@atomist/automation-client/operations/common/GitHubRepoRef";
import { chooseAndSetGoals, ChooseAndSetGoalsRules } from "../../api-helper/goal/chooseAndSetGoals";
import { fetchDefaultBranchTip, fetchPushForCommit, tipOfBranch } from "../events/delivery/goals/resetGoals";
@Parameters()
export class DisposeParameters {
@Secret(Secrets.UserToken)
public githubToken: string;
@MappedParameter(MappedParameters.GitHubOwner)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository)
public repo: string;
@MappedParameter(MappedParameters.GitHubRepositoryProvider)
public providerId: string;
@Parameter({required: true})
public areYouSure: string;
}
export function disposeCommand(rules: ChooseAndSetGoalsRules): HandleCommand {
@Parameters()
export class RetryDeployParameters {
@Parameter()
public repo: string;
@Parameter()
public owner: string;
@Parameter()
public sha: string;
@Parameter()
public targetUrl: string;
@Secret(Secrets.UserToken)
public githubToken: string;
@MappedParameter(MappedParameters.SlackChannelName)
public channelName: string;
}
import { HandleCommand } from "@atomist/automation-client/lib/HandleCommand";
import { commandHandlerFrom } from "@atomist/automation-client/lib/onCommand";
import {
chooseAndSetGoals,
ChooseAndSetGoalsRules,
} from "@atomist/sdm";
import {
fetchBranchTips,
fetchPushForCommit,
tipOfBranch,
} from "../../util/graph/queryCommits";
@Parameters()
export class DisposeParameters {
@Secret(Secrets.UserToken)
public githubToken: string;
@MappedParameter(MappedParameters.GitHubOwner)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository)
public repo: string;
@MappedParameter(MappedParameters.GitHubRepositoryProvider)
public providerId: string;
@Parameter({ required: true })
public areYouSure: string;
}
export function disposeCommand(rules: ChooseAndSetGoalsRules): HandleCommand {
import { commandHandlerFrom } from "@atomist/automation-client/onCommand";
import { GitHubRepoRef } from "@atomist/automation-client/operations/common/GitHubRepoRef";
import { RemoteRepoRef } from "@atomist/automation-client/operations/common/RepoId";
import * as stringify from "json-stringify-safe";
import { chooseAndSetGoals } from "../../../../api-helper/goal/chooseAndSetGoals";
import { SdmGoalImplementationMapper } from "../../../../api/goal/support/SdmGoalImplementationMapper";
import { GoalsSetListener } from "../../../../api/listener/GoalsSetListener";
import { GoalSetter } from "../../../../api/mapping/GoalSetter";
import { ProjectLoader } from "../../../../spi/project/ProjectLoader";
import { RepoRefResolver } from "../../../../spi/repo-ref/RepoRefResolver";
import { PushFields, PushForCommit, RepoBranchTips } from "../../../../typings/types";
@Parameters()
export class ResetGoalsParameters {
@Secret(Secrets.UserToken)
public githubToken: string;
@MappedParameter(MappedParameters.GitHubOwner)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository)
public repo: string;
@MappedParameter(MappedParameters.GitHubRepositoryProvider)
public providerId: string;
@Parameter({required: false})
public sha: string;
@Parameter({required: false})
public branch: string;