Skip to content

Commit

Permalink
feat: use registry version from local config (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt authored Mar 24, 2024
1 parent 4404ccd commit a053af1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions swiftwave_service/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ var initCmd = &cobra.Command{
currentPostgresTimeZone := ""
currentPostgresSSLMode := ""

currentLocalImageRegistryImage := ""
currentLocalImageRegistryPort := 0
currentLocalImageRegistryUser := ""
currentLocalImageRegistryPassword := ""
Expand All @@ -101,6 +102,7 @@ var initCmd = &cobra.Command{
currentPostgresDatabase = config.LocalConfig.PostgresqlConfig.Database
currentPostgresTimeZone = config.LocalConfig.PostgresqlConfig.TimeZone
currentPostgresSSLMode = config.LocalConfig.PostgresqlConfig.SSLMode
currentLocalImageRegistryImage = config.LocalConfig.LocalImageRegistryConfig.Image
currentLocalImageRegistryPort = config.LocalConfig.LocalImageRegistryConfig.Port
currentLocalImageRegistryUser = config.LocalConfig.LocalImageRegistryConfig.Username
currentLocalImageRegistryPassword = config.LocalConfig.LocalImageRegistryConfig.Password
Expand All @@ -125,6 +127,7 @@ var initCmd = &cobra.Command{
RunLocalPostgres: isLocalPostgres,
},
LocalImageRegistryConfig: local_config.LocalImageRegistryConfig{
Image: defaultString(currentLocalImageRegistryImage, "registry:2.8"),
Port: defaultInt(currentLocalImageRegistryPort, 3334),
Username: defaultString(currentLocalImageRegistryUser, "user_"+generateRandomString(8)),
Password: defaultString(currentLocalImageRegistryPassword, generateRandomString(20)),
Expand Down
4 changes: 2 additions & 2 deletions swiftwave_service/cmd/localregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func startLocalRegistry(ctx context.Context) error {
"-v", fmt.Sprintf("%s:/cert", config.LocalConfig.LocalImageRegistryConfig.CertPath),
"-v", fmt.Sprintf("%s:/auth", config.LocalConfig.LocalImageRegistryConfig.AuthPath),
"-v", fmt.Sprintf("%s:/var/lib/registry", config.LocalConfig.LocalImageRegistryConfig.DataPath),
"--name", localRegistryContainerName, "registry:2.8")
"--name", localRegistryContainerName, config.LocalConfig.LocalImageRegistryConfig.Image)
} else {
printInfo("Using Non-TLS for local image registry")
dockerCmd = exec.Command("docker", "run", "-d",
Expand All @@ -151,7 +151,7 @@ func startLocalRegistry(ctx context.Context) error {
"-e", "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm",
"-v", fmt.Sprintf("%s:/auth", config.LocalConfig.LocalImageRegistryConfig.AuthPath),
"-v", fmt.Sprintf("%s:/var/lib/registry", config.LocalConfig.LocalImageRegistryConfig.DataPath),
"--name", localRegistryContainerName, "registry:2.8")
"--name", localRegistryContainerName, config.LocalConfig.LocalImageRegistryConfig.Image)
}
dockerCmd.Stdout = os.Stdout
dockerCmd.Stderr = os.Stderr
Expand Down
1 change: 1 addition & 0 deletions swiftwave_service/config/local_config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type LocalImageRegistryConfig struct {
Port int `yaml:"port"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Image string `yaml:"image"`
DataPath string `yaml:"-"`
CertPath string `yaml:"-"`
AuthPath string `yaml:"-"`
Expand Down
5 changes: 3 additions & 2 deletions swiftwave_service/config/local_config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"gopkg.in/yaml.v3"
"io"
"os"
"strings"
)

var config *Config
Expand Down Expand Up @@ -85,13 +86,13 @@ func readConfigFile(path string) (*Config, error) {
}

func FillDefaults(config *Config) error {
if config.ServiceConfig.BindAddress == "" {
if strings.Compare(config.ServiceConfig.BindAddress, "") == 0 {
config.ServiceConfig.BindAddress = defaultBindAddress
}
if config.ServiceConfig.BindPort == 0 {
config.ServiceConfig.BindPort = defaultBindPort
}
if config.ServiceConfig.ManagementNodeAddress == "" {
if strings.Compare(config.ServiceConfig.ManagementNodeAddress, "") == 0 {
return errors.New("management_node_address is required in config")
}
if config.LocalImageRegistryConfig.Port == 0 {
Expand Down

0 comments on commit a053af1

Please sign in to comment.