Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 740515f

Browse files
committed
chore: add more getAll
1 parent c5973cd commit 740515f

File tree

10 files changed

+32
-30
lines changed

10 files changed

+32
-30
lines changed

packages/ipfs/src/core/components/bootstrap/add.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = ({ repo }) => {
1212
throw new Error(`${multiaddr} is not a valid Multiaddr`)
1313
}
1414

15-
const config = await repo.config.get()
15+
const config = await repo.config.getAll()
1616
if (options.default) {
1717
config.Bootstrap = defaultConfig().Bootstrap
1818
} else if (multiaddr && config.Bootstrap.indexOf(multiaddr) === -1) {

packages/ipfs/src/core/components/bootstrap/rm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = ({ repo }) => {
1212
}
1313

1414
let res = []
15-
const config = await repo.config.get()
15+
const config = await repo.config.getAll()
1616

1717
if (options.all) {
1818
res = config.Bootstrap || []

packages/ipfs/src/core/components/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ async function initNewRepo (repo, { privateKey, emptyRepo, bits, profiles, confi
227227
}
228228

229229
async function initExistingRepo (repo, { config: newConfig, profiles, pass }) {
230-
let config = await repo.config.get()
230+
let config = await repo.config.getAll()
231231

232232
if (newConfig || profiles) {
233233
if (profiles) {

packages/ipfs/src/core/components/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = ({
3434
await repo.open()
3535
}
3636

37-
const config = await repo.config.get()
37+
const config = await repo.config.getAll()
3838
const addrs = []
3939

4040
if (config.Addresses && config.Addresses.Swarm) {

packages/ipfs/src/http/api/resources/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ exports.getOrSet = {
9999

100100
let originalConfig
101101
try {
102-
originalConfig = await ipfs.config.get(undefined, {
102+
originalConfig = await ipfs.config.getAll({
103103
signal,
104104
timeout
105105
})
@@ -172,7 +172,7 @@ exports.get = {
172172

173173
let config
174174
try {
175-
config = await ipfs.config.get(undefined, {
175+
config = await ipfs.config.getAll({
176176
signal,
177177
timeout
178178
})
@@ -215,7 +215,7 @@ exports.show = {
215215

216216
let config
217217
try {
218-
config = await ipfs.config.get(undefined, {
218+
config = await ipfs.config.getAll({
219219
signal,
220220
timeout
221221
})

packages/ipfs/src/http/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class HttpApi {
5454

5555
const ipfs = this._ipfs
5656

57-
const config = await ipfs.config.get()
57+
const config = await ipfs.config.getAll()
5858
config.Addresses = config.Addresses || {}
5959

6060
const apiAddrs = config.Addresses.API

packages/ipfs/test/cli/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('config', () => {
1414
ipfs = {
1515
config: {
1616
set: sinon.stub(),
17+
getAll: sinon.stub(),
1718
get: sinon.stub(),
1819
replace: sinon.stub(),
1920
profiles: {
@@ -87,15 +88,15 @@ describe('config', () => {
8788

8889
describe('show', function () {
8990
it('returns the full config', async () => {
90-
ipfs.config.get.withArgs({
91+
ipfs.config.getAll.withArgs({
9192
timeout: undefined
9293
}).returns({ foo: 'bar' })
9394
const out = await cli('config show', { ipfs })
9495
expect(JSON.parse(out)).to.be.eql({ foo: 'bar' })
9596
})
9697

9798
it('returns the full config with a timeout', async () => {
98-
ipfs.config.get.withArgs({
99+
ipfs.config.getAll.withArgs({
99100
timeout: 1000
100101
}).returns({ foo: 'bar' })
101102
const out = await cli('config show --timeout=1s', { ipfs })

packages/ipfs/test/core/create-node.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('create node', function () {
3434
preload: { enabled: false }
3535
})
3636

37-
const config = await node.config.get()
37+
const config = await node.config.getAll()
3838
expect(config.Identity).to.exist()
3939
await node.stop()
4040
})
@@ -53,7 +53,7 @@ describe('create node', function () {
5353
preload: { enabled: false }
5454
})
5555

56-
const config = await node.config.get()
56+
const config = await node.config.getAll()
5757
expect(config.Identity).to.exist()
5858
await node.stop()
5959
})
@@ -104,7 +104,7 @@ describe('create node', function () {
104104
preload: { enabled: false }
105105
})
106106

107-
const config = await node.config.get()
107+
const config = await node.config.getAll()
108108
expect(config.Identity).to.exist()
109109
expect(config.Identity.PrivKey.length).is.below(1024)
110110
await node.stop()
@@ -152,7 +152,7 @@ describe('create node', function () {
152152
preload: { enabled: false }
153153
})
154154

155-
const config = await node.config.get()
155+
const config = await node.config.getAll()
156156
expect(config.Addresses.Swarm).to.eql(['/ip4/127.0.0.1/tcp/9977'])
157157
expect(config.Bootstrap).to.eql([])
158158
await node.stop()

packages/ipfs/test/core/init.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('init', function () {
3838
const res = await repo.exists()
3939
expect(res).to.equal(true)
4040

41-
const config = await repo.config.get()
41+
const config = await repo.config.getAll()
4242

4343
expect(config.Identity).to.exist()
4444
expect(config.Keychain).to.exist()
@@ -49,14 +49,14 @@ describe('init', function () {
4949

5050
await ipfs.init({ bits: 1024, pass: nanoid() })
5151

52-
const config = await repo.config.get()
52+
const config = await repo.config.getAll()
5353
expect(config.Identity.PrivKey.length).is.above(256)
5454
})
5555

5656
it('should allow a pregenerated key to be used', async () => {
5757
await ipfs.init({ privateKey })
5858

59-
const config = await repo.config.get()
59+
const config = await repo.config.getAll()
6060
expect(config.Identity.PeerID).is.equal('QmRsooYQasV5f5r834NSpdUtmejdQcpxXkK6qsozZWEihC')
6161
})
6262

@@ -79,14 +79,14 @@ describe('init', function () {
7979
it('should apply one profile', async () => {
8080
await ipfs.init({ bits: 512, profiles: ['test'] })
8181

82-
const config = await repo.config.get()
82+
const config = await repo.config.getAll()
8383
expect(config.Bootstrap).to.be.empty()
8484
})
8585

8686
it('should apply multiple profiles', async () => {
8787
await ipfs.init({ bits: 512, profiles: ['test', 'local-discovery'] })
8888

89-
const config = await repo.config.get()
89+
const config = await repo.config.getAll()
9090
expect(config.Bootstrap).to.be.empty()
9191
expect(config.Discovery.MDNS.Enabled).to.be.true()
9292
})

packages/ipfs/test/http-api/inject/config.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('/config', () => {
2323
beforeEach(() => {
2424
ipfs = {
2525
config: {
26+
getAll: sinon.stub(),
2627
get: sinon.stub(),
2728
replace: sinon.stub(),
2829
profiles: {
@@ -58,7 +59,7 @@ describe('/config', () => {
5859
})
5960

6061
it('returns value for request with valid arg', async () => {
61-
ipfs.config.get.withArgs(undefined, defaultOptions).returns({
62+
ipfs.config.getAll.withArgs(defaultOptions).returns({
6263
API: {
6364
HTTPHeaders: 'value'
6465
}
@@ -75,7 +76,7 @@ describe('/config', () => {
7576
})
7677

7778
it('returns value for request as subcommand', async () => {
78-
ipfs.config.get.withArgs(undefined, defaultOptions).returns({
79+
ipfs.config.getAll.withArgs(defaultOptions).returns({
7980
API: {
8081
HTTPHeaders: 'value'
8182
}
@@ -92,7 +93,7 @@ describe('/config', () => {
9293
})
9394

9495
it('updates value for request with both args', async () => {
95-
ipfs.config.get.withArgs(undefined, defaultOptions).returns({
96+
ipfs.config.getAll.withArgs(defaultOptions).returns({
9697
Datastore: {
9798
Path: 'not-kitten'
9899
}
@@ -114,7 +115,7 @@ describe('/config', () => {
114115
})
115116

116117
it('returns 400 value for request with both args and JSON flag with invalid JSON argument', async () => {
117-
ipfs.config.get.withArgs(undefined, defaultOptions).returns({
118+
ipfs.config.getAll.withArgs(defaultOptions).returns({
118119
Datastore: {
119120
Path: 'not-kitten'
120121
}
@@ -132,7 +133,7 @@ describe('/config', () => {
132133
})
133134

134135
it('updates value for request with both args and JSON flag with valid JSON argument', async () => {
135-
ipfs.config.get.withArgs(undefined, defaultOptions).returns({
136+
ipfs.config.getAll.withArgs(defaultOptions).returns({
136137
Datastore: {
137138
Path: 'not-kitten'
138139
}
@@ -156,7 +157,7 @@ describe('/config', () => {
156157
})
157158

158159
it('updates null json value', async () => {
159-
ipfs.config.get.withArgs(undefined, defaultOptions).returns({
160+
ipfs.config.getAll.withArgs(defaultOptions).returns({
160161
Datastore: {
161162
Path: 'not-kitten'
162163
}
@@ -178,7 +179,7 @@ describe('/config', () => {
178179
})
179180

180181
it('updates value for request with both args and bool flag and true argument', async () => {
181-
ipfs.config.get.withArgs(undefined, defaultOptions).returns({
182+
ipfs.config.getAll.withArgs(defaultOptions).returns({
182183
Datastore: {
183184
Path: 'not-kitten'
184185
}
@@ -200,7 +201,7 @@ describe('/config', () => {
200201
})
201202

202203
it('updates value for request with both args and bool flag and false argument', async () => {
203-
ipfs.config.get.withArgs(undefined, defaultOptions).returns({
204+
ipfs.config.getAll.withArgs(defaultOptions).returns({
204205
Datastore: {
205206
Path: 'not-kitten'
206207
}
@@ -224,7 +225,7 @@ describe('/config', () => {
224225
it('accepts a timeout', async () => {
225226
const key = 'Datastore.Path'
226227
const value = 'value'
227-
ipfs.config.get.withArgs(undefined, {
228+
ipfs.config.getAll.withArgs({
228229
...defaultOptions,
229230
timeout: 1000
230231
}).returns({
@@ -262,7 +263,7 @@ describe('/config', () => {
262263
}
263264
}
264265

265-
ipfs.config.get.withArgs(undefined, defaultOptions).returns(config)
266+
ipfs.config.getAll.withArgs(defaultOptions).returns(config)
266267

267268
const res = await http({
268269
method: 'POST',
@@ -280,7 +281,7 @@ describe('/config', () => {
280281
}
281282
}
282283

283-
ipfs.config.get.withArgs(undefined, {
284+
ipfs.config.getAll.withArgs({
284285
...defaultOptions,
285286
timeout: 1000
286287
}).returns(config)

0 commit comments

Comments
 (0)