How to use the @atomist/sdm.addressChannelsFor function in @atomist/sdm

To help you get started, we’ve selected a few @atomist/sdm 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 / events / delivery / goals / FulfillGoalOnRequested.ts View on Github external
return Success;
        } else if (sdmGoal.fulfillment.method === SdmGoalFulfillmentMethod.Other) {
            // fail goal with neither Sdm nor SideEffect fulfillment
            await updateGoal(
                ctx,
                sdmGoal,
                {
                    state: SdmGoalState.failure,
                    description: `No fulfillment for ${sdmGoal.uniqueName}`,
                });
            return Success;
        }

        const id = this.configuration.sdm.repoRefResolver.repoRefFromSdmGoal(sdmGoal);
        const credentials = await resolveCredentialsPromise(this.configuration.sdm.credentialsResolver.eventHandlerCredentials(ctx, id));
        const addressChannels = addressChannelsFor(sdmGoal.push.repo, ctx);
        const preferences = this.configuration.sdm.preferenceStoreFactory(ctx);

        const implementation = this.implementationMapper.findImplementationBySdmGoal(sdmGoal);
        const { goal } = implementation;

        const progressLog = new WriteToAllProgressLog(
            sdmGoal.name,
            new LoggingProgressLog(sdmGoal.name, "debug"),
            await this.configuration.sdm.logFactory(ctx, sdmGoal));

        const goalInvocation: GoalInvocation = {
            configuration: this.configuration,
            sdmGoal,
            goalEvent: sdmGoal,
            goal,
            progressLog,
github atomist / sdm-core / lib / handlers / events / delivery / verify / OnVerifiedDeploymentStatus.ts View on Github external
params: this): Promise {
        const status: Status = event.data.Status[0];
        const commit = status.commit;

        if (status.context !== StagingVerifiedGoal.context) {
            logger.debug(`********* onVerifiedStatus got called with status context=[${status.context}]`);
            return Success;
        }

        const id = this.repoRefResolver.toRemoteRepoRef(commit.repo, { sha: commit.sha });
        const credentials = this.credentialsFactory.eventHandlerCredentials(context, id);
        const vdi: VerifiedDeploymentListenerInvocation = {
            id,
            context,
            status,
            addressChannels: addressChannelsFor(commit.repo, context),
            credentials,
        };
        await Promise.all(params.listeners.map(l => l(vdi)));
        return Success;
    }
}
github atomist / sdm-core / lib / handlers / events / delivery / build / InvokeListenersOnBuildComplete.ts View on Github external
public async handle(event: EventFired,
                        context: HandlerContext,
                        params: this): Promise {
        const build = event.data.Build[0];
        const repo = build.commit.repo;
        const id = this.repoRefResolver.toRemoteRepoRef(repo, {});
        const credentials = this.credentialsFactory.eventHandlerCredentials(context, id);

        const addressChannels: AddressChannels = addressChannelsFor(repo, context);
        const bli: BuildListenerInvocation = {
            context,
            id,
            credentials,
            addressChannels,
            build,
        };
        await Promise.all(params.listeners
            .map(l => l(bli)),
        );
        return Success;
    }
}
github atomist / sdm-core / lib / handlers / events / delivery / deploy / OnDeployStatus.ts View on Github external
public async handle(event: EventFired,
                        context: HandlerContext, params: this): Promise {
        const status = event.data.Status[0];
        const commit = status.commit;

        if (status.context !== StagingDeploymentGoal.context) {
            logger.debug(`********* OnDeploy got called with status context=[${status.context}]`);
            return Success;
        }
        const addressChannels = addressChannelsFor(commit.repo, context);
        const id = params.repoRefResolver.toRemoteRepoRef(commit.repo, { sha: commit.sha });
        const credentials = this.credentialsFactory.eventHandlerCredentials(context, id);

        const dil: DeploymentListenerInvocation = {
            context,
            status,
            id,
            addressChannels,
            credentials,
        };
        await Promise.all(params.listeners.map(l => l(dil)));
        return Success;
    }
