refactor: move registry path to const

This commit is contained in:
Jose Diaz-Gonzalez committed 2024-01-23 03:00:27 -05:00
1 parent a90f6bdee8
commit e13561ec4d
3 files changed
+5 -4

No files matched your search

+2
View File
@@ -32,6 +32,8 @@ var (
const KubeConfigPath = "/etc/rancher/k3s/k3s.yaml" const KubeConfigPath = "/etc/rancher/k3s/k3s.yaml"
const RegistryConfigPath = "/etc/rancher/k3s/registries.yaml"
var ( var (
runtimeScheme = runtime.NewScheme() runtimeScheme = runtime.NewScheme()
codecs = serializer.NewCodecFactory(runtimeScheme) codecs = serializer.NewCodecFactory(runtimeScheme)
+2 -2
View File
@@ -76,7 +76,7 @@ func CommandInitialize() error {
return fmt.Errorf("Error installing k3s: %w", installerCmd.ExitError) return fmt.Errorf("Error installing k3s: %w", installerCmd.ExitError)
} }
if err := common.TouchFile("/etc/rancher/k3s/registries.yaml"); err != nil { if err := common.TouchFile(RegistryConfigPath); err != nil {
return fmt.Errorf("Error creating initial registries.yaml file") return fmt.Errorf("Error creating initial registries.yaml file")
} }
@@ -84,7 +84,7 @@ func CommandInitialize() error {
"setfacl", "setfacl",
"-m", "-m",
"user:dokku:rwx", "user:dokku:rwx",
"/etc/rancher/k3s/registries.yaml", RegistryConfigPath,
}, " ")) }, " "))
if !registryAclCmd.Execute() { if !registryAclCmd.Execute() {
return fmt.Errorf("Error updating acls on k3s registries.yaml file: %w", registryAclCmd.ExitError) return fmt.Errorf("Error updating acls on k3s registries.yaml file: %w", registryAclCmd.ExitError)
+1 -2
View File
@@ -85,8 +85,7 @@ func TriggerPostRegistryLogin(server string, username string, password string) e
} }
registry := registries.Registry{} registry := registries.Registry{}
registryFile := "/etc/rancher/k3s/registries.yaml" yamlFile, err := os.ReadFile(RegistryConfigPath)
yamlFile, err := os.ReadFile(registryFile)
if err != nil { if err != nil {
return fmt.Errorf("Unable to read existing registries.yaml: %w", err) return fmt.Errorf("Unable to read existing registries.yaml: %w", err)
} }