How to use the @atomist/automation-client.MappedParameters.GitHubRepository function in @atomist/automation-client

To help you get started, we’ve selected a few @atomist/automation-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atomist / sdm-core / lib / handlers / commands / ShowBuildLog.ts View on Github external
} from "@atomist/sdm";
import * as _ from "lodash";
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): CommandListener {
    return async cli => {

        const sha = cli.parameters.sha ? cli.parameters.sha :
            await tipOfDefaultBranch(cli.parameters.githubToken,
                new GitHubRepoRef(cli.parameters.owner, cli.parameters.repo)); // TODO: use fetchDefaultBranchTip

        // TODO get rid of hard coding
        const id = new DefaultRepoRefResolver().toRemoteRepoRef(cli.parameters, { sha });
        const ac: AddressChannels = (msg, opts) => cli.context.messageClient.respond(msg, opts);
github atomist / sdm / src / handlers / events / delivery / verify / OnEndpointStatus.ts View on Github external
target_url: requestApproval ? forApproval(targetUrl) : targetUrl,
        context: verifyGoal.context,
        description: state === "success" ? verifyGoal.successDescription : ("Failed to " + verifyGoal.name),
    });
}

@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;
github atomist / sdm / src / handlers / commands / SetDeployEnablement.ts View on Github external
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) {
    return (ctx: HandlerContext, params: SetDeployEnablementParameters): Promise => {
        const deployEnablement: SdmDeployEnablement = {
            state: enable ? "requested" : "disabled",
github atomist / sdm / src / handlers / commands / deleteRepository.ts View on Github external
import { Parameters } from "@atomist/automation-client/decorators";
import { commandHandlerFrom } from "@atomist/automation-client/onCommand";
import { GitHubRepoRef } from "@atomist/automation-client/operations/common/GitHubRepoRef";
import { deleteRepository } from "../../util/github/ghub";
import { fetchProvider } from "../../util/github/gitHubProvider";

@Parameters()
export class DeleteRepositoryParameters {

    @Secret(Secrets.userToken("delete_repo"))
    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 const DeleteRepositoryCommandName = "DeleteRepository";

export function deleteRepositoryCommand(): HandleCommand {
    return commandHandlerFrom(deleteRepositoryPlease(),
        DeleteRepositoryParameters,
        DeleteRepositoryCommandName,
        "Really delete the GitHub repository",
github atomist / sdm / src / software-delivery-machine / blueprint / deploy / dispose.ts View on Github external
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,
        "DisposeOfProject",
        "Delete deployments and repo",
        "dispose of this project");
github atomist / sdm-core / src / handlers / events / delivery / goals / resetGoals.ts View on Github external
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;

    @Value("version")
    public version: string;
github atomist / sdm / src / handlers / commands / reportRunning.ts View on Github external
import { tipOfDefaultBranch } from "../../util/github/ghub";
import {
    linkToDiff,
    renderDiff,
} from "../../util/slack/diffRendering";

@Parameters()
export class ReportRunningParameters {

    @Secret(Secrets.UserToken)
    public githubToken: string;

    @MappedParameter(MappedParameters.GitHubOwner)
    public owner;

    @MappedParameter(MappedParameters.GitHubRepository)
    public repo;

    @Parameter({required: false})
    public comparisonSha: string;
}

export interface ServiceDomain {
    domain: string;
    color: string;
}

export function reportRunningCommand(serviceDomains: ServiceDomain[],
                                     intent: string = "what is running"): HandleCommand {
    const handlerName = "ReportRunning-" + serviceDomains.map(sd => sd.domain).join("-");
    return commandHandlerFrom(reportRunningServices(serviceDomains), ReportRunningParameters, handlerName,
        "describe services Atomist thinks are running", intent);
github atomist / sdm-core / lib / handlers / commands / disposeCommand.ts View on Github external
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",
        "Remove this project from existence",
        ["dispose of this project", "exterminate"]);
}
github atomist / sdm-core / lib / handlers / commands / SetDeployEnablement.ts View on Github external
import { bold } from "@atomist/slack-messages";
import {
    DeployEnablementRootType,
    SdmDeployEnablement,
} from "../../ingesters/sdmDeployEnablement";

@Parameters()
export class SetDeployEnablementParameters {

    @Parameter({ required: false, displayable: false })
    public msgId?: string;

    @MappedParameter(MappedParameters.GitHubOwner)
    public owner: string;

    @MappedParameter(MappedParameters.GitHubRepository)
    public repo: string;

    @MappedParameter(MappedParameters.GitHubRepositoryProvider)
    public providerId: string;

    @Value("name")
    public name: string;

    @Value("version")
    public version: string;
}

/**
 * Command to set deploy enablement on the currently mapped repo
 * @param {CommandListenerInvocation} cli
 * @param {boolean} enable
github atomist / sdm / lib / api / command / target / GitHubRepoTargets.ts View on Github external
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) {
            if (!this.repos) {
                return {
                    message: