Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deploy in multiple stages; improve 3way merge
* Resource deployment now can happen in multiple stages. * 3-way merge improved for install/upgrade/uninstall/rollback: resources deployed in previous non-successful releases accounted for in merge. Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
- Loading branch information
1 parent
bf1f2d0
commit 9a8d3ee
Showing
14 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
"os" | ||
|
||
"github.com/werf/logboek" | ||
|
||
"github.com/werf/werf/pkg/container_backend" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package helm | ||
|
||
import ( | ||
"fmt" | ||
"sort" | ||
"strconv" | ||
|
||
"helm.sh/helm/v3/pkg/kube" | ||
"helm.sh/helm/v3/pkg/phasemanagers/stages" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/cli-runtime/pkg/resource" | ||
) | ||
|
||
type StagesSplitter struct{} | ||
|
||
func (s StagesSplitter) Split(resources kube.ResourceList) (stages.SortedStageList, error) { | ||
var stageList stages.SortedStageList | ||
if err := resources.Visit(func(res *resource.Info, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
|
||
unstructuredObj := unstructured.Unstructured{} | ||
unstructuredObj.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(res.Object) | ||
if err != nil { | ||
return fmt.Errorf("error converting object to unstructured type: %w", err) | ||
} | ||
|
||
var weight int | ||
if w, ok := unstructuredObj.GetAnnotations()[StageWeightAnnoName]; ok { | ||
weight, err = strconv.Atoi(w) | ||
if err != nil { | ||
return fmt.Errorf("error parsing annotation \"%s: %s\" — value should be an integer: %w", StageWeightAnnoName, w, err) | ||
} | ||
} | ||
|
||
stage := stageList.StageByWeight(weight) | ||
|
||
if stage == nil { | ||
stage = &stages.Stage{ | ||
Weight: weight, | ||
} | ||
stageList = append(stageList, stage) | ||
} | ||
|
||
stage.DesiredResources.Append(res) | ||
|
||
return nil | ||
}); err != nil { | ||
return nil, fmt.Errorf("error visiting resources list: %w", err) | ||
} | ||
|
||
sort.Sort(stageList) | ||
|
||
return stageList, nil | ||
} |