Skip to content

Commit aeb520f

Browse files
committed
merge conflicts
2 parents 13448e6 + d2e6200 commit aeb520f

File tree

21 files changed

+2145
-1494
lines changed

21 files changed

+2145
-1494
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
v0.0.14
2+
---
3+
- Small patch removing forced failures on docker build to prevent failures on warnings
4+
5+
v0.0.13
6+
---
7+
- Add spinner on deploy command
8+
- Change getCredential error handling to only log source error on verbose channel
9+
10+
v0.0.12
11+
---
12+
- Adding sample dashboard for general AWS
13+
14+
v0.0.11
15+
---
16+
- README updates
17+
18+
v0.0.10
19+
---
20+
Fix signup url. Add providers to cli widgets in samples.
21+
122
v0.0.9
223
---
324
- added graceful failure to docker network rm if network does not exist

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,22 @@ Sample dashboard configurations can be found in the `/samples` folder in this re
118118
|Widget|Widgets are components that have two functions: render and getData. getData is called in the API’s server and is used to make external requests, do computations, etc. Once it is called, it sets some data on the widget itself that’s passed back to the frontend, where render is called to display the widget.
119119
|Providers|Providers are the beating hearts of the Console. They can be long running and run in the background. They may be passed to widgets to provide sensitive information or long-lived information, whereas widgets are better written as quick request/response styled objects.
120120

121+
### Providers
122+
Currently supports AWS with plans to add others! AWS provider can be configured with local profiles or Access/Secret keys.
123+
#### AWS
124+
```
125+
providers:
126+
AwsLocalProvider:
127+
id: AwsLocalProvider
128+
type: AwsCredentialsProvider
129+
credentials:
130+
# Option A: local credentials
131+
profileName: default
132+
# Option B: Access/Secret keys (required when deploying with ops-cli deploy)
133+
# AwsAccessKeyId:
134+
# AwsSecretAccessKey:
135+
```
136+
121137
### [Core widgets](https://github.com/tinystacks/ops-core-widgets)
122138
|Name|Description|
123139
|---------|---------|

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = {
2424
"src/utils/ops-stack-api-utils/get-client.ts",
2525
"src/utils/ops-stack-api-utils/index.ts",
2626
"src/utils/ops-core/index.ts",
27-
"src/utils/open/index.ts"
27+
"src/utils/open/index.ts",
28+
"src/utils/spinner/index.ts"
2829
]
2930
};

package-lock.json

Lines changed: 1649 additions & 1248 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tinystacks/ops-cli",
3-
"version": "0.0.9",
3+
"version": "0.0.14",
44
"description": "",
55
"main": "dist/index.js",
66
"bin": {
@@ -71,6 +71,7 @@
7171
"js-yaml": "^4.1.0",
7272
"lodash.isnil": "^4.0.0",
7373
"open": "^9.1.0",
74+
"ora": "^6.3.0",
7475
"prompts": "^2.4.2"
7576
}
7677
}