github atomist / sdm-core / lib / handlers / events / issue / NewIssueHandler.ts View on Github external
public async handle(event: EventFired,
                        context: HandlerContext): Promise {
        const issue = event.data.Issue[0];
        const addressChannels = addressChannelsFor(issue.repo, context);
        const id = this.repoRefResolver.toRemoteRepoRef(issue.repo, {});

        if (issue.updatedAt !== issue.createdAt) {
            logger.debug("Issue updated, not created: %s on %j", issue.number, id);
            return Success;
        }
        const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
        const preferences = this.preferenceStoreFactory(context);

        const inv: NewIssueListenerInvocation = {
            id,
            addressChannels,
            preferences,
            configuration: this.configuration,
            context,
            issue,
github atomist / sdm-core / lib / handlers / events / repo / OnPullRequest.ts View on Github external
public async handle(event: EventFired,
                        context: HandlerContext): Promise {
        const pullRequest = event.data.PullRequest[0];
        const repo = pullRequest.repo;
        const id = this.repoRefResolver.toRemoteRepoRef(
            repo,
            {
                sha: pullRequest.head.sha,
                branch: pullRequest.branch.name,
            });
        const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
        const addressChannels = addressChannelsFor(repo, context);
        const preferences = this.preferenceStoreFactory(context);

        await this.projectLoader.doWithProject({ credentials, id, context, readOnly: true }, async project => {
            const prli: PullRequestListenerInvocation = {
                id,
                context,
                addressChannels,
                preferences,
                configuration: this.configuration,
                credentials,
                project,
                pullRequest,
            };
            await Promise.all(this.listeners
                .map(l => l(prli)),
            );
github atomist / sdm-core / lib / handlers / events / delivery / code / ReactToSemanticDiffsOnPushImpact.ts View on Github external
const diffs: FingerprintDifference[] =
            allNames
                .map(name => ({
                    oldValue: oldValues.find(f => f.name === name),
                    newValue: newValues.find(f => f.name === name),
                }))
                .filter(fv => _.get(fv, "oldValue.sha") !== _.get(fv, "newValue.sha"));

        const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
        const preferences = this.preferencesStoreFactory(context);
        const inv: FingerprintDifferenceListenerInvocation = {
            id,
            context,
            credentials,
            addressChannels: addressChannelsFor(after.repo, context),
            configuration: this.configuration,
            preferences,
            diffs,
        };
        await Promise.all(this.differenceListeners.map(dh => dh(inv)));
        return Success;
    }
}
github atomist / sdm-core / lib / handlers / events / repo / OnTag.ts View on Github external
public async handle(event: EventFired,
                        context: HandlerContext): Promise {
        const tag = event.data.Tag[0];
        const repo = tag.commit.repo;

        const id = this.repoRefResolver.toRemoteRepoRef(repo, {});
        const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
        const addressChannels = addressChannelsFor(repo, context);
        const preferences = this.preferenceStoreFactory(context);

        const invocation: TagListenerInvocation = {
            addressChannels,
            preferences,
            configuration: this.configuration,
            id,
            context,
            tag,
            credentials,
        };
        await Promise.all(this.listeners.map(l => l(invocation)));
        return Success;
    }
}
github atomist / sdm-core / lib / handlers / events / delivery / goals / RespondOnGoalCompletion.ts View on Github external
if (!shouldHandle(sdmGoal)) {
            logger.debug(`Goal ${sdmGoal.uniqueName} skipped because not managed by this SDM`);
            return Success;
        }

        await verifyGoal(sdmGoal, this.configuration.sdm.goalSigning, context);

        const id = this.repoRefResolver.repoRefFromPush(sdmGoal.push);

        const goals = fetchGoalsFromPush(sdmGoal);

        const gsi: GoalCompletionListenerInvocation = {
            id,
            context,
            credentials: await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id)),
            addressChannels: addressChannelsFor(sdmGoal.push.repo, context),
            configuration: this.configuration,
            preferences: this.preferenceStoreFactory(context),
            allGoals: goals,
            completedGoal: sdmGoal,
        };

        try {
            await Promise.all(this.goalCompletionListeners.map(l => l(gsi)));
        } catch (e) {
            logger.warn(`Error occurred while running goal completion listener: ${stringify(e)}`);
        }
        return Success;
    }
}
github atomist / sdm-core / lib / handlers / events / issue / ClosedIssueHandler.ts View on Github external
public async handle(event: EventFired,
                        context: HandlerContext): Promise {
        const issue = event.data.Issue[0];
        const id = this.repoRefResolver.toRemoteRepoRef(issue.repo, {});
        const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
        const preferences = this.preferenceStoreFactory(context);

        const addressChannels = addressChannelsFor(issue.repo, context);
        const inv: ClosedIssueListenerInvocation = {
            id,
            addressChannels,
            preferences,
            configuration: this.configuration,
            context,
            issue,
            credentials,
        };
        await Promise.all(this.closedIssueListeners
            .map(l => l(inv)));
        return Success;
    }
}