Skip to content
Closed
Changes from all commits
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
34 changes: 19 additions & 15 deletions hook-docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import (
)

type tinkConfig struct {
registry string
baseURL string
tinkerbell string
syslogHost string
registry string
baseURL string
tinkerbell string
syslogHost string
tinkServerTLS bool
Copy link
Member

Choose a reason for hiding this comment

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

doesn't look like this value is being set anywhere. You might want to add to parseCmdLine.


// TODO add others
}
Expand All @@ -39,19 +40,22 @@ func main() {
cmdLines := strings.Split(string(content), " ")
cfg := parseCmdLine(cmdLines)

path := fmt.Sprintf("/etc/docker/certs.d/%s/", cfg.registry)
// if tinkServerTLS is not enabled, skip downloading the certs
if cfg.tinkServerTLS {
Copy link

Choose a reason for hiding this comment

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

Should this not be set in parseCmdLine?

Copy link
Contributor

Choose a reason for hiding this comment

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

I say we just get rid of this. Fetching the certs is very likely to be done in an unsafe manner and we're better off not making it easy to shoot your foot.

path := fmt.Sprintf("/etc/docker/certs.d/%s/", cfg.registry)

// Create the directory
err = os.MkdirAll(path, os.ModeDir)
if err != nil {
panic(err)
}
// Download the configuration
err = downloadFile(path+"ca.crt", cfg.baseURL+"/ca.pem")
if err != nil {
panic(err)
// Create the directory
err = os.MkdirAll(path, os.ModeDir)
if err != nil {
panic(err)
}
// Download the configuration
err = downloadFile(path+"ca.crt", cfg.baseURL+"/ca.pem")
if err != nil {
panic(err)
}
fmt.Println("Downloaded the repository certificates, starting the Docker Engine")
}
fmt.Println("Downloaded the repository certificates, starting the Docker Engine")

d := dockerConfig{
Debug: true,
Expand Down