Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-nest docker registry auth and reformat related doc #445

Merged
merged 2 commits into from
Nov 18, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,21 @@ type DockerDriver struct {
fingerprint.StaticFingerprinter
}

type DockerAuthConfig struct {
UserName string `mapstructure:"auth.username"` // user name of the registry
Password string `mapstructure:"auth.password"` // password to access the registry
Email string `mapstructure:"auth.email"` // email address of the user who is allowed to access the registry
ServerAddress string `mapstructure:"auth.server_address"` // server address of the registry

}

type DockerDriverConfig struct {
DockerAuthConfig
ImageName string `mapstructure:"image"` // Container's Image Name
Command string `mapstructure:"command"` // The Command/Entrypoint to run when the container starts up
Args string `mapstructure:"args"` // The arguments to the Command/Entrypoint
NetworkMode string `mapstructure:"network_mode"` // The network mode of the container - host, net and none
PortMap []map[string]int `mapstructure:"port_map"` // A map of host port labels and the ports exposed on the container
Privileged bool `mapstructure:"privileged"` // Flag to run the container in priviledged mode
DNS string `mapstructure:"dns_server"` // DNS Server for containers
SearchDomains string `mapstructure:"search_domains"` // DNS Search domains for containers
Hostname string `mapstructure:"hostname"` // Hostname for containers
Labels []map[string]string `mapstructure:"labels"` // Labels to set when the container starts up
ImageName string `mapstructure:"image"` // Container's Image Name
Command string `mapstructure:"command"` // The Command/Entrypoint to run when the container starts up
Args string `mapstructure:"args"` // The arguments to the Command/Entrypoint
NetworkMode string `mapstructure:"network_mode"` // The network mode of the container - host, net and none
PortMap []map[string]int `mapstructure:"port_map"` // A map of host port labels and the ports exposed on the container
Privileged bool `mapstructure:"privileged"` // Flag to run the container in priviledged mode
DNS string `mapstructure:"dns_server"` // DNS Server for containers
SearchDomains string `mapstructure:"search_domains"` // DNS Search domains for containers
Hostname string `mapstructure:"hostname"` // Hostname for containers
Labels []map[string]string `mapstructure:"labels"` // Labels to set when the container starts up
UserName string `mapstructure:"auth_username"` // user name of the registry
Password string `mapstructure:"auth_password"` // password to access the registry
Email string `mapstructure:"auth_email"` // email address of the user who is allowed to access the registry
ServerAddress string `mapstructure:"auth_server_address"` // server address of the registry
}

func (c *DockerDriverConfig) Validate() error {
Expand Down Expand Up @@ -392,6 +387,9 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle
ServerAddress: driverConfig.ServerAddress,
}

d.logger.Printf("[DEBUG] TASKCONFIG: %v", task.Config)
d.logger.Printf("[DEBUG] DRIVERCONFIG: %v", driverConfig)
d.logger.Printf("[DEBUG] AUTH: %v", authOptions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes credential leakage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch (debugging cruft)

err = client.PullImage(pullOptions, authOptions)
if err != nil {
d.logger.Printf("[ERR] driver.docker: failed pulling container %s:%s: %s", repo, tag, err)
Expand Down
10 changes: 5 additions & 5 deletions website/source/docs/drivers/docker.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ specification:
following authentication parameters. These options can provide access to
private repositories that utilize the docker remote api (e.g. dockerhub,
quay.io)
- `auth.username` - (Optional) The account username
- `auth.password` - (Optional) The account password
- `auth.email` - (Optional) The account email
- `auth.server-address` - (Optional) The server domain/ip without the
protocol

* `auth_username` - (Optional) The account username.
* `auth_password` - (Optional) The account password.
* `auth_email` - (Optional) The account email.
* `auth_server-address` - (Optional) The server domain/ip without the protocol.

### Port Mapping

Expand Down