Skip to content

Commit

Permalink
chore: give context to errors (argoproj#10592) (argoproj#15022)
Browse files Browse the repository at this point in the history
* chore: give context to errors

Signed-off-by: Vipin M S <[email protected]>

* Update util/settings/settings.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/settings/settings.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/tls/tls.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/settings/settings.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/settings/settings.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/settings/settings.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/settings/settings.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/settings/settings.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/tls/tls.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Update util/tls/tls.go

Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Vipin M S <[email protected]>

* Apply suggestions from code review

Signed-off-by: Michael Crenshaw <[email protected]>

---------

Signed-off-by: Vipin M S <[email protected]>
Signed-off-by: Vipin M S <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
  • Loading branch information
vipinachar and crenshaw-dev authored Aug 11, 2023
1 parent 48cdba9 commit f7bfb3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions util/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func (mgr *SettingsManager) GetSecretsLister() (v1listers.SecretLister, error) {
func (mgr *SettingsManager) GetSecretsInformer() (cache.SharedIndexInformer, error) {
err := mgr.ensureSynced(false)
if err != nil {
return nil, err
return nil, fmt.Errorf("error ensuring that the secrets manager is synced: %w", err)
}
return mgr.secretsInformer, nil
}
Expand Down Expand Up @@ -688,14 +688,14 @@ func (mgr *SettingsManager) GetConfigMapByName(configMapName string) (*apiv1.Con
func (mgr *SettingsManager) GetResourcesFilter() (*ResourcesFilter, error) {
argoCDCM, err := mgr.getConfigMap()
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving argocd-cm: %w", err)
}
rf := &ResourcesFilter{}
if value, ok := argoCDCM.Data[resourceInclusionsKey]; ok {
includedResources := make([]FilteredResource, 0)
err := yaml.Unmarshal([]byte(value), &includedResources)
if err != nil {
return nil, err
return nil, fmt.Errorf("error unmarshalling included resources %w", err)
}
rf.ResourceInclusions = includedResources
}
Expand All @@ -704,7 +704,7 @@ func (mgr *SettingsManager) GetResourcesFilter() (*ResourcesFilter, error) {
excludedResources := make([]FilteredResource, 0)
err := yaml.Unmarshal([]byte(value), &excludedResources)
if err != nil {
return nil, err
return nil, fmt.Errorf("error unmarshalling excluded resources %w", err)
}
rf.ResourceExclusions = excludedResources
}
Expand Down Expand Up @@ -759,13 +759,13 @@ func (mgr *SettingsManager) GetServerRBACLogEnforceEnable() (bool, error) {
func (mgr *SettingsManager) GetDeepLinks(deeplinkType string) ([]DeepLink, error) {
argoCDCM, err := mgr.getConfigMap()
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving argocd-cm: %w", err)
}
deepLinks := make([]DeepLink, 0)
if value, ok := argoCDCM.Data[deeplinkType]; ok {
err := yaml.Unmarshal([]byte(value), &deepLinks)
if err != nil {
return nil, err
return nil, fmt.Errorf("error unmarshalling deep links %w", err)
}
}
return deepLinks, nil
Expand Down Expand Up @@ -1036,7 +1036,7 @@ func (mgr *SettingsManager) GetHelmSettings() (*v1alpha1.HelmOptions, error) {
func (mgr *SettingsManager) GetKustomizeSettings() (*KustomizeSettings, error) {
argoCDCM, err := mgr.getConfigMap()
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving argocd-cm: %w", err)
}
kustomizeVersionsMap := map[string]KustomizeVersion{}
buildOptions := map[string]string{}
Expand Down Expand Up @@ -1238,15 +1238,15 @@ func (mgr *SettingsManager) GetSettings() (*ArgoCDSettings, error) {
}
argoCDCM, err := mgr.configmaps.ConfigMaps(mgr.namespace).Get(common.ArgoCDConfigMapName)
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving argocd-cm: %w", err)
}
argoCDSecret, err := mgr.secrets.Secrets(mgr.namespace).Get(common.ArgoCDSecretName)
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving argocd-secret: %w", err)
}
selector, err := labels.Parse(partOfArgoCDSelector)
if err != nil {
return nil, err
return nil, fmt.Errorf("error parsing Argo CD selector %w", err)
}
secrets, err := mgr.secrets.Secrets(mgr.namespace).List(selector)
if err != nil {
Expand Down Expand Up @@ -2107,14 +2107,14 @@ func ReplaceStringSecret(val string, secretValues map[string]string) string {
func (mgr *SettingsManager) GetGlobalProjectsSettings() ([]GlobalProjectSettings, error) {
argoCDCM, err := mgr.getConfigMap()
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving argocd-cm: %w", err)
}
globalProjectSettings := make([]GlobalProjectSettings, 0)
if value, ok := argoCDCM.Data[globalProjectsKey]; ok {
if value != "" {
err := yaml.Unmarshal([]byte(value), &globalProjectSettings)
if err != nil {
return nil, err
return nil, fmt.Errorf("error unmarshalling global project settings: %w", err)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions util/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ func tlsVersionsToStr(versions []uint16) []string {
func getTLSConfigCustomizer(minVersionStr, maxVersionStr, tlsCiphersStr string) (ConfigCustomizer, error) {
minVersion, err := getTLSVersionByString(minVersionStr)
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving TLS version by min version %q: %w", minVersionStr, err)
}
maxVersion, err := getTLSVersionByString(maxVersionStr)
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving TLS version by max version %q: %w", maxVersionStr, err)
}
if minVersion > maxVersion {
return nil, fmt.Errorf("Minimum TLS version %s must not be higher than maximum TLS version %s", minVersionStr, maxVersionStr)
Expand All @@ -153,7 +153,7 @@ func getTLSConfigCustomizer(minVersionStr, maxVersionStr, tlsCiphersStr string)
if tlsCiphersStr != "" {
cipherSuites, err = getTLSCipherSuitesByString(tlsCiphersStr)
if err != nil {
return nil, err
return nil, fmt.Errorf("error retrieving TLS cipher suites: %w", err)
}
} else {
cipherSuites = make([]uint16, 0)
Expand Down

0 comments on commit f7bfb3f

Please sign in to comment.