-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Itai Gendler
authored and
Itai Gendler
committed
Apr 28, 2018
1 parent
f443322
commit afc5828
Showing
10 changed files
with
283 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const debug = require('debug')('codefresh:cli:create:pipelines2'); | ||
const Command = require('../../../Command'); | ||
const CFError = require('cf-errors'); | ||
const _ = require('lodash'); | ||
const { helm } = require('../../../../../logic').api; | ||
const { printError } = require('../../../helpers/general'); | ||
const { specifyOutputForArray } = require('../../../helpers/get'); | ||
|
||
const applyRoot = require('../../root/apply.cmd'); | ||
|
||
|
||
const command = new Command({ | ||
command: 'helm-repo [name]', | ||
aliases: [], | ||
parent: applyRoot, | ||
description: 'Update a helm repo', | ||
webDocs: { | ||
category: 'Helm Repos', | ||
title: 'Update Helm Repo', | ||
}, | ||
builder: (yargs) => { | ||
yargs | ||
.positional('name', { | ||
describe: 'Name of context', | ||
}) | ||
.option('public', { | ||
describe: 'Mark the helm repo as public', | ||
alias: 'p', | ||
type: 'boolean', | ||
default: false, | ||
}) | ||
.example('codefresh patch helm-repo my-repo -p', 'Update helm repo to be public') | ||
.example('codefresh patch helm-repo my-repo -p=false', 'Update helm repo to be private'); | ||
|
||
return yargs; | ||
}, | ||
handler: async (argv) => { | ||
const data = { | ||
name: argv.name, | ||
public: argv.public, | ||
}; | ||
|
||
await helm.updateRepo(data.name, data); | ||
console.log(`Helm repo: ${data.name} patched.`); | ||
}, | ||
}); | ||
|
||
module.exports = command; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const debug = require('debug')('codefresh:cli:create:context'); | ||
const Command = require('../../../Command'); | ||
const CFError = require('cf-errors'); | ||
const _ = require('lodash'); | ||
const { helm } = require('../../../../../logic').api; | ||
const createRoot = require('../../root/create.cmd'); | ||
|
||
const command = new Command({ | ||
command: 'helm-repo [name]', | ||
parent: createRoot, | ||
description: 'Create a Codefresh managed helm repo', | ||
usage: 'ATM it is only possible to create a helm repository against Codefresh managed helm registry', | ||
webDocs: { | ||
category: 'Helm Repos', | ||
title: 'Create Helm Repo', | ||
}, | ||
builder: (yargs) => { | ||
yargs | ||
.positional('name', { | ||
describe: 'Name of context', | ||
}) | ||
.option('public', { | ||
describe: 'Mark the helm repo as public', | ||
alias: 'p', | ||
type: 'boolean', | ||
default: false, | ||
}) | ||
.example('codefresh create helm-repo', 'Create a private helm repo managed by Codefresh.') | ||
.example('codefresh create helm-repo --public', 'Create a public helm repo managed by Codefresh.'); | ||
|
||
return yargs; | ||
}, | ||
handler: async (argv) => { | ||
const data = { | ||
name: argv.name, | ||
public: argv.public, | ||
}; | ||
|
||
await helm.createRepo(data); | ||
console.log(`Helm repo: ${data.name} created`); | ||
}, | ||
}); | ||
|
||
module.exports = command; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const debug = require('debug')('codefresh:cli:create:pipelines2'); | ||
const Command = require('../../../Command'); | ||
const CFError = require('cf-errors'); | ||
const _ = require('lodash'); | ||
const { helm } = require('../../../../../logic').api; | ||
const deleteRoot = require('../../root/delete.cmd'); | ||
|
||
|
||
const command = new Command({ | ||
command: 'helm-repo [name]', | ||
aliases: [], | ||
parent: deleteRoot, | ||
description: 'Delete a helm repo', | ||
webDocs: { | ||
category: 'Helm Repos', | ||
title: 'Delete Helm Repo', | ||
}, | ||
builder: (yargs) => { | ||
yargs | ||
.positional('name', { | ||
describe: 'Helm repo name', | ||
}) | ||
.example('codefresh delete helm-repo my-repo', 'Delete a helm repo.'); | ||
return yargs; | ||
}, | ||
handler: async (argv) => { | ||
const { name } = argv; | ||
|
||
await helm.deleteRepo(name); | ||
console.log(`Helm repo '${name}' deleted.`); | ||
}, | ||
}); | ||
|
||
|
||
module.exports = command; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const debug = require('debug')('codefresh:cli:create:pipelines2'); | ||
const Command = require('../../../Command'); | ||
const CFError = require('cf-errors'); | ||
const _ = require('lodash'); | ||
const { helm } = require('../../../../../logic').api; | ||
const { printError } = require('../../../helpers/general'); | ||
const { specifyOutputForArray } = require('../../../helpers/get'); | ||
|
||
const getRoot = require('../../root/get.cmd'); | ||
|
||
|
||
const command = new Command({ | ||
command: 'helm-repo [name..]', | ||
aliases: [], | ||
parent: getRoot, | ||
description: 'Get a specific helm-repo or an array of helm-repos', | ||
webDocs: { | ||
category: 'Helm Repos', | ||
title: 'Get Helm Repo', | ||
}, | ||
builder: (yargs) => { | ||
yargs | ||
.positional('name', { | ||
describe: 'Helm repo name', | ||
}) | ||
.example('codefresh get helm-repo', 'Get all helm repos') | ||
.example('codefresh get helm-repo my-repo', 'Get a specific helm repo'); | ||
return yargs; | ||
}, | ||
handler: async (argv) => { | ||
const { name: names, output } = argv; | ||
|
||
if (!_.isEmpty(names)) { | ||
const repos = []; | ||
for (const name of names) { | ||
try { | ||
const currRepo = await helm.getRepoByName(name); | ||
repos.push(currRepo); | ||
} catch (err) { | ||
if (repos.length) { | ||
specifyOutputForArray(output, repos); | ||
} | ||
|
||
debug(err.toString()); | ||
const message = err.toString().includes('not find') ? `Helm repo '${name}' was not found.` : 'Error occurred'; | ||
throw new CFError({ | ||
cause: err, | ||
message, | ||
}); | ||
} | ||
} | ||
specifyOutputForArray(output, repos); | ||
} else { | ||
specifyOutputForArray(output, await helm.getAllRepos()); | ||
} | ||
}, | ||
}); | ||
|
||
module.exports = command; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const moment = require('moment'); | ||
const Entity = require('./Entity'); | ||
|
||
class Pipeline extends Entity { | ||
constructor(data) { | ||
super(); | ||
this.entityType = 'helm-repo'; | ||
this.info = data; | ||
this.name = this.info.Name; | ||
this.created = moment(this.info.CreatedAt).fromNow(); | ||
this.updated = moment(this.info.UpdatedAt).fromNow(); | ||
this.public = this.info.Public.toString(); | ||
this.defaultColumns = ['name', 'public', 'created', 'updated']; | ||
this.wideColumns = this.defaultColumns.concat([]); | ||
} | ||
} | ||
|
||
module.exports = Pipeline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters