Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Define repo on add/remove commands + guarding (#57)
Browse files Browse the repository at this point in the history
* define commands

Signed-off-by: Andrew Mak <[email protected]>

* rename

Signed-off-by: Andrew Mak <[email protected]>

* add directive

Signed-off-by: Andrew Mak <[email protected]>

* rename

Signed-off-by: Andrew Mak <[email protected]>

* controller workaround

Signed-off-by: Andrew Mak <[email protected]>

* pulling in 0.4.8

Signed-off-by: Andrew Mak <[email protected]>

* backout some change

Signed-off-by: Andrew Mak <[email protected]>

* back out a change

Signed-off-by: Andrew Mak <[email protected]>

* commands + better guarding

Signed-off-by: Andrew Mak <[email protected]>
  • Loading branch information
makandre authored and sghung committed Nov 4, 2019
1 parent 7c9763a commit b72b7cf
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 33 deletions.
14 changes: 14 additions & 0 deletions codewind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ commands:
- init
- $subtype
- none
- name: onRepositoryAdd
command: appsody
args:
- repo
- add
- $id
- $url,.yaml
- name: onRepositoryRemove
command: appsody
args:
- repo
- remove
- $id
detection: .appsody-config.yaml
config:
containerAppRoot: /project/user-app
needsMount: true
style: Appsody
78 changes: 45 additions & 33 deletions templatesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,33 @@ module.exports = {
getRepositories: async function() {

const repos = [];

const result = await exec(`${__dirname}/appsody repo list -o json`);
const json = JSON.parse(result.stdout);

try {
const result = await exec(`${__dirname}/appsody repo list -o json`);
const json = JSON.parse(result.stdout);

for (const repo of json.repositories) {
for (const repo of json.repositories) {

const name = repo.name;
let url = repo.url;
const name = repo.name;
let url = repo.url;

if (name != 'experimental' && url.endsWith('index.yaml')) {
if (name != 'experimental' && url.endsWith('index.yaml')) {

url = url.substring(0, url.length - 10) + 'index.json';
url = url.substring(0, url.length - 10) + 'index.json';

repos.push({
id: name,
name: `Appsody Stacks - ${name}`,
description: 'Use Appsody in Codewind to develop applications with sharable technology stacks.',
url
});
repos.push({
id: name,
name: `Appsody Stacks - ${name}`,
description: 'Use Appsody in Codewind to develop applications with sharable technology stacks.',
url
});
}
}
}
catch (err) {
console.error('Appsody extension: failed to retrieve repositories');
console.error(err.message);
}

return repos;
},
Expand All @@ -72,27 +78,33 @@ module.exports = {

const projectTypes = [];

const result = await exec(`${__dirname}/appsody list ${id} -o json`);
const json = JSON.parse(result.stdout);

for (const repo of json.repositories) {

for (const stack of repo.stacks) {

projectTypes.push({
projectType: 'appsodyExtension',
projectSubtypes: {
label: 'Appsody stack',
items: [{
id: `${repo.repositoryName}/${stack.id}`,
version: stack.version,
label: `Appsody ${stack.id}`,
description: stack.description
}]
}
});
try {
const result = await exec(`${__dirname}/appsody list ${id} -o json`);
const json = JSON.parse(result.stdout);

for (const repo of json.repositories) {

for (const stack of repo.stacks) {

projectTypes.push({
projectType: 'appsodyExtension',
projectSubtypes: {
label: 'Appsody stack',
items: [{
id: `${repo.repositoryName}/${stack.id}`,
version: stack.version,
label: `Appsody ${stack.id}`,
description: stack.description
}]
}
});
}
}
}
catch (err) {
console.error('Appsody extension: failed to retrieve project types');
console.error(err.message);
}

return projectTypes;
}
Expand Down

0 comments on commit b72b7cf

Please sign in to comment.