How to use the @atomist/automation-client.configurationValue 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 / lib / api-helper / misc / spawned.ts View on Github external
export async function spawnAndWatch(spawnCommand: SpawnCommand,
                                    options: SpawnOptions,
                                    log: ProgressLog,
                                    spOpts: Partial = {}): Promise {
    const delimitedLog = new DelimitedWriteProgressLogDecorator(log, "\n");

    // Set the goal default timeout to 10mins
    if (!spOpts.timeout) {
        spOpts.timeout = configurationValue("sdm.goal.timeout", 1000 * 60 * 10);
    }

    return clientSpawnAndWatch(spawnCommand, options, delimitedLog, spOpts);
}
github atomist / sdm / lib / api / context / parameterPrompt.ts View on Github external
correlation_id: trigger.correlation_id,
            team: trigger.team,
            command: trigger.command,
            source: trigger.source,
            parameters: trigger.parameters,
            parameter_specs: _.map(newParameters, (v, k) => ({
                ...v,
                name: k,
                required: v.required !== undefined ? v.required : true,
                pattern: v.pattern ? v.pattern.source : undefined,
            })),
            content_type: AtomistContinuationMimeType,
        };

        // Strangely send a message doesn't need a promise await; it is sync.
        configurationValue("ws.lifecycle").send(response);
        throw new CommandListenerExecutionInterruptError(
            `Prompting for new parameters: ${_.map(newParameters, (v, k) => k).join(", ")}`);
    };
}
github atomist / sdm-core / lib / internal / delivery / deploy / local / ManagedDeployments.ts View on Github external
export async function portIsInUse(host: string, port: number): Promise {
    const httpClient = configurationValue("http.client.factory", DefaultHttpClientFactory).create();
    const agent = new https.Agent({
        rejectUnauthorized: false,
    });
    try {
        await httpClient.exchange(`${host}:${port}`, {
            method: HttpMethod.Head,
            options: { httpsAgent: agent },
        });
        return true;
    } catch {
        return false;
    }
}
github atomist / sdm-core / lib / pack / goal-state / cancelGoals.ts View on Github external
export async function pendingGoalSets(ctx: HandlerContext,
                                      name: string,
                                      offset: number = 0,
                                      fetch: number = 50): Promise {
    const results = await ctx.graphClient.query({
        name: "InProcessSdmGoalSets",
        variables: {
            fetch,
            offset,
            registration: [name],
        },
        options: {
            ...QueryNoCacheOptions,
            log: configurationValue("sdm.query.logging", false),
        },
    });
    return (results.SdmGoalSet || []).map(gs => gs);
}
github atomist / sdm / lib / api-helper / misc / slack / messages.ts View on Github external
export function slackFooter(): string {
    return `${configurationValue("name")}`;
}
github atomist / sdm-core / lib / pack / k8s / KubernetesGoalScheduler.ts View on Github external
export async function listJobs(labelSelector?: string): Promise {
    const kc = loadKubeConfig();
    const batch = kc.makeApiClient(k8s.BatchV1Api);

    if (configurationValue("sdm.k8s.job.singleNamespace", true)) {
        const podNs = await readNamespace();
        return (await batch.listNamespacedJob(
            podNs,
            undefined,
            undefined,
            undefined,
            undefined,
            labelSelector,
        )).body.items;
    } else {
        return (await batch.listJobForAllNamespaces(
            undefined,
            undefined,
            undefined,
            labelSelector,
        )).body.items;
github atomist / sdm-core / lib / util / verify / lookFor200OnEndpointRootGet.ts View on Github external
return async (inv: EndpointVerificationInvocation) => {
        const httpClient = configurationValue("http.client.factory", DefaultHttpClientFactory).create();
        const agent = new https.Agent({
            rejectUnauthorized: false,
        });
        if (!inv.url) {
            throw new Error("Verify called with null URL");
        }
        try {
            const resp = await httpClient.exchange(inv.url, {
                method: HttpMethod.Get,
                options: { httpsAgent: agent },
                retry: retryOpts,
            });
            logger.debug(`lookFor200OnEndpointRootGet: Response for ${inv.url} was ${resp.status}`);
            if (resp.status !== 200) {
                throw new Error(`Unexpected response when getting ${inv.url}: ${resp.status}`);
            }
github atomist / sdm-pack-aspect / lib / job / createFingerprintJob.ts View on Github external
return {
            providerId: provider.providerId,
            name: org.owner,
            tasks: org.repos.map(repo => {
                return {
                    providerId: provider.providerId,
                    repoId: repo.id,
                    owner: repo.owner,
                    name: repo.name,
                    branch: repo.defaultBranch || "master",
                };
            }),
        };
    });

    const prefs: PreferenceStore = configurationValue("sdm.preferenceStoreFactory")(ctx);

    for (const org of orgs) {
        const analyzed = await prefs.get(preferenceKey(org.name), { scope: PreferenceScope.Sdm, defaultValue: false });
        if (!analyzed || rerun) {
            try {
                await createJob({
                        command: calculateFingerprintTask([], []),
                        parameters: org.tasks,
                        name: `OrganizationAnalysis/${org.providerId}/${org.name}`,
                        description: `Analyzing repositories in ${bold(org.name)}`,
                    },
                    ctx);
                await prefs.put(preferenceKey(org.name), true, { scope: PreferenceScope.Sdm });
            } catch (e) {
                logger.warn("Failed to create job for org '%s': %s", org.name, e.message);
            }