Generate image pull secret at bootstrap
Add an optional flag called `--registry-creds` to the bootstrap command for generating an image pull secret for container images stored in private registries. Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
@@ -26,6 +26,7 @@ type Options struct {
|
||||
ComponentsExtra []string
|
||||
EventsAddr string
|
||||
Registry string
|
||||
RegistryCredential string
|
||||
ImagePullSecret string
|
||||
WatchAllNamespaces bool
|
||||
NetworkPolicy bool
|
||||
@@ -46,6 +47,7 @@ func MakeDefaultOptions() Options {
|
||||
ComponentsExtra: []string{"image-reflector-controller", "image-automation-controller"},
|
||||
EventsAddr: "",
|
||||
Registry: "ghcr.io/fluxcd",
|
||||
RegistryCredential: "",
|
||||
ImagePullSecret: "",
|
||||
WatchAllNamespaces: true,
|
||||
NetworkPolicy: true,
|
||||
|
||||
@@ -83,7 +83,7 @@ func Generate(options Options) (*manifestgen.Manifest, error) {
|
||||
|
||||
var dockerCfgJson []byte
|
||||
if options.Registry != "" {
|
||||
dockerCfgJson, err = generateDockerConfigJson(options.Registry, options.Username, options.Password)
|
||||
dockerCfgJson, err = GenerateDockerConfigJson(options.Registry, options.Username, options.Password)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to generate json for docker config: %w", err)
|
||||
}
|
||||
@@ -223,7 +223,7 @@ func resourceToString(data []byte) string {
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func generateDockerConfigJson(url, username, password string) ([]byte, error) {
|
||||
func GenerateDockerConfigJson(url, username, password string) ([]byte, error) {
|
||||
cred := fmt.Sprintf("%s:%s", username, password)
|
||||
auth := base64.StdEncoding.EncodeToString([]byte(cred))
|
||||
cfg := DockerConfigJSON{
|
||||
|
||||
Reference in New Issue
Block a user