Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update logs to indicate parsing of secret file #50

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Changes from all commits
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
17 changes: 11 additions & 6 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ func (s *service) getNewIsilonConfigs(ctx context.Context, configBytes []byte) (
var inputConfigs *IsilonClusters
var yamlErr error
var err error

log.Info("reading secret file to validate cluster config details")
inputConfigs, yamlErr = unmarshalYAMLContent(configBytes)
if yamlErr != nil {
log.Errorf("failed to parse isilon clusters' config details as yaml data, error: %v", yamlErr)
Expand All @@ -642,16 +644,16 @@ func (s *service) getNewIsilonConfigs(ctx context.Context, configBytes []byte) (
config := clusterConfig
log.Debugf("parsing config details for cluster %v", config.ClusterName)
if config.ClusterName == "" {
return nil, defaultIsiClusterName, fmt.Errorf("invalid value for clusterName at index [%d]", i)
return nil, defaultIsiClusterName, fmt.Errorf("clusterName not provided in secret at index [%d]", i)
}
if config.User == "" {
return nil, defaultIsiClusterName, fmt.Errorf("invalid value for username at index [%d]", i)
return nil, defaultIsiClusterName, fmt.Errorf("username not provided for cluster %s at index [%d]", config.ClusterName, i)
}
if config.Password == "" {
return nil, defaultIsiClusterName, fmt.Errorf("invalid value for password at index [%d]", i)
return nil, defaultIsiClusterName, fmt.Errorf("password not provided for cluster %s at index [%d]", config.ClusterName, i)
}
if config.Endpoint == "" {
return nil, defaultIsiClusterName, fmt.Errorf("invalid value for endpoint at index [%d]", i)
return nil, defaultIsiClusterName, fmt.Errorf("endpoint not provided for cluster %s at index [%d]", config.ClusterName, i)
}

// Let Endpoint be generic.
Expand All @@ -661,6 +663,7 @@ func (s *service) getNewIsilonConfigs(ctx context.Context, configBytes []byte) (
}

if config.EndpointPort == "" {
log.Warnf("using default as EndpointPort not provided for cluster %s in secret at index [%d]", config.ClusterName, i)
config.EndpointPort = s.opts.Port
}

Expand All @@ -669,18 +672,20 @@ func (s *service) getNewIsilonConfigs(ctx context.Context, configBytes []byte) (
}

if config.IsiPath == "" {
log.Warnf("using default as IsiPath not provided for cluster %s in secret at index [%d]", config.ClusterName, i)
config.IsiPath = s.opts.Path
}

if config.IsiVolumePathPermissions == "" {
log.Warnf("using default as IsiVolumePathPermissions not provided for cluster %s in secret at index [%d]", config.ClusterName, i)
config.IsiVolumePathPermissions = s.opts.IsiVolumePathPermissions
}

config.EndpointURL = fmt.Sprintf("https://%s:%s", config.Endpoint, config.EndpointPort)
clientCtx, _ := GetLogger(ctx)
config.isiSvc, err = s.GetIsiService(clientCtx, &config, logLevel)
if err != nil {
log.Errorf("failed to get isi client, error: %v", err)
log.Errorf("failed to get isi client for cluster %s, error: %v", config.ClusterName, err)
}

if config.IsDefault == nil {
Expand Down Expand Up @@ -719,7 +724,7 @@ func (s *service) getNewIsilonConfigs(ctx context.Context, configBytes []byte) (
"IsDefault": *config.IsDefault,
}
// TODO: Replace logrus with log
logrus.WithFields(fields).Infof("new config details for cluster %s", config.ClusterName)
logrus.WithFields(fields).Infof("new config details set for cluster %s", config.ClusterName)
}

return newIsiClusters, defaultIsiClusterName, nil
Expand Down