MCPcopy Index your code
hub / github.com/devspace-sh/devspace / validateDeployments

Function validateDeployments

pkg/devspace/config/versions/validate.go:254–291  ·  view source on GitHub ↗
(config *latest.Config)

Source from the content-addressed store, hash-verified

252}
253
254func validateDeployments(config *latest.Config) error {
255 for index, deployConfig := range config.Deployments {
256 if encoding.IsUnsafeName(deployConfig.Name) {
257 return fmt.Errorf("deployments.%s has to match the following regex: %v", index, encoding.UnsafeNameRegEx.String())
258 }
259 if deployConfig.Helm == nil && deployConfig.Kubectl == nil {
260 return errors.Errorf("Please specify either helm or kubectl as deployment type in deployment %s", deployConfig.Name)
261 }
262 if deployConfig.Kubectl != nil && deployConfig.Kubectl.Manifests == nil && deployConfig.Kubectl.InlineManifest == "" {
263 return errors.Errorf("deployments[%s].kubectl.manifests or deployments[%s].kubectl.InlineManifest is required", index, index)
264 }
265 if deployConfig.Kubectl != nil && deployConfig.Kubectl.Manifests != nil && deployConfig.Kubectl.InlineManifest != "" {
266 return errors.Errorf("deployments[%s].kubectl.manifests and deployments[%s].kubectl.inlineManifest cannot be used together", index, index)
267 }
268 if deployConfig.Kubectl != nil && deployConfig.Helm != nil {
269 return errors.Errorf("deployments[%s].kubectl and deployments[%s].helm cannot be used together", index, index)
270 }
271 if deployConfig.Kubectl != nil && deployConfig.Kubectl.Patches != nil {
272 for patch := range deployConfig.Kubectl.Patches {
273 if deployConfig.Kubectl.Patches[patch].Target.Name == "" {
274 return errors.Errorf("deployments[%s].kubectl.patches[%d].target.name is required", index, patch)
275 }
276 if deployConfig.Kubectl.Patches[patch].Operation == "" {
277 return errors.Errorf("deployments[%s].kubectl.patches[%d].op is required", index, patch)
278 }
279 if deployConfig.Kubectl.Patches[patch].Path == "" {
280 return errors.Errorf("deployments[%s].kubectl.patches[%d].path is required", index, patch)
281 }
282 if deployConfig.Kubectl.Patches[patch].Operation != "remove" &&
283 deployConfig.Kubectl.Patches[patch].Value == nil {
284 return errors.Errorf("deployments[%s].kubectl.patches[%d].value is required", index, patch)
285 }
286 }
287 }
288 }
289
290 return nil
291}
292
293func ValidateComponentConfig(deployConfig *latest.DeploymentConfig, overwriteValues map[string]interface{}) error {
294 if deployConfig.Helm != nil && deployConfig.Helm.Chart == nil {

Callers 1

ValidateFunction · 0.85

Calls 3

IsUnsafeNameFunction · 0.92
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected