in pkg/controller/elasticsearch/filesettings/file_settings.go [84:126]
func (s *Settings) updateState(es types.NamespacedName, policy policyv1alpha1.StackConfigPolicy) error {
p := policy.DeepCopy() // be sure to not mutate the original policy
state := newEmptySettingsState()
// mutate Snapshot Repositories
if p.Spec.Elasticsearch.SnapshotRepositories != nil {
for name, untypedDefinition := range p.Spec.Elasticsearch.SnapshotRepositories.Data {
definition, ok := untypedDefinition.(map[string]interface{})
if !ok {
return fmt.Errorf(`invalid type (%T) for definition of snapshot repository %q of Elasticsearch "%s/%s"`, untypedDefinition, name, es.Namespace, es.Name)
}
repoSettings, err := mutateSnapshotRepositorySettings(definition, es.Namespace, es.Name)
if err != nil {
return err
}
p.Spec.Elasticsearch.SnapshotRepositories.Data[name] = repoSettings
}
state.SnapshotRepositories = p.Spec.Elasticsearch.SnapshotRepositories
}
// just copy other settings
if p.Spec.Elasticsearch.ClusterSettings != nil {
state.ClusterSettings = p.Spec.Elasticsearch.ClusterSettings
}
if p.Spec.Elasticsearch.SnapshotLifecyclePolicies != nil {
state.SLM = p.Spec.Elasticsearch.SnapshotLifecyclePolicies
}
if p.Spec.Elasticsearch.SecurityRoleMappings != nil {
state.RoleMappings = p.Spec.Elasticsearch.SecurityRoleMappings
}
if p.Spec.Elasticsearch.IndexLifecyclePolicies != nil {
state.IndexLifecyclePolicies = p.Spec.Elasticsearch.IndexLifecyclePolicies
}
if p.Spec.Elasticsearch.IngestPipelines != nil {
state.IngestPipelines = p.Spec.Elasticsearch.IngestPipelines
}
if p.Spec.Elasticsearch.IndexTemplates.ComposableIndexTemplates != nil {
state.IndexTemplates.ComposableIndexTemplates = p.Spec.Elasticsearch.IndexTemplates.ComposableIndexTemplates
}
if p.Spec.Elasticsearch.IndexTemplates.ComponentTemplates != nil {
state.IndexTemplates.ComponentTemplates = p.Spec.Elasticsearch.IndexTemplates.ComponentTemplates
}
s.State = state
return nil
}