@port-labs/port
Version:
A Pulumi package for creating and managing Port resources.
296 lines • 10.3 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Scorecard = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* This resource allows you to manage a scorecard.
*
* See the [Port documentation](https://docs.getport.io/promote-scorecards/) for more information about scorecards.
*
* ## Example Usage
*
* This will create a blueprint with a Scorecard measuring the readiness of a microservice.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as port from "@pulumi/port";
*
* const microservice = new port.index.Port_blueprint("microservice", {
* title: "microservice",
* icon: "Terraform",
* identifier: "microservice",
* properties: {
* stringProps: {
* author: {
* title: "Author",
* },
* url: {
* title: "URL",
* },
* },
* booleanProps: {
* required: {
* type: "boolean",
* },
* },
* numberProps: {
* sum: {
* type: "number",
* },
* },
* },
* });
* const readiness = new port.index.Port_scorecard("readiness", {
* identifier: "Readiness",
* title: "Readiness",
* blueprint: microservice.identifier,
* rules: [
* {
* identifier: "hasOwner",
* title: "Has Owner",
* level: "Gold",
* query: {
* combinator: "and",
* conditions: [
* JSON.stringify({
* property: "$team",
* operator: "isNotEmpty",
* }),
* JSON.stringify({
* property: "author",
* operator: "=",
* value: "myValue",
* }),
* ],
* },
* },
* {
* identifier: "hasUrl",
* title: "Has URL",
* level: "Silver",
* query: {
* combinator: "and",
* conditions: [JSON.stringify({
* property: "url",
* operator: "isNotEmpty",
* })],
* },
* },
* {
* identifier: "checkSumIfRequired",
* title: "Check Sum If Required",
* level: "Bronze",
* query: {
* combinator: "or",
* conditions: [
* JSON.stringify({
* property: "required",
* operator: "=",
* value: false,
* }),
* JSON.stringify({
* property: "sum",
* operator: ">",
* value: 2,
* }),
* ],
* },
* },
* ],
* }, {
* dependsOn: [microservice],
* });
* ```
*
* ### With Levels And Filter
*
* This will override the default levels (Basic, Bronze, Silver, Gold) with the provided levels: Not Ready, Partially Ready, Ready.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as port from "@pulumi/port";
*
* const microservice = new port.index.Port_blueprint("microservice", {
* title: "microservice",
* icon: "Terraform",
* identifier: "microservice",
* properties: {
* stringProps: {
* author: {
* title: "Author",
* },
* url: {
* title: "URL",
* },
* },
* booleanProps: {
* required: {
* type: "boolean",
* },
* },
* numberProps: {
* sum: {
* type: "number",
* },
* },
* },
* });
* const readiness = new port.index.Port_scorecard("readiness", {
* identifier: "Readiness",
* title: "Readiness",
* blueprint: microservice.identifier,
* filter: {
* combinator: "and",
* conditions: [JSON.stringify({
* property: "sum",
* operator: ">",
* value: 0,
* })],
* },
* levels: [
* {
* color: "red",
* title: "No Ready",
* },
* {
* color: "yellow",
* title: "Partially Ready",
* },
* {
* color: "green",
* title: "Ready",
* },
* ],
* rules: [
* {
* identifier: "hasOwner",
* title: "Has Owner",
* level: "Ready",
* query: {
* combinator: "and",
* conditions: [
* JSON.stringify({
* property: "$team",
* operator: "isNotEmpty",
* }),
* JSON.stringify({
* property: "author",
* operator: "=",
* value: "myValue",
* }),
* ],
* },
* },
* {
* identifier: "hasUrl",
* title: "Has URL",
* level: "Partially Ready",
* query: {
* combinator: "and",
* conditions: [JSON.stringify({
* property: "url",
* operator: "isNotEmpty",
* })],
* },
* },
* {
* identifier: "checkSumIfRequired",
* title: "Check Sum If Required",
* level: "Partially Ready",
* query: {
* combinator: "or",
* conditions: [
* JSON.stringify({
* property: "required",
* operator: "=",
* value: false,
* }),
* JSON.stringify({
* property: "sum",
* operator: ">",
* value: 2,
* }),
* ],
* },
* },
* ],
* }, {
* dependsOn: [microservice],
* });
* ```
*/
class Scorecard extends pulumi.CustomResource {
/**
* Get an existing Scorecard resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new Scorecard(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Scorecard. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Scorecard.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["blueprint"] = state ? state.blueprint : undefined;
resourceInputs["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["createdBy"] = state ? state.createdBy : undefined;
resourceInputs["filter"] = state ? state.filter : undefined;
resourceInputs["identifier"] = state ? state.identifier : undefined;
resourceInputs["levels"] = state ? state.levels : undefined;
resourceInputs["rules"] = state ? state.rules : undefined;
resourceInputs["title"] = state ? state.title : undefined;
resourceInputs["updatedAt"] = state ? state.updatedAt : undefined;
resourceInputs["updatedBy"] = state ? state.updatedBy : undefined;
}
else {
const args = argsOrState;
if ((!args || args.blueprint === undefined) && !opts.urn) {
throw new Error("Missing required property 'blueprint'");
}
if ((!args || args.identifier === undefined) && !opts.urn) {
throw new Error("Missing required property 'identifier'");
}
if ((!args || args.rules === undefined) && !opts.urn) {
throw new Error("Missing required property 'rules'");
}
if ((!args || args.title === undefined) && !opts.urn) {
throw new Error("Missing required property 'title'");
}
resourceInputs["blueprint"] = args ? args.blueprint : undefined;
resourceInputs["filter"] = args ? args.filter : undefined;
resourceInputs["identifier"] = args ? args.identifier : undefined;
resourceInputs["levels"] = args ? args.levels : undefined;
resourceInputs["rules"] = args ? args.rules : undefined;
resourceInputs["title"] = args ? args.title : undefined;
resourceInputs["createdAt"] = undefined /*out*/;
resourceInputs["createdBy"] = undefined /*out*/;
resourceInputs["updatedAt"] = undefined /*out*/;
resourceInputs["updatedBy"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Scorecard.__pulumiType, name, resourceInputs, opts);
}
}
exports.Scorecard = Scorecard;
/** @internal */
Scorecard.__pulumiType = 'port:index/scorecard:Scorecard';
//# sourceMappingURL=scorecard.js.map