Status gets the status of the deployment
(ctx devspacecontext.Context)
| 11 | |
| 12 | // Status gets the status of the deployment |
| 13 | func (d *DeployConfig) Status(ctx devspacecontext.Context) (*deployer.StatusResult, error) { |
| 14 | var ( |
| 15 | deployTargetStr = d.getDeployTarget() |
| 16 | err error |
| 17 | ) |
| 18 | |
| 19 | if d.Helm == nil { |
| 20 | // Get HelmClient |
| 21 | d.Helm, err = helm.NewClient(ctx.Log()) |
| 22 | if err != nil { |
| 23 | return nil, err |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | // Get all releases |
| 28 | releases, err := d.Helm.ListReleases(ctx, ctx.KubeClient().Namespace()) |
| 29 | if err != nil { |
| 30 | return &deployer.StatusResult{ |
| 31 | Name: d.DeploymentConfig.Name, |
| 32 | Type: "Helm", |
| 33 | Target: deployTargetStr, |
| 34 | Status: fmt.Sprintf("Error: %v", err), |
| 35 | }, nil |
| 36 | } |
| 37 | |
| 38 | if len(releases) == 0 { |
| 39 | return &deployer.StatusResult{ |
| 40 | Name: d.DeploymentConfig.Name, |
| 41 | Type: "Helm", |
| 42 | Target: deployTargetStr, |
| 43 | Status: "Not deployed", |
| 44 | }, nil |
| 45 | } |
| 46 | |
| 47 | for _, release := range releases { |
| 48 | if d.matchesRelease(release) { |
| 49 | if release.Status != "DEPLOYED" { |
| 50 | return &deployer.StatusResult{ |
| 51 | Name: d.DeploymentConfig.Name, |
| 52 | Type: "Helm", |
| 53 | Target: deployTargetStr, |
| 54 | Status: "Status:" + release.Status, |
| 55 | }, nil |
| 56 | } |
| 57 | |
| 58 | return &deployer.StatusResult{ |
| 59 | Name: d.DeploymentConfig.Name, |
| 60 | Type: "Helm", |
| 61 | Target: deployTargetStr, |
| 62 | Status: "Deployed", |
| 63 | }, nil |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | return &deployer.StatusResult{ |
| 68 | Name: d.DeploymentConfig.Name, |
| 69 | Type: "Helm", |
| 70 | Target: deployTargetStr, |