Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
logger,
Success,
} from "@atomist/automation-client";
import { subscription } from "@atomist/automation-client/graph/graphQL";
import { updateGoal } from "../../../../api-helper/goal/storeGoals";
import { goalKeyEquals, SdmGoal, SdmGoalKey } from "../../../../ingesters/sdmGoalIngester";
import { fetchGoalsForCommit } from "../../../../internal/delivery/goals/support/fetchGoalsOnCommit";
import { isGoalRelevant } from "../../../../internal/delivery/goals/support/validateGoal";
import { RepoRefResolver } from "../../../../spi/repo-ref/RepoRefResolver";
import { OnAnyFailedSdmGoal } from "../../../../typings/types";
import { fetchScmProvider, sumSdmGoalEventsByOverride } from "./RequestDownstreamGoalsOnGoalSuccess";
/**
* Respond to a failure status by failing downstream goals
*/
@EventHandler("Fail downstream goals on a goal failure", subscription("OnAnyFailedSdmGoal"))
export class SkipDownstreamGoalsOnGoalFailure implements HandleEvent {
constructor(private readonly repoRefResolver: RepoRefResolver) {}
// #98: GitHub Status->SdmGoal: We still have to respond to failure on status,
// until we change all the failure updates to happen on SdmGoal.
// but we can update the SdmGoals, and let that propagate to the statuses.
// we can count on all of the statuses we need to update to exist as SdmGoals.
// however, we can't count on the SdmGoal to have the latest state, so check the Status for that.
public async handle(event: EventFired,
context: HandlerContext,
params: this): Promise {
const failedGoal = event.data.SdmGoal[0] as SdmGoal;
if (!isGoalRelevant(failedGoal)) {
*/
import { EventFired, EventHandler, HandleEvent, HandlerContext, HandlerResult, logger, Success } from "@atomist/automation-client";
import { subscription } from "@atomist/automation-client/graph/graphQL";
import { GitCommandGitProject } from "@atomist/automation-client/project/git/GitCommandGitProject";
import * as _ from "lodash";
import {AddressChannels, AddressNoChannels} from "../../../api/context/addressChannels";
import { PushListener, PushListenerInvocation } from "../../../api/listener/PushListener";
import { CredentialsResolver } from "../../../spi/credentials/CredentialsResolver";
import { RepoRefResolver } from "../../../spi/repo-ref/RepoRefResolver";
import * as schema from "../../../typings/types";
/**
* A new repo has been created, and it has some code in it.
*/
@EventHandler("On repo creation", subscription("OnFirstPushToRepo"))
export class OnFirstPushToRepo
implements HandleEvent {
constructor(private readonly actions: PushListener[],
private readonly repoRefResolver: RepoRefResolver,
private readonly credentialsFactory: CredentialsResolver) {
}
public async handle(event: EventFired,
context: HandlerContext,
params: this): Promise {
const push = event.data.Push[0];
if (!!push.before) {
logger.debug(`Done: Not a new commit on ${push.repo.name}`);
return Success;
* limitations under the License.
*/
import { EventFired, EventHandler, HandleEvent, HandlerContext, HandlerResult, Success } from "@atomist/automation-client";
import { subscription } from "@atomist/automation-client/graph/graphQL";
import { AddressChannels, addressChannelsFor } from "../../../api/context/addressChannels";
import { PullRequestListener, PullRequestListenerInvocation } from "../../../api/listener/PullRequestListener";
import { CredentialsResolver } from "../../../spi/credentials/CredentialsResolver";
import { ProjectLoader } from "../../../spi/project/ProjectLoader";
import { RepoRefResolver } from "../../../spi/repo-ref/RepoRefResolver";
import * as schema from "../../../typings/types";
/**
* A pull request has been raised
*/
@EventHandler("On pull request", subscription("OnPullRequest"))
export class OnPullRequest implements HandleEvent {
constructor(
private readonly projectLoader: ProjectLoader,
private readonly repoRefResolver: RepoRefResolver,
private readonly listeners: PullRequestListener[],
private readonly credentialsFactory: CredentialsResolver) {
}
public async handle(event: EventFired,
context: HandlerContext,
params: this): Promise {
const pullRequest = event.data.PullRequest[0];
const repo = pullRequest.repo;
const id = params.repoRefResolver.toRemoteRepoRef(repo, { sha: pullRequest.head.sha });
const credentials = this.credentialsFactory.eventHandlerCredentials(context, id);
import { EventFired, EventHandler, HandleEvent, HandlerContext, HandlerResult, Success } from "@atomist/automation-client";
import { subscription } from "@atomist/automation-client/graph/graphQL";
import { RemoteRepoRef } from "@atomist/automation-client/operations/common/RepoId";
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 { CredentialsResolver } from "../../../../spi/credentials/CredentialsResolver";
import { ProjectLoader } from "../../../../spi/project/ProjectLoader";
import { RepoRefResolver } from "../../../../spi/repo-ref/RepoRefResolver";
import { OnPushToAnyBranch } from "../../../../typings/types";
/**
* Set up goalSet on a push (e.g. for delivery).
*/
@EventHandler("Set up goalSet", subscription("OnPushToAnyBranch"))
export class SetGoalsOnPush implements HandleEvent {
/**
* Configure goal setting
* @param projectLoader use to load projects
* @param repoRefResolver used to resolve repos from GraphQL return
* @param goalSetter
* @param goalsListeners listener to goals set
* @param implementationMapping
* @param credentialsFactory credentials factory
*/
constructor(private readonly projectLoader: ProjectLoader,
private readonly repoRefResolver: RepoRefResolver,
private readonly goalSetter: GoalSetter,
public readonly goalsListeners: GoalsSetListener[],
private readonly implementationMapping: SdmGoalImplementationMapper,
import { forApproval } from "./approvalGate";
export interface EndpointVerificationInvocation extends ListenerInvocation {
/**
* Reported endpoint base url
*/
url: string;
}
export type EndpointVerificationListener = SdmListener;
/**
* React to an endpoint reported in a GitHub status.
*/
@EventHandler("React to an endpoint",
subscription({
name: "OnSuccessStatus",
variables: {
context: StagingEndpointContext,
},
}),
)
export class OnEndpointStatus implements HandleEvent {
@Secret(Secrets.OrgToken)
private githubToken: string;
constructor(public goal: Goal, private sdm: SdmVerification) {
}
public async handle(event: EventFired,
* limitations under the License.
*/
import { EventFired, EventHandler, HandleEvent, HandlerContext, HandlerResult, logger, Success } from "@atomist/automation-client";
import { subscription } from "@atomist/automation-client/graph/graphQL";
import { addressChannelsFor } from "../../../../api/context/addressChannels";
import { DeploymentListener, DeploymentListenerInvocation } from "../../../../api/listener/DeploymentListener";
import { StagingDeploymentGoal } from "../../../../api/machine/wellKnownGoals";
import { CredentialsResolver } from "../../../../spi/credentials/CredentialsResolver";
import { RepoRefResolver } from "../../../../spi/repo-ref/RepoRefResolver";
import { OnSuccessStatus } from "../../../../typings/types";
/**
* React to a deployment.
*/
@EventHandler("React to a successful deployment",
subscription({
name: "OnSuccessStatus",
variables: {
context: StagingDeploymentGoal.context,
},
}),
)
export class OnDeployStatus implements HandleEvent {
constructor(private readonly listeners: DeploymentListener[],
private readonly repoRefResolver: RepoRefResolver,
private readonly credentialsFactory: CredentialsResolver) {}
public async handle(event: EventFired,
context: HandlerContext, params: this): Promise {
const status = event.data.Status[0];
GitHubStatusAndFriends,
Goal,
} from "../../../../common/goals/Goal";
import { createEphemeralProgressLog } from "../../../../common/log/EphemeralProgressLog";
import { addressChannelsFor } from "../../../../common/slack/addressChannels";
import { ArtifactStore } from "../../../../spi/artifact/ArtifactStore";
import { Deployer } from "../../../../spi/deploy/Deployer";
import { TargetInfo } from "../../../../spi/deploy/Deployment";
import { OnAnySuccessStatus } from "../../../../typings/types";
import { StatusSuccessHandler } from "../../StatusSuccessHandler";
import { deploy } from "./deploy";
/**
* Deploy a published artifact identified in an ImageLinked event.
*/
@EventHandler("Deploy linked artifact", GraphQL.subscriptionFromFile(
"../../../../graphql/subscription/OnAnySuccessStatus",
__dirname),
)
export class DeployFromLocalOnSuccessStatus implements StatusSuccessHandler {
@Secret(Secrets.OrgToken)
private githubToken: string;
constructor(private commandName: string,
private deployGoal: Goal,
private endpointGoal: Goal,
private artifactStore: ArtifactStore,
public deployer: Deployer,
private targeter: (id: RemoteRepoRef) => T) {
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EventFired, EventHandler, HandleEvent, HandlerContext, HandlerResult, logger, Success } from "@atomist/automation-client";
import { subscription } from "@atomist/automation-client/graph/graphQL";
import { addressChannelsFor } from "../../../api/context/addressChannels";
import { NewIssueListener, NewIssueListenerInvocation } from "../../../api/listener/NewIssueListener";
import { CredentialsResolver } from "../../../spi/credentials/CredentialsResolver";
import { RepoRefResolver } from "../../../spi/repo-ref/RepoRefResolver";
import * as schema from "../../../typings/types";
/**
* A new issue has been created.
*/
@EventHandler("On issue creation", subscription("OnNewIssue"))
export class NewIssueHandler implements HandleEvent {
private readonly newIssueListeners: NewIssueListener[];
constructor(newIssueListeners: NewIssueListener[],
private readonly repoRefResolver: RepoRefResolver,
private readonly credentialsFactory: CredentialsResolver) {
this.newIssueListeners = newIssueListeners;
}
public async handle(event: EventFired,
context: HandlerContext,
params: this): Promise {
const issue = event.data.Issue[0];
const addressChannels = addressChannelsFor(issue.repo, context);
const id = params.repoRefResolver.toRemoteRepoRef(issue.repo, {});
* limitations under the License.
*/
import { EventFired, EventHandler, HandleEvent, HandlerContext, HandlerResult, Success } from "@atomist/automation-client";
import { subscription } from "@atomist/automation-client/graph/graphQL";
import { GitCommandGitProject } from "@atomist/automation-client/project/git/GitCommandGitProject";
import { AddressChannels, addressChannelsFor } from "../../../api/context/addressChannels";
import { ProjectListener, ProjectListenerInvocation } from "../../../api/listener/ProjectListener";
import { CredentialsResolver } from "../../../spi/credentials/CredentialsResolver";
import { RepoRefResolver } from "../../../spi/repo-ref/RepoRefResolver";
import * as schema from "../../../typings/types";
/**
* A repo has been onboarded
*/
@EventHandler("On repo onboarding", subscription("OnRepoOnboarded"))
export class OnRepoOnboarded implements HandleEvent {
constructor(private readonly actions: ProjectListener[],
private readonly repoRefResolver: RepoRefResolver,
private readonly credentialsFactory: CredentialsResolver) {
}
public async handle(event: EventFired,
context: HandlerContext,
params: this): Promise {
const repoOnboarded = event.data.RepoOnboarded[0];
const id = params.repoRefResolver.toRemoteRepoRef(repoOnboarded.repo, {branch: repoOnboarded.repo.defaultBranch});
const credentials = this.credentialsFactory.eventHandlerCredentials(context, id);
const addressChannels: AddressChannels = addressChannelsFor(repoOnboarded.repo, context);
const project = await GitCommandGitProject.cloned(credentials, id);