Skip to content

Commit

Permalink
Lint remaining issues and add tslint to makefile (pulumi#383)
Browse files Browse the repository at this point in the history
* Lint remaining issues and add tslint to makefile

* Install tslint

* Install typescript for tslint
  • Loading branch information
mikhailshilkov authored and stack72 committed Sep 9, 2019
1 parent 76cdb38 commit 70c1834
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 68 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
.PHONY: ensure only_build only_test all

all: only_build only_test
all: install only_build lint only_test

install:
yarn global add tslint typescript

ensure:
cd misc/test && GO111MODULE=on go mod vendor

only_build:

lint:
tslint -c tslint.json **/*.ts

only_test:
go test ./misc/test/... --timeout 4h -v -count=1 -short -parallel 40

Expand Down
2 changes: 1 addition & 1 deletion aws-ts-assume-role/assume-role/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config();
const roleToAssumeARN = config.require("roleToAssumeARN");
Expand Down
10 changes: 5 additions & 5 deletions aws-ts-assume-role/create-role/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config();
const unprivilegedUsername = config.require("unprivilegedUsername");
Expand All @@ -17,11 +17,11 @@ const unprivilegedUserCreds = new aws.iam.AccessKey("unprivileged-user-key", {
const allowS3ManagementRole = new aws.iam.Role("allow-s3-management", {
description: "Allow management of S3 buckets",
assumeRolePolicy: unprivilegedUser.arn.apply(arn => {
return aws.iam.assumeRolePolicyForPrincipal({AWS: arn})
return aws.iam.assumeRolePolicyForPrincipal({AWS: arn});
}),
});

new aws.iam.RolePolicy("allow-s3-management-policy", {
const policy = new aws.iam.RolePolicy("allow-s3-management-policy", {
role: allowS3ManagementRole,
policy: {
Version: "2012-10-17",
Expand All @@ -30,8 +30,8 @@ new aws.iam.RolePolicy("allow-s3-management-policy", {
Effect: "Allow",
Resource: "*",
Action: "s3:*",
}]
}
}],
},
}, {parent: allowS3ManagementRole});

export const roleArn = allowS3ManagementRole.arn;
Expand Down
4 changes: 2 additions & 2 deletions aws-ts-stackreference/team/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

/**
* company
Expand All @@ -19,7 +19,7 @@ const combinedTags = {
/* from department stack */ department: departmentStack.getOutput("departmentName"),
/* from team config */ team: config.require("teamName"),
"Managed By": "Pulumi",
}
};

