Deploy deploys all deployments in the config
(ctx devspacecontext.Context, deployments []string, options *Options)
| 48 | |
| 49 | // Deploy deploys all deployments in the config |
| 50 | func (c *controller) Deploy(ctx devspacecontext.Context, deployments []string, options *Options) error { |
| 51 | config := ctx.Config().Config() |
| 52 | event := "deploy" |
| 53 | if options.Render { |
| 54 | event = "render" |
| 55 | } |
| 56 | |
| 57 | if options.SkipDeploy { |
| 58 | ctx.Log().Debugf("Skip deploy because of --skip-deploy") |
| 59 | return nil |
| 60 | } |
| 61 | |
| 62 | if len(config.Deployments) > 0 { |
| 63 | // Execute before deployments deploy hook |
| 64 | err := hook.ExecuteHooks(ctx, nil, "before:"+event) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | |
| 69 | // get relevant deployments |
| 70 | var ( |
| 71 | concurrentDeployments []*latest.DeploymentConfig |
| 72 | sequentialDeployments []*latest.DeploymentConfig |
| 73 | ) |
| 74 | if len(deployments) == 0 { |
| 75 | for _, deployConfig := range config.Deployments { |
| 76 | if !options.Render && !options.Sequential { |
| 77 | concurrentDeployments = append(concurrentDeployments, deployConfig) |
| 78 | } else { |
| 79 | sequentialDeployments = append(sequentialDeployments, deployConfig) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // make sure --all behaves the same every rung |
| 84 | sort.Slice(concurrentDeployments, func(i, j int) bool { |
| 85 | return concurrentDeployments[i].Name < concurrentDeployments[j].Name |
| 86 | }) |
| 87 | sort.Slice(sequentialDeployments, func(i, j int) bool { |
| 88 | return sequentialDeployments[i].Name < sequentialDeployments[j].Name |
| 89 | }) |
| 90 | } else { |
| 91 | deploymentMap := config.Deployments |
| 92 | if deploymentMap == nil { |
| 93 | deploymentMap = map[string]*latest.DeploymentConfig{} |
| 94 | } |
| 95 | |
| 96 | for _, deployment := range deployments { |
| 97 | deployConfig, ok := deploymentMap[deployment] |
| 98 | if !ok { |
| 99 | return fmt.Errorf("couldn't find deployment %v", deployment) |
| 100 | } |
| 101 | |
| 102 | if !options.Render && !options.Sequential { |
| 103 | concurrentDeployments = append(concurrentDeployments, deployConfig) |
| 104 | } else { |
| 105 | sequentialDeployments = append(sequentialDeployments, deployConfig) |
| 106 | } |
| 107 | } |
nothing calls this directly
no test coverage detected