This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1119 from ipfs/add-listing-config-profiles
feat: add methods for listing config profiles
- Loading branch information
Showing
7 changed files
with
63 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
'use strict' | ||
|
||
const moduleConfig = require('../utils/module-config') | ||
|
||
module.exports = (arg) => { | ||
const send = moduleConfig(arg) | ||
|
||
module.exports = (send, config) => { | ||
return { | ||
get: require('./get')(send), | ||
set: require('./set')(send), | ||
replace: require('./replace')(send), | ||
profile: require('./profile')(send) | ||
profiles: { | ||
apply: require('./profiles/apply')(config), | ||
list: require('./profiles/list')(config) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
'use strict' | ||
|
||
const callbackify = require('callbackify') | ||
const configure = require('../../lib/configure') | ||
|
||
module.exports = configure(({ ky }) => { | ||
return callbackify.variadic(async (profile, options) => { | ||
options = options || {} | ||
|
||
const res = await ky.post('config/profile/apply', { | ||
timeout: options.timeout, | ||
signal: options.signal, | ||
headers: options.headers, | ||
searchParams: { | ||
arg: profile, | ||
// can only pass strings or numbers as values https://github.com/sindresorhus/ky/issues/182 | ||
'dry-run': options.dryRun ? 'true' : 'false' | ||
} | ||
}) | ||
|
||
const parsed = await res.json() | ||
|
||
return { | ||
original: parsed.OldCfg, updated: parsed.NewCfg | ||
} | ||
}) | ||
}) |
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,22 @@ | ||
'use strict' | ||
|
||
const callbackify = require('callbackify') | ||
const configure = require('../../lib/configure') | ||
const toCamel = require('../../lib/object-to-camel') | ||
|
||
module.exports = configure(({ ky }) => { | ||
return callbackify.variadic(async (options) => { | ||
options = options || {} | ||
|
||
const res = await ky.get('config/profile/list', { | ||
timeout: options.timeout, | ||
signal: options.signal, | ||
headers: options.headers | ||
}) | ||
|
||
const parsed = await res.json() | ||
|
||
return parsed | ||
.map(profile => toCamel(profile)) | ||
}) | ||
}) |
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