node_terminus
v1.0.11
Published
Pantheon Terminus cli wrapper and extensions
Downloads
19
Readme
Node Terminus wrapper (nt)
Both a simple wrapper, and extended workFlow objects to ease Pantheon data interactions for CI/CD Systems.
Commands are dynamically generated from Pantheons site: https://pantheon.io/docs/assets/terminus/commands.json (right now saved, file will put in place dynamic request soon)
Relies on Docker for executing commands.
Note: MACHINE_TOKEN environment variable overrides config.machine_token always.
Send results to callbackUrl:
example: nt.terminus.cmd.site_list('','',"https://thisismyoverrideurl")
Development
- Use
npm run autotest
- Add tests as you add functions.
General requirements
- Have a Pantheon machine token
Software requirements
- Docker installed and , with C:\ drive shared if running windows.
- Nodejs, obviously.
- Mocha - Globally
- Supervisor - Globally
Examples
Login to set cache, and query all sites in json.
let loginAndRun = async () => {
return nt.terminus.cmd.auth_login.run()
.then(()=>{
return nt.terminus.cmd.auth_whoami.run('')
.then(data => {
return data
})
})
.then(data => {
this.whoami = data.trim()
console.log(`Logged in as: ${this.whoami}`)
})
}
loginAndRun()
.then(() =>{
return nt.terminus.cmd.site_list.run('--format=json')
.then(data => {
return data
})
})
.then(data => {
console.log(data)
})
Query Pantheon for all sites, for each site get all envs
async function querySiteIds() {
return nt.terminus.cmd.site_list.run('--format=json')
}
let getResults = getSiteIds
async function getSiteIds() {
return querySiteIds()
.then(data => {
let sites = _.map(JSON.parse(data),d=>{
return d
})
return sites
})
}
async function addSiteEnv(site_name,site_id) {
return nt.terminus.cmd.env_list.run('--format=json',`${site_id}`)
}
getSiteIds()
.then(sites =>{
return _.each(sites,s =>{
let getEnvs = async (site_id) =>{
return nt.terminus.cmd.env_list.run('--format=json',`${site_id}`)
.then((envs) =>{
return envs
})
}
return getEnvs(s.id)
.then(envs => {
let results = {
name: s.name,
envs: envs
}
return results
})
})
})
.then(results => {
let siteResults = _.map(results,r =>{
let s = {
site: r.name,
envs: r
}
return s
});
return siteResults;
})
Query pantheon,and post results to url.
let callbackurl = "https://en59ptugt60wx.x.pipedream.net/"
nt.terminus.cmd.site_list.run('','',callbackurl)
.then(data =>{
console.log(data)
})