Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { GitHubRepoRef } from "@atomist/automation-client/operations/common/GitHubRepoRef";
import { RemoteRepoRef } from "@atomist/automation-client/operations/common/RepoId";
import * as _ from "lodash";
import { AddressChannels } from "../../api/context/addressChannels";
import { LogInterpretation } from "../../spi/log/InterpretedLog";
import { BuildUrlBySha } from "../../typings/types";
import { tipOfDefaultBranch } from "../../util/github/ghub";
import { DefaultRepoRefResolver } from "../common/DefaultRepoRefResolver";
import { displayBuildLogFailure } from "../events/delivery/build/SetStatusOnBuildComplete";
@Parameters()
export class DisplayBuildLogParameters {
@Secret(Secrets.UserToken)
public githubToken: string;
@MappedParameter(MappedParameters.GitHubOwner)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository)
public repo: string;
@Parameter({required: false})
public sha?: string;
}
function displayBuildLogForCommit(interpreter?: LogInterpretation) {
return async (ctx: HandlerContext,
params: { githubToken: string, owner: string, repo: string, sha?: string }) => {
const sha = params.sha ? params.sha :
await tipOfDefaultBranch(params.githubToken, new GitHubRepoRef(params.owner, params.repo)); // TODO: use fetchDefaultBranchTip
});
}
@Parameters()
export class RetryVerifyParameters {
@Secret(Secrets.UserToken)
public githubToken: string;
@MappedParameter(MappedParameters.SlackChannelName)
public channelName: string;
@MappedParameter(MappedParameters.GitHubRepository)
public repo: string;
@MappedParameter(MappedParameters.GitHubOwner)
public owner: string;
@Parameter({required: false})
public sha: string;
@Parameter()
public targetUrl: string;
}
function retryVerificationCommandName(verifyGoal: Goal) {
// todo: get the env on the Goal
return "RetryFailedVerification" + splitContext(verifyGoal.context).env;
}
export function retryVerifyCommand(sdm: SdmVerification): HandleCommand {
import { CloudFoundryInfo } from "../../../common/delivery/deploy/pcf/CloudFoundryTarget";
import { AddressChannels } from "../../../common/slack/addressChannels";
import { undeployFromK8s } from "../../../handlers/events/delivery/deploy/k8s/RequestK8sDeploys";
import { deleteRepository } from "../../../util/github/ghub";
import { CloudFoundryProductionTarget, CloudFoundryStagingTarget } from "./cloudFoundryDeploy";
export const K8sTestingDomain = "testing";
export const K8sProductionDomain = "production";
@Parameters()
export class DisposeParameters {
@Secret(Secrets.userToken("delete_repo"))
public githubToken: string;
@MappedParameter(MappedParameters.GitHubOwner)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository)
public repo: string;
@MappedParameter(MappedParameters.SlackUserName)
public screenName: string;
@Parameter({displayName: "Are you sure?"})
public areYouSure: string;
}
export const disposeProjectHandler: HandleCommand =
commandHandlerFrom(disposeHandle,
DisposeParameters,
* Resolve from a Mapped parameter or from a supplied repos regex if no repo mapping
*/
import {
MappedParameter,
MappedParameters,
Parameter,
validationPatterns,
ValidationResult,
} from "@atomist/automation-client";
import { FallbackParams } from "@atomist/automation-client/lib/operations/common/params/FallbackParams";
import { GitHubTargetsParams } from "@atomist/automation-client/lib/operations/common/params/GitHubTargetsParams";
import { RepoTargets } from "../../machine/RepoTargets";
export class GitHubRepoTargets extends GitHubTargetsParams implements FallbackParams, RepoTargets {
@MappedParameter(MappedParameters.GitHubOwner, false)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository, false)
public repo: string;
@Parameter({ description: "Ref", ...validationPatterns.GitShaRegExp, required: false })
public sha: string;
@Parameter({ description: "Branch", ...validationPatterns.GitBranchRegExp, required: false })
public branch: string = "master";
@Parameter({ description: "regex", required: false })
public repos: string;
public bindAndValidate(): ValidationResult {
if (!this.repo) {
import { RepoTargets } from "../../machine/RepoTargets";
/**
* Targets for working with BitBucket repo(s).
* Allows use of regex.
*/
@Parameters()
export class GitlabRepoTargets extends TargetsParams implements FallbackParams, RepoTargets {
@MappedParameter(MappedParameters.GitHubApiUrl, false)
public apiUrl: string;
@MappedParameter(MappedParameters.GitHubUrl, false)
public url: string;
@MappedParameter(MappedParameters.GitHubOwner, false)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository, false)
public repo: string;
@Parameter({ description: "Ref", ...validationPatterns.GitShaRegExp, required: false })
public sha: string;
@Parameter({ description: "Branch Defaults to 'master'", ...validationPatterns.GitBranchRegExp, required: false })
public branch: string = "master";
@Parameter({ description: "regex", required: false })
public repos: string;
get credentials(): ProjectOperationCredentials {
return undefined;
codeLine,
italic,
} from "@atomist/slack-messages";
import * as stringify from "json-stringify-safe";
import {
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;
@Value("name")
public name: string;
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 {
return commandHandlerFrom(disposeOfProject(rules),
DisposeParameters,
"DisposeOfProject",
Success,
} from "@atomist/automation-client";
import { Parameters } from "@atomist/automation-client/decorators";
import { HandlerContext } from "@atomist/automation-client/Handlers";
import { commandHandlerFrom } from "@atomist/automation-client/onCommand";
import { addressEvent } from "@atomist/automation-client/spi/message/MessageClient";
import {
DeployEnablementRootType,
SdmDeployEnablement,
} from "../../ingesters/sdmDeployEnablement";
import { success } from "../../util/slack/messages";
@Parameters()
export class SetDeployEnablementParameters {
@MappedParameter(MappedParameters.GitHubOwner)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository)
public repo: string;
@MappedParameter(MappedParameters.GitHubRepositoryProvider)
public providerId: string;
}
/**
* Command to set deploy enablement on the currently mapped repo
* @param {boolean} enable
* @return {(ctx: HandlerContext, params: SetDeployEnablementParameters) => Promise}
*/
export function setDeployEnablement(enable: boolean) {
(inv.credentials as TokenCredentials).token,
inv.id as GitHubRepoRef,
{domain: K8sProductionDomain, color: ProductionMauve}, inv.id.sha);
const message: slack.SlackMessage = {
attachments: currentlyRunning,
};
return inv.context.messageClient.send(message, inv.messageDestination, {id: messageId});
}
@Parameters()
export class PromotionParameters {
@Secret(Secrets.UserToken)
public githubToken;
@MappedParameter(MappedParameters.GitHubOwner)
public owner;
@MappedParameter(MappedParameters.GitHubRepository)
public repo;
@Parameter({required: false})
public sha;
@MappedParameter(MappedParameters.SlackChannel)
public channel;
}
export const offerPromotionCommand: Maker> = () =>
commandHandlerFrom(async (context: HandlerContext, params: PromotionParameters) => {
const inv: VerifiedDeploymentInvocation = {
id: new GitHubRepoRef(params.owner, params.repo, params.sha || await
} from "@atomist/automation-client";
import { FallbackParams } from "@atomist/automation-client/lib/operations/common/params/FallbackParams";
import { TargetsParams } from "@atomist/automation-client/lib/operations/common/params/TargetsParams";
import { RepoTargets } from "../../machine/RepoTargets";
/**
* Targets for working with BitBucket repo(s).
* Allows use of regex.
*/
@Parameters()
export class BitBucketRepoTargets extends TargetsParams implements FallbackParams, RepoTargets {
@MappedParameter(MappedParameters.GitHubApiUrl, false)
public apiUrl: string;
@MappedParameter(MappedParameters.GitHubOwner, false)
public owner: string;
@MappedParameter(MappedParameters.GitHubRepository, false)
public repo: string;
@Parameter({ description: "Ref", ...validationPatterns.GitShaRegExp, required: false })
public sha: string;
@Parameter({ description: "Branch Defaults to 'master'", ...validationPatterns.GitBranchRegExp, required: false })
public branch: string = "master";
@Parameter({ description: "regex", required: false })
public repos: string;
get credentials(): ProjectOperationCredentials {
return undefined;