Skip to content

Commit

Permalink
Add randomly generates container names
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #88
Approved by: baude
  • Loading branch information
mheon authored and rh-atomic-bot committed Nov 30, 2017
1 parent 7424758 commit 1f9c894
Show file tree
Hide file tree
Showing 3 changed files with 615 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libpod/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/containers/storage"
"github.com/containers/storage/pkg/archive"
"github.com/docker/docker/pkg/namesgenerator"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/term"
spec "github.com/opencontainers/runtime-spec/specs-go"
Expand Down Expand Up @@ -329,7 +330,7 @@ func newContainer(rspec *spec.Spec) (*Container, error) {
ctr.state = new(containerRuntimeInfo)

ctr.config.ID = stringid.GenerateNonCryptoID()
ctr.config.Name = ctr.config.ID // TODO generate unique human-readable names
ctr.config.Name = namesgenerator.GetRandomName(0)

ctr.config.Spec = new(spec.Spec)
deepcopier.Copy(rspec).To(ctr.config.Spec)
Expand Down
2 changes: 1 addition & 1 deletion libpod/runtime_ctr.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (r *Runtime) NewContainer(spec *spec.Spec, options ...CtrCreateOption) (c *
}()

if err := r.state.AddContainer(ctr); err != nil {
// TODO: Might be worth making an effort to detect duplicate IDs
// TODO: Might be worth making an effort to detect duplicate IDs and names
// We can recover from that by generating a new ID for the
// container
return nil, errors.Wrapf(err, "error adding new container to state")
Expand Down
Loading

0 comments on commit 1f9c894

Please sign in to comment.