samples/aws-sample.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
Console:
2+
name: console
3+
providers:
4+
AwsLocalProvider:
5+
id: AwsLocalProvider
6+
type: AwsCredentialsProvider
7+
credentials:
8+
profileName: default
9+
dashboards:
10+
LayoutDashboard:
11+
route: main
12+
widgets:
13+
- $ref: '#/Console/widgets/SmallMarkdown'
14+
- $ref: '#/Console/widgets/Metrics'
15+
- $ref: '#/Console/widgets/Logs'
16+
- $ref: '#/Console/widgets/BillingCommands'
17+
id: LayoutDashboard
18+
widgets:
19+
SmallMarkdown:
20+
id: SmallMarkdown
21+
type: Markdown
22+
displayName: Small Markdown Window
23+
markdown: |
24+
##### This is fully supported markdown
25+
``` You can even drop in some code if you want ```
26+
providers: []
27+
children: []
28+
BillingCommands:
29+
id: BillingCommands
30+
type: Tabs
31+
displayName: Billing CLI Commands
32+
tabNames:
33+
- Current Month Bill
34+
- List EC2 Instances
35+
providers: []
36+
children:
37+
- $ref: '#/Console/widgets/CurrentMonthBill'
38+
- $ref: '#/Console/widgets/EC2Instances'
39+
CurrentMonthBill:
40+
id: CurrentMonthBill
41+
type: Cli
42+
displayName: Current Month Bill
43+
command: >
44+
aws ce get-cost-and-usage --time-period Start=$(date +%Y-%m-01),End=$(date +%Y-%m-%d) --granularity MONTHLY --metrics BlendedCost
45+
runOnStart: true
46+
providers: []
47+
children: []
48+
EC2Instances:
49+
id: EC2Instances
50+
type: Cli
51+
displayName: List EC2 Instances
52+
command: >
53+
aws ec2 describe-instances --query "Reservations[*].Instances[*].Tags[?Key=='Name'].Value[]" --output text
54+
runOnStart: true
55+
providers: []
56+
children: []
57+
Metrics:
58+
id: Metrics
59+
type: Grid
60+
displayName: EC2 Metrics
61+
providers: []
62+
children:
63+
- $ref: '#/Console/widgets/CPUMetrics'
64+
- $ref: '#/Console/widgets/NetworkMetrics'
65+
CPUMetrics:
66+
id: CPUMetrics
67+
type: AwsCloudWatchMetricGraph
68+
displayName: CPU Utilization - All Instances
69+
metrics:
70+
- metricNamespace: AWS/EC2
71+
metricName: CPUUtilization
72+
metricDisplayName: Average
73+
statistic: Average
74+
dimensions: []
75+
- metricNamespace: AWS/EC2
76+
metricName: CPUUtilization
77+
metricDisplayName: Max
78+
statistic: Maximum
79+
dimensions: []
80+
- metricNamespace: AWS/EC2
81+
metricName: CPUUtilization
82+
metricDisplayName: Min
83+
statistic: Minimum
84+
dimensions: []
85+
timeRange:
86+
time: 12
87+
unit: h
88+
region: us-east-1
89+
providers:
90+
- $ref: '#/Console/providers/AwsLocalProvider'
91+
children: []
92+
NetworkMetrics:
93+
id: NetworkMetrics
94+
type: AwsCloudWatchMetricGraph
95+
displayName: NetworkIn - All Instances
96+
metrics:
97+
- metricNamespace: AWS/EC2
98+
metricName: NetworkIn
99+
metricDisplayName: NetworkIn
100+
statistic: Average
101+
dimensions: []
102+
- metricNamespace: AWS/EC2
103+
metricName: NetworkOut
104+
metricDisplayName: NetworkOut
105+
statistic: Average
106+
dimensions: []
107+
timeRange:
108+
time: 12
109+
unit: h
110+
region: us-east-1
111+
providers:
112+
- $ref: '#/Console/providers/AwsLocalProvider'
113+
children: []
114+
Logs:
115+
id: Logs
116+
type: AwsCloudWatchLogs
117+
displayName: Service Logs
118+
region: us-east-1
119+
logGroupName: INSERT_LOG_GROUP_NAME_HERE
120+
timeRange:
121+
time: 12
122+
unit: h
123+
events: []
124+
providers:
125+
- $ref: '#/Console/providers/AwsLocalProvider'
126+
children: []
127+
dependencies:
128+
Markdown: '@tinystacks/ops-core-widgets'
129+
Tabs: '@tinystacks/ops-core-widgets'
130+
Grid: '@tinystacks/ops-core-widgets'
131+
Cli: '@tinystacks/ops-core-widgets'
132+
Panel: '@tinystacks/ops-core-widgets'
133+
AwsCloudWatchLogs: '@tinystacks/ops-aws-core-widgets'
134+
AwsCredentialsProvider: '@tinystacks/ops-aws-core-widgets'
135+
AwsCloudWatchMetricGraph: '@tinystacks/ops-aws-core-widgets'

samples/ecs-dashboard-sample.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ Console:
273273
EcsProcesses:
274274
type: Cli
275275
displayName: List processes
276+
providers:
277+
- $ref: '#/Console/providers/AwsLocalProvider'
276278
environmentVariables:
277279
AWS_REGION:
278280
$ref: '#/Console/widgets/EcsInfo'
@@ -288,6 +290,8 @@ Console:
288290
EcsDiskUtil:
289291
type: Cli
290292
displayName: Show Disk Utils
293+
providers:
294+
- $ref: '#/Console/providers/AwsLocalProvider'
291295
environmentVariables:
292296
AWS_REGION:
293297
$ref: '#/Console/widgets/EcsInfo'
@@ -303,6 +307,8 @@ Console:
303307
EcsNetworkConnectivity:
304308
type: Cli
305309
displayName: Internet Connectivity
310+
providers:
311+
- $ref: '#/Console/providers/AwsLocalProvider'
306312
environmentVariables:
307313
AWS_REGION:
308314
$ref: '#/Console/widgets/EcsInfo'

