Skip to content

Commit

Permalink
fixup! Certificate support for image registry
Browse files Browse the repository at this point in the history
  • Loading branch information
tmshort committed Jun 24, 2024
1 parent cf5b281 commit 421d281
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func main() {
)
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.StringVar(&caCertDir, "ca-cert-dir", "", "The directory of TLS certificate to use for verifying HTTPS connections to the Catalogd and docker-registry web servers.")
flag.StringVar(&caCertDir, "ca-certs-dir", "", "The directory of TLS certificate to use for verifying HTTPS connections to the Catalogd and docker-registry web servers.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
Expand Down
2 changes: 1 addition & 1 deletion config/overlays/tls/patches/manager_deployment_cert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
value: {"name":"catalogd-certificate", "readOnly": true, "mountPath":"/var/certs/catalogd.crt", "subPath":"catalogd.crt"}
- op: add
path: /spec/template/spec/containers/0/args/-
value: "--ca-cert-dir=/var/certs"
value: "--ca-certs-dir=/var/certs"
22 changes: 9 additions & 13 deletions internal/httputil/httputil.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/x509"
"net/http"
"os"
"path/filepath"
"strings"
"time"
)
Expand All @@ -16,22 +15,19 @@ func LoadCerts(caDir string) (string, error) {
}

var certs []string

Check failure on line 17 in internal/httputil/httputil.go

View workflow job for this annotation

GitHub Actions / lint

Consider pre-allocating `certs` (prealloc)
err := filepath.Walk(caDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
dirEntries, err := os.ReadDir(caDir)
if err != nil {
return "", err
}
for _, e := range dirEntries {
if e.IsDir() {
continue
}
data, err := os.ReadFile(path)
data, err := os.ReadFile(e.Name())
if err != nil {
return err
return "", err
}
certs = append(certs, string(data))
return nil
})
if err != nil {
return "", err
}
return strings.Join(certs, "\n"), nil
}
Expand Down

0 comments on commit 421d281

Please sign in to comment.