Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/argocd-server/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewCommand() *cobra.Command {
command.Flags().StringVar(&staticAssetsDir, "staticassets", "", "Static assets directory path")
command.Flags().StringVar(&logLevel, "loglevel", "info", "Set the logging level. One of: debug|info|warn|error")
command.Flags().StringVar(&repoServerAddress, "repo-server", "localhost:8081", "Repo server address.")
command.Flags().StringVar(&configMapName, "config-map", "", "Name of a Kubernetes config map to use.")
command.Flags().StringVar(&configMapName, "config-map", "argo-cd-cm", "Name of a Kubernetes config map to use.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it make sense to replace "argo-cd-cm" with a util.ConfigManagerDefaultConfigMapName const? That way the same default const can be used between argocd install and argocd-server.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@merenbach for some reason I cannot find ConfigManagerDefaultConfigMapName const. Is it in master or some other branch?

@merenbach merenbach Mar 27, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexmt I should have clarified. This would be a new const in util/configmanager.go. You could name it whatever seems appropriate. It would reduce hardcoding, especially since I suspect we could have that config map default name in more than one location: once during install, once during server runtime.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. It make sense, working on changes

command.AddCommand(cli.NewVersionCmd(cliName))
return command
}
21 changes: 12 additions & 9 deletions util/configmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes"
)

Expand Down Expand Up @@ -36,29 +37,31 @@ type ConfigManager struct {
}

// GetSettings retrieves settings from the ConfigManager.
func (mgr *ConfigManager) GetSettings() (settings ArgoCDSettings, err error) {
func (mgr *ConfigManager) GetSettings() (ArgoCDSettings, error) {
settings := ArgoCDSettings{}
settings.LocalUsers = make(map[string]string)
configMap, err := mgr.readConfigMap(mgr.configMapName)
if err != nil {
return
if errors.IsNotFound(err) {
return settings, nil
} else {
return settings, err
}
}

// Try to retrieve the name of a Kubernetes secret holding root credentials
rootCredentialsSecretName, ok := configMap.Data[RootCredentialsSecretNameKey]

if !ok {
return
return settings, nil
}

// Try to retrieve the secret
rootCredentials, err := mgr.readSecret(rootCredentialsSecretName)

if err != nil {
return
return settings, err
}

// No more errors, so let's populate the struct
settings.LocalUsers = make(map[string]string)

// Retrieve credential info from the secret
rootUsername, okUsername := rootCredentials.Data[ConfigManagerRootUsernameKey]
rootPassword, okPassword := rootCredentials.Data[ConfigManagerRootPasswordKey]
Expand All @@ -67,7 +70,7 @@ func (mgr *ConfigManager) GetSettings() (settings ArgoCDSettings, err error) {
// Store credential info inside LocalUsers
settings.LocalUsers[string(rootUsername)] = string(rootPassword)
}
return
return settings, nil
}

// NewConfigManager generates a new ConfigManager pointer and returns it
Expand Down