automate-cli: nil-check config before redacting it
These missing nil checks could cause panics.
@@ -7,10 +7,11 @@ import (
"os"
"path/filepath"
+ "github.com/pkg/errors"
+
config "github.com/chef/automate/api/config/shared"
w "github.com/chef/automate/api/config/shared/wrappers"
"github.com/chef/automate/components/automate-deployment/pkg/toml"
- "github.com/pkg/errors"
)
// NewUserOverrideConfig returns a completely blank config struct onto which we
@@ -474,14 +475,22 @@ func (c *AutomateConfig) RedactedCopy() (*AutomateConfig, error) {
// Redact removes sensitive or deprecated values from the configuration
func (c *AutomateConfig) Redact() {
// sensitive
+ if c.GetDeployment().GetV1().GetSvc() != nil {
c.Deployment.V1.Svc.AdminUser = nil
+ }
// deprecated
+ if c.GetCompliance().GetV1().GetSys() != nil {
c.Compliance.V1.Sys.Retention = nil
+ }
+ if c.GetEventFeedService().GetV1().GetSys().GetService() != nil {
c.EventFeedService.V1.Sys.Service.PurgeEventFeedAfterDays = nil
+ }
+ if c.GetIngest().GetV1().GetSys().GetService() != nil {
c.Ingest.V1.Sys.Service.PurgeActionsAfterDays = nil
c.Ingest.V1.Sys.Service.PurgeConvergeHistoryAfterDays = nil
}
+}
// MarshalToTOMLFile marshals the AutomateConfig to a TOML representation and
// writes it to a file at the given path.
