Skip to content

Commit b7f4f54

Browse files
Merge pull request #8 from datawire/aglez/dev/cache
Aglez/dev/cache
2 parents d75e6e6 + 3eb19eb commit b7f4f54

File tree

1,957 files changed

+258702
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,957 files changed

+258702
-12
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Default ignored files
2+
/shelf/
3+
/.idea/workspace.xml
4+
# Editor-based HTTP Client requests
5+
/httpRequests/
6+
# Datasource local storage ignored files
7+
/dataSources/
8+
/dataSources.local.xml
9+
/.idea/

configure/action.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'Configure Telepresence on the repository'
2+
description: 'Set the configuration to use telepresence in the repository'
3+
inputs:
4+
version:
5+
description: The version of telepresence to use
6+
required: false
7+
default: latest
8+
runs:
9+
using: 'node16'
10+
main: 'configure.js'

configure/configure.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const core = require('@actions/core');
2+
const exec = require('@actions/exec');
3+
const io = require('@actions/io');
4+
const configure = require('../src/configure');
5+
const installTelepresence = require('../src/install');
6+
const cache = require('@actions/cache');
7+
8+
const telepresenceConfiguring = async function () {
9+
const isInstalled = await installTelepresence.telepresenceInstall();
10+
if(!isInstalled)
11+
return;
12+
13+
const path = configure.getTelepresenceConfigPath();
14+
const telepresenceConfigDir = [path];
15+
16+
try {
17+
await io.mkdirP(path);
18+
await cache.restoreCache(telepresenceConfigDir, configure.TELEPRESENCE_CACHE_KEY);
19+
} catch (error) {
20+
core.warning(`Unable to find the telepresence id: ${error}`);
21+
}
22+
try {
23+
await exec.exec(`${installTelepresence.TP_PATH}/telepresence`, ['connect']);
24+
} catch (error) {
25+
core.setFailed(error.message);
26+
return;
27+
}
28+
try {
29+
const cacheKey = await cache.saveCache(telepresenceConfigDir, configure.TELEPRESENCE_CACHE_KEY);
30+
if (!cacheKey)
31+
core.setFailed('Unable to save the telepresence key cache');
32+
} catch (error) {
33+
core.setFailed(error.message);
34+
}
35+
}
36+
37+
38+
telepresenceConfiguring();

connect/connect.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
const core = require('@actions/core')
22
const exec = require('@actions/exec');
3+
const configure = require("../src/configure");
34

45
const telepresenceConnect = async function(){
6+
const isConfigured = await configure.getConfiguration();
7+
if(!isConfigured)
8+
return;
59
try {
610
await exec.exec('telepresence', ['connect']);
711
core.saveState("telepresence_connected", true)

install/action.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
name: 'Install Telepresence'
2-
description: 'Install a specific version of Telepresence'
1+
name: 'Telepresence Install'
2+
description: 'Installs an specific version of telepresence'
33
inputs:
44
version:
5-
description: Version of Telepresence to install. The latest version is selected as default.
5+
description: Version of Telepresence to Install
66
required: false
77
default: latest
88
runs:
9-
using: "composite"
10-
steps:
11-
- name: Install Telepresence
12-
shell: bash
13-
run: |
14-
sudo curl -fL https://app.getambassador.io/download/tel2/linux/amd64/${{inputs.version}}/telepresence -o /usr/local/bin/telepresence
15-
sudo chmod a+x /usr/local/bin/telepresence
9+
using: 'node16'
10+
main: 'install.js'

install/install.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const install = require('../src/install');
2+
3+
install.telepresenceInstall();

intercept/intercept.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
const artifact = require('@actions/artifact');
22
const core = require('@actions/core')
33
const exec = require('@actions/exec');
4+
const configure = require('../src/configure');
45

56
const telepresenceIntercept = async function(){
7+
const isConfigured = await configure.getConfiguration();
8+
if(!isConfigured)
9+
return;
610
try {
711
const service_name = core.getInput('service_name');
812
const service_port = core.getInput('service_port');

login/login.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
const core = require('@actions/core')
22
const exec = require('@actions/exec');
33
const AmbassadorClient = require('../ambassador/api-client');
4+
const configure = require("../src/configure");
45

56
const telepresenceLogin = async function(){
7+
const isConfigured = await configure.getConfiguration();
8+
if(!isConfigured)
9+
return;
610
const apiKey = core.getInput('telepresence_api_key');
711
if (!apiKey) {
812
core.setFailed('telepresence_api_key is required');

node_modules/.bin/semver

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)