const amiId = aws.getAmi({
mostRecent: true,
Expand Down
18 changes: 9 additions & 9 deletions azure-ts-appservice-devops/infra/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
import * as pulumi from "@pulumi/pulumi";

// use first 10 characters of the stackname as prefix for resource names
const prefix = pulumi.getStack().substring(0, 9);
Expand Down Expand Up @@ -51,15 +51,15 @@ const blob = new azure.storage.ZipBlob(`${prefix}-b`, {
storageContainerName: storageContainer.name,
type: "block",

content: new pulumi.asset.FileArchive("../src/bin/Debug/netcoreapp2.1/publish")
content: new pulumi.asset.FileArchive("../src/bin/Debug/netcoreapp2.1/publish"),
});

const codeBlobUrl = azure.storage.signedBlobReadUrl(blob, storageAccount);

const appInsights = new azure.appinsights.Insights(`${prefix}-ai`, {
...resourceGroupArgs,

applicationType: "Web"
applicationType: "Web",
});


Expand All @@ -79,7 +79,7 @@ const sqlServer = new azure.sql.SqlServer(`${prefix}-sql`, {
const database = new azure.sql.Database(`${prefix}-db`, {
...resourceGroupArgs,
serverName: sqlServer.name,
requestedServiceObjectiveName: "S0"
requestedServiceObjectiveName: "S0",
});

const app = new azure.appservice.AppService(`${prefix}-as`, {
Expand All @@ -92,26 +92,26 @@ const app = new azure.appservice.AppService(`${prefix}-as`, {
"WEBSITE_RUN_FROM_ZIP": codeBlobUrl,
"ApplicationInsights:InstrumentationKey": appInsights.instrumentationKey,
"APPINSIGHTS_INSTRUMENTATIONKEY": appInsights.instrumentationKey,
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
},

connectionStrings: [{
name: "MyDbConnection",
value:
pulumi.all([sqlServer.name, database.name]).apply(([server, db]) =>
`Server=tcp:${server}.database.windows.net;initial catalog=${db};user ID=${username};password=${pwd};Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;`),
type: "SQLAzure"
}]
type: "SQLAzure",
}],
});

const firewallRules = app.outboundIpAddresses.apply(
ips => ips.split(',').map(
ips => ips.split(",").map(
ip => new azure.sql.FirewallRule(`FR${ip}`, {
endIpAddress: ip,
resourceGroupName: resourceGroup.name,
serverName: sqlServer.name,
startIpAddress: ip,
})
}),
));

export const endpoint = pulumi.interpolate `https://${app.defaultSiteHostname}`;
2 changes: 1 addition & 1 deletion azure-ts-appservice-springboot/infrastructure/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
import * as docker from "@pulumi/docker";
import * as pulumi from "@pulumi/pulumi";

// Create an Azure Resource Group
const resourceGroup = new azure.core.ResourceGroup("jenkins-tutorial-group");
Expand Down
4 changes: 2 additions & 2 deletions f5bigip-ts-ltm-pool/f5bigip-ec2-instance/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

import * as fs from "fs";

Expand Down Expand Up @@ -39,7 +39,7 @@ const bigIpAmiId = aws.getAmi({
filters: [
{ name: "product-code", values: ["8esk90vx7v713sa0muq2skw3j"] },
{ name: "name", values: ["F5 Networks BIGIP-14.0.0.1-0.0.2 PAYG - Good 25Mbps *"] },
]
],
}).then(ami => ami.id);

const bigIpUserData =
Expand Down
4 changes: 2 additions & 2 deletions f5bigip-ts-ltm-pool/f5bigip-pool/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as f5bigip from "@pulumi/f5bigip";
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config();
const backendInstances = config.require("backendInstances").split(',');
const backendInstances = config.require("backendInstances").split(",");

const baseTags = {
project: `${pulumi.getProject()}-${pulumi.getStack()}`,
Expand Down
6 changes: 3 additions & 3 deletions f5bigip-ts-ltm-pool/nginx-ec2-instance/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

const baseTags = {
project: `${pulumi.getProject()}-${pulumi.getStack()}`,
Expand All @@ -13,7 +13,7 @@ const ubuntuAmiId = aws.getAmi({
owners: ["099720109477"],
}).then(ami => ami.id);

let nginxUserData =
const nginxUserData =
`#!/bin/bash
apt -y update
apt -y install nginx
Expand All @@ -34,7 +34,7 @@ const nginxSecGroup = new aws.ec2.SecurityGroup("nginx", {
tags: Object.assign({ Name: `nginx` }, baseTags),
});

let nginxInstances = [];
const nginxInstances = [];
for (let i = 0; i < 3; i++) {
const nginxInstance = new aws.ec2.Instance(`nginx-${i}`, {
ami: ubuntuAmiId,
Expand Down
2 changes: 1 addition & 1 deletion gcp-ts-k8s-ruby-on-rails-postgresql/infra/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const cluster = new gcp.container.Cluster("gke-cluster", {
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring"
"https://www.googleapis.com/auth/monitoring",
],
},
});
Expand Down
14 changes: 7 additions & 7 deletions kubernetes-ts-guestbook/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
import * as pulumi from "@pulumi/pulumi";
import * as k8sjs from "./k8sjs";

let config = new pulumi.Config();
const config = new pulumi.Config();

let redisMaster = new k8sjs.ServiceDeployment("redis-master", {
const redisMaster = new k8sjs.ServiceDeployment("redis-master", {
image: "k8s.gcr.io/redis:e2e",
ports: [6379]
ports: [6379],
});

let redisReplica = new k8sjs.ServiceDeployment("redis-replica", {
const redisReplica = new k8sjs.ServiceDeployment("redis-replica", {
image: "gcr.io/google_samples/gb-redisslave:v1",
ports: [6379]
ports: [6379],
});

let frontend = new k8sjs.ServiceDeployment("frontend", {
const frontend = new k8sjs.ServiceDeployment("frontend", {
replicas: 3,
image: "gcr.io/google-samples/gb-frontend:v4",
ports: [80],
allocateIpAddress: true,
isMinikube: config.getBoolean("isMinikube")
isMinikube: config.getBoolean("isMinikube"),
});

export let frontendIp = frontend.ipAddress;
68 changes: 34 additions & 34 deletions kubernetes-ts-guestbook/simple/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
import * as pulumi from "@pulumi/pulumi";

// Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're
// running on minikube, and if so, create only services of type ClusterIP.
let config = new pulumi.Config();
let isMinikube = config.getBoolean("isMinikube");
const config = new pulumi.Config();
const isMinikube = config.getBoolean("isMinikube");

//
// REDIS MASTER.
//

let redisMasterLabels = { app: "redis-master" };
let redisMasterDeployment = new k8s.apps.v1.Deployment("redis-master", {
const redisMasterLabels = { app: "redis-master" };
const redisMasterDeployment = new k8s.apps.v1.Deployment("redis-master", {
spec: {
selector: { matchLabels: redisMasterLabels },
template: {
Expand All @@ -24,29 +24,29 @@ let redisMasterDeployment = new k8s.apps.v1.Deployment("redis-master", {
name: "master",
image: "k8s.gcr.io/redis:e2e",
resources: { requests: { cpu: "100m", memory: "100Mi" } },
ports: [{ containerPort: 6379 }]
}
]
}
}
}
ports: [{ containerPort: 6379 }],
},
],
},
},
},
});
let redisMasterService = new k8s.core.v1.Service("redis-master", {
const redisMasterService = new k8s.core.v1.Service("redis-master", {
metadata: {
labels: redisMasterDeployment.metadata.labels
labels: redisMasterDeployment.metadata.labels,
},
spec: {
ports: [{ port: 6379, targetPort: 6379 }],
selector: redisMasterDeployment.spec.template.metadata.labels,
}
},
});

//
// REDIS REPLICA.
//

let redisReplicaLabels = { app: "redis-replica" };
let redisReplicaDeployment = new k8s.apps.v1.Deployment("redis-replica", {
const redisReplicaLabels = { app: "redis-replica" };
const redisReplicaDeployment = new k8s.apps.v1.Deployment("redis-replica", {
spec: {
selector: { matchLabels: redisReplicaLabels },
template: {
Expand All @@ -60,27 +60,27 @@ let redisReplicaDeployment = new k8s.apps.v1.Deployment("redis-replica", {
// If your cluster config does not include a dns service, then to instead access an environment
// variable to find the master service's host, change `value: "dns"` to read `value: "env"`.
env: [{ name: "GET_HOSTS_FROM", value: "dns" }],
ports: [{ containerPort: 6379 }]
}
]
}
}
}
ports: [{ containerPort: 6379 }],
},
],
},
},
},
});
let redisReplicaService = new k8s.core.v1.Service("redis-replica", {
const redisReplicaService = new k8s.core.v1.Service("redis-replica", {
metadata: { labels: redisReplicaDeployment.metadata.labels },
spec: {
ports: [{ port: 6379, targetPort: 6379 }],
selector: redisReplicaDeployment.spec.template.metadata.labels,
}
},
});

//
// FRONTEND
//

let frontendLabels = { app: "frontend" };
let frontendDeployment = new k8s.apps.v1.Deployment("frontend", {
const frontendLabels = { app: "frontend" };
const frontendDeployment = new k8s.apps.v1.Deployment("frontend", {
spec: {
selector: { matchLabels: frontendLabels },
replicas: 3,
Expand All @@ -95,20 +95,20 @@ let frontendDeployment = new k8s.apps.v1.Deployment("frontend", {
// If your cluster config does not include a dns service, then to instead access an environment
// variable to find the master service's host, change `value: "dns"` to read `value: "env"`.
env: [{ name: "GET_HOSTS_FROM", value: "dns" /* value: "env"*/ }],
ports: [{ containerPort: 80 }]
}
]
}
}
}
ports: [{ containerPort: 80 }],
},
],
},
},
},
});
let frontendService = new k8s.core.v1.Service("frontend", {
const frontendService = new k8s.core.v1.Service("frontend", {
metadata: { labels: frontendDeployment.metadata.labels },
spec: {
type: isMinikube ? "ClusterIP" : "LoadBalancer",
ports: [{ port: 80 }],
selector: frontendDeployment.spec.template.metadata.labels,
}
},
});

// Export the frontend IP.
Expand Down

0 comments on commit 70c1834

Please sign in to comment.