refactor: move registry path to const

This commit is contained in:
Jose Diaz-Gonzalez
2024-01-18 18:55:03 -05:00
parent a90f6bdee8
commit e13561ec4d
3 changed files with 5 additions and 4 deletions

View File

@@ -32,6 +32,8 @@ var (
const KubeConfigPath = "/etc/rancher/k3s/k3s.yaml"
const RegistryConfigPath = "/etc/rancher/k3s/registries.yaml"
var (
runtimeScheme = runtime.NewScheme()
codecs = serializer.NewCodecFactory(runtimeScheme)

View File

@@ -76,7 +76,7 @@ func CommandInitialize() error {
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")
}
@@ -84,7 +84,7 @@ func CommandInitialize() error {
"setfacl",
"-m",
"user:dokku:rwx",
"/etc/rancher/k3s/registries.yaml",
RegistryConfigPath,
}, " "))
if !registryAclCmd.Execute() {
return fmt.Errorf("Error updating acls on k3s registries.yaml file: %w", registryAclCmd.ExitError)

View File

@@ -85,8 +85,7 @@ func TriggerPostRegistryLogin(server string, username string, password string) e
}
registry := registries.Registry{}
registryFile := "/etc/rancher/k3s/registries.yaml"
yamlFile, err := os.ReadFile(registryFile)
yamlFile, err := os.ReadFile(RegistryConfigPath)
if err != nil {
return fmt.Errorf("Unable to read existing registries.yaml: %w", err)
}