src/commands/deploy/index.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import * as fs from 'fs';
22
import path from 'path';
33
import HttpError from 'http-errors';
4-
import { HostedOpsConsole, OpsStackApiClient } from '@tinystacks/ops-stack-client';
4+
import { HostedOpsConsole, OpsStackApiClient, Status } from '@tinystacks/ops-stack-client';
55
import logger from '../../logger';
66
import { CommonOptions } from '../../types';
77
import { parseConfig } from '../../utils/config';
88
import { DEFAULT_CONFIG_FILENAME } from '../../constants';
99
import { getCredentials, getClient } from '../../utils/ops-stack-api-utils';
10+
import { getSpinner } from '../../utils/spinner';
11+
import { sleep } from '../../utils/os';
1012

1113
async function checkIfConsoleExists (consoleName: string, opsStackClient: OpsStackApiClient): Promise<boolean | never> {
1214
try {
13-
1415
const consoleStacks = await opsStackClient.allocate.getOpsStack(consoleName);
1516
const [consoleStack] = consoleStacks || [];
1617
if (consoleStack && consoleStack.name === consoleName) return true;
@@ -25,7 +26,28 @@ async function checkIfConsoleExists (consoleName: string, opsStackClient: OpsSta
2526
}
2627
}
2728

29+
async function waitForStackToSync (opsStackClient: OpsStackApiClient, consoleName: string): Promise<void> {
30+
const tenSeconds = 10 * 1000;
31+
await sleep(tenSeconds);
32+
33+
const consoleStacks = await opsStackClient.allocate.getOpsStack(consoleName);
34+
const [consoleStack] = consoleStacks || [];
35+
if (consoleStack && consoleStack.name === consoleName) {
36+
if (consoleStack.status === Status.IN_SYNC) {
37+
return;
38+
} else if (consoleStack.status === Status.SYNC_FAILED) {
39+
throw new Error('Failed to deploy ops console!');
40+
}
41+
return waitForStackToSync(opsStackClient, consoleName);
42+
}
43+
throw consoleStack;
44+
}
45+
2846
async function deploy (options: CommonOptions) {
47+
const spinner = await getSpinner({
48+
text: 'Initializing...',
49+
color: 'blue'
50+
});
2951
try {
3052
const {
3153
configFile
@@ -37,6 +59,7 @@ async function deploy (options: CommonOptions) {
3759
const { apiKey } = getCredentials();
3860
const opsStackClient = getClient(apiKey);
3961
const consoleExists = await checkIfConsoleExists(name, opsStackClient);
62+
spinner.start();
4063
let response: HostedOpsConsole | HttpError.HttpError;
4164
if (consoleExists) {
4265
response = await opsStackClient.allocate.updateOpsStack(name, configFileContents);
@@ -46,9 +69,14 @@ async function deploy (options: CommonOptions) {
4669
if (HttpError.isHttpError(response)) {
4770
throw response;
4871
}
49-
logger.success('Successful started ops console deployment!');
72+
spinner.text = 'Deploying...';
73+
spinner.color = 'green';
74+
await waitForStackToSync(opsStackClient, name);
75+
spinner.stop();
76+
logger.success('Successfully deployed ops console!');
5077
logger.stdout(JSON.stringify(response, null, 2));
5178
} catch (error) {
79+
spinner.stop();
5280
logger.error(`Error deploying ops console: ${error}`);
5381
}
5482
}

src/commands/signup/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function signup (options: SignupOptions = {}) {
1919
openCommand = 'xdg-open';
2020
break;
2121
}
22-
logger.info('Opening https://ops.tinystacks.com in your default browser...');
23-
execSync(`${openCommand} https://ops.tinystacks.com`);
22+
logger.info('Opening https://ops.tinystacks.com/sign-up in your default browser...');
23+
execSync(`${openCommand} https://ops.tinystacks.com/sign-up`);
2424
} catch (e) {
2525
logger.error(`Error during signup: ${e}`);
2626
}

0 commit comments

Comments
 (0)