/* Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.html Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package settings import "k8s.libre.sh/application/settings/parameters" func OrderByResourceRef(s *ConfigSpec) (secrets, configMaps map[string]parameters.Parameters) { secrets = make(map[string]parameters.Parameters) configMaps = make(map[string]parameters.Parameters) for _, source := range s.Sources { if source.Type == "secret" { secrets[source.Ref] = parameters.Parameters{} } else if source.Type == "configmap" { configMaps[source.Ref] = parameters.Parameters{} } } // Then we get the sources that are provided for each parameters and will need a transformation for _, p := range *s.Parameters { if len(p.ValueFrom.Ref) > 0 && p.Type == parameters.SecretParameter { secrets[p.ValueFrom.Ref] = append(secrets[p.ValueFrom.Ref], p) } if len(p.ValueFrom.Ref) > 0 && p.Type == parameters.ConfigParameter { configMaps[p.ValueFrom.Ref] = append(configMaps[p.ValueFrom.Ref], p) } } return secrets, configMaps } /* func OrderBySourceTypeAndRef(s *ConfigSpec) (orderedParams map[string]map[string]parameters.Parameters) { // We order the parameters by secret and configmap sources // First we get the sources provided that should be mounted untouched // paramsByResourceName = make(map[string]parameters.Parameters) orderedParams = make(map[string]map[string]parameters.Parameters) orderedParams["secret"] = make(map[string]parameters.Parameters) orderedParams["configmap"] = make(map[string]parameters.Parameters) orderedParams["field"] = make(map[string]parameters.Parameters) orderedParams["templateValue"] = make(map[string]parameters.Parameters) for _, ref := range s.SecretRefs { orderedParams["secret"][ref] = parameters.Parameters{} } for _, ref := range s.ConfigRefs { orderedParams["configmap"][ref] = parameters.Parameters{} } // Then we get the sources that are provided for each parameters and will need a transformation for _, p := range *s.Parameters { if len(p.ValueFrom.Ref) > 0 { orderedParams[string(p.Type)][p.ValueFrom.Ref] = append(orderedParams[string(p.Type)][p.ValueFrom.Ref], p) } } return orderedParams } */