ApplyReplace applies the replaces
(config map[string]interface{}, profile *latest.ProfileConfig)
| 148 | |
| 149 | // ApplyReplace applies the replaces |
| 150 | func ApplyReplace(config map[string]interface{}, profile *latest.ProfileConfig) error { |
| 151 | if profile == nil || profile.Replace == nil { |
| 152 | return nil |
| 153 | } |
| 154 | |
| 155 | if profile.Replace.Commands != nil { |
| 156 | setKey(config, "commands", *profile.Replace.Commands) |
| 157 | } |
| 158 | if profile.Replace.OldCommands != nil { |
| 159 | setKey(config, "commands", *profile.Replace.OldCommands) |
| 160 | } |
| 161 | if profile.Replace.Deployments != nil { |
| 162 | setKey(config, "deployments", *profile.Replace.Deployments) |
| 163 | } |
| 164 | if profile.Replace.OldDeployments != nil { |
| 165 | setKey(config, "deployments", *profile.Replace.OldDeployments) |
| 166 | } |
| 167 | if profile.Replace.Vars != nil { |
| 168 | setKey(config, "vars", *profile.Replace.Vars) |
| 169 | } |
| 170 | if profile.Replace.OldVars != nil { |
| 171 | setKey(config, "vars", *profile.Replace.OldVars) |
| 172 | } |
| 173 | if profile.Replace.Images != nil { |
| 174 | setKey(config, "images", *profile.Replace.Images) |
| 175 | } |
| 176 | if profile.Replace.Dependencies != nil { |
| 177 | setKey(config, "dependencies", *profile.Replace.Dependencies) |
| 178 | } |
| 179 | if profile.Replace.OldDependencies != nil { |
| 180 | setKey(config, "dependencies", *profile.Replace.OldDependencies) |
| 181 | } |
| 182 | if profile.Replace.Dev != nil { |
| 183 | setKey(config, "dev", *profile.Replace.Dev) |
| 184 | } |
| 185 | if profile.Replace.Hooks != nil { |
| 186 | setKey(config, "hooks", *profile.Replace.Hooks) |
| 187 | } |
| 188 | if profile.Replace.PullSecrets != nil { |
| 189 | setKey(config, "pullSecrets", *profile.Replace.PullSecrets) |
| 190 | } |
| 191 | if profile.Replace.OldPullSecrets != nil { |
| 192 | setKey(config, "pullSecrets", *profile.Replace.OldPullSecrets) |
| 193 | } |
| 194 | return nil |
| 195 | } |
| 196 | |
| 197 | func setKey(m map[string]interface{}, key string, value interface{}) { |
| 198 | if value != nil { |