Extend creates a new Container with the existing settings and applies a series of ContainerOptions to further configure the new container.
(opts ...ContainerOption)
| 58 | // Extend creates a new Container with the existing settings and applies a series of |
| 59 | // ContainerOptions to further configure the new container. |
| 60 | func (c *Container) Extend(opts ...ContainerOption) (*Container, error) { |
| 61 | if c == nil { |
| 62 | return NewContainer(opts...) |
| 63 | } |
| 64 | // Copy the name and aliases of the existing container. |
| 65 | ext := &Container{name: c.Name()} |
| 66 | if len(c.AliasSet()) > 0 { |
| 67 | aliasSet := make(map[string]string, len(c.AliasSet())) |
| 68 | for k, v := range c.AliasSet() { |
| 69 | aliasSet[k] = v |
| 70 | } |
| 71 | ext.aliases = aliasSet |
| 72 | } |
| 73 | // Apply the new options to the container. |
| 74 | var err error |
| 75 | for _, opt := range opts { |
| 76 | ext, err = opt(ext) |
| 77 | if err != nil { |
| 78 | return nil, err |
| 79 | } |
| 80 | } |
| 81 | return ext, nil |
| 82 | } |
| 83 | |
| 84 | // Name returns the fully-qualified name of the container. |
| 85 | // |