Commit graph

16 commits

Author SHA1 Message Date
Sebastiaan van Stijn
54512f2184
pkg/stringid: optimize performance
Had these laying around; not very critical as these functions are barely
used, but probably won't hurt:

    BenchmarkIsShortID-10       1447230     816.9 ns/op       0 B/op     0 allocs/op
    BenchmarkIsShortIDNew-10   10103319     101.9 ns/op       0 B/op     0 allocs/op
    BenchmarkValidateID-10        10000    112208 ns/op   33005 B/op    10 allocs/op
    BenchmarkValidateIDNew-10    653293      1737 ns/op   16534 B/op     6 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-16 14:44:52 +01:00
Sebastiaan van Stijn
f73d72bfdc
pkg: replace some README's with GoDoc package descriptions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-30 17:11:37 +02:00
Justin Cormack
2df693e533
Entropy cannot be saved
Remove non cryptographic randomness.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2019-06-07 11:54:45 +01:00
Daniel Nephin
4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
Stephen J Day
66cfe61f71
pkg: remove random package
The unnecessary `random` package has been removed in favor of using the
`math/rand` package directly. Seeding of the random value from crypto
has been added to the `stringid` package to account for the change.

May need to add an equivalent seed to `namesgenerator`, but this is
often used with `stringid` and has collision protection.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-05-08 17:02:02 -07:00
Tonis Tiigi
9f3046f9a0 Move imageID validation to stringid pkg
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-12-26 18:53:22 -08:00
Sebastiaan van Stijn
78eab14d0b
Minor refactor and beter coverage for pkg/stringid
This slightly simplifies TruncateID() by only
trimming the string if needed.

Also improved unit-tests for this package;

- Add a test for GenerateNonCryptoID()
- Add a test for shortening a sha-256 ID
- Make TestShortenId() more "unit", by using a fixed string, instead of calling GenerateRandomID()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-07-20 00:23:06 +02:00
allencloud
aef02273d9 fix typos in pkg
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-04-09 21:18:15 +08:00
Justas Brazauskas
927b334ebf Fix typos found across repository
Signed-off-by: Justas Brazauskas <brazauskasjustas@gmail.com>
2015-12-13 18:04:12 +02:00
Tonis Tiigi
4352da7803 Update daemon and docker core to use new content addressable storage
Add distribution package for managing pulls and pushes. This is based on
the old code in the graph package, with major changes to work with the
new image/layer model.

Add v1 migration code.

Update registry, api/*, and daemon packages to use the reference
package's types where applicable.

Update daemon package to use image/layer/tag stores instead of the graph
package

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2015-11-24 09:40:25 -08:00
Alexander Morozov
270e8cf64d Fix golint warnings
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-11-02 08:02:25 -08:00
Alexander Morozov
4553b6af4b Add GenerateNonCryptoID function to avoid entropy exhaustion
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-07-28 22:31:01 -07:00
Vincent Demeester
18c7c67308 Lint on pkg/* packages
- pkg/useragent
- pkg/units
- pkg/ulimit
- pkg/truncindex
- pkg/timeoutconn
- pkg/term
- pkg/tarsum
- pkg/tailfile
- pkg/systemd
- pkg/stringutils
- pkg/stringid
- pkg/streamformatter
- pkg/sockets
- pkg/signal
- pkg/proxy
- pkg/progressreader
- pkg/pools
- pkg/plugins
- pkg/pidfile
- pkg/parsers
- pkg/parsers/filters
- pkg/parsers/kernel
- pkg/parsers/operatingsystem

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-07-27 21:26:21 +02:00
unclejack
cb08c1173f pkg/stringid: precompile regexp
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2015-05-13 21:48:48 +03:00
Richard Burnison
8d1a500303 Only use fallback to short IDs when obvious.
As reported in #11294, the Docker daemon will execute contains it
shouldn't run in the event that a requested tag is present in an image's
ID. This leads to the wrong image being started up silently.

This change reduces the risk of such a collision by using the short ID
iff the actual revOrTag looks like a short ID (not that it necessarily
is).

Signed-off-by: Richard Burnison <rburnison@ebay.com>
2015-04-10 13:20:44 -04:00
Antonio Murdaca
b80fae7356 Refactor pkg/common, Fixes #11599
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
2015-03-24 18:19:59 +01:00