From 80e8b2b66c598ca70f4f0ab8e59c9eb25f99e1d1 Mon Sep 17 00:00:00 2001 From: Ian Alexander Wood Date: Thu, 12 Jul 2018 11:00:48 +0100 Subject: [PATCH] sort deps in charts for less merge conflicts (#1269) --- Dockerfile.base => Dockerfile.builder-base | 0 Dockerfile.buildgo => Dockerfile.builder-go | 0 Dockerfile.builder-gradle | 4 ++ Dockerfile.maven => Dockerfile.builder-maven | 0 ...erfile.nodejs => Dockerfile.builder-nodejs | 0 Dockerfile.builder-python | 4 ++ Dockerfile.builder-python2 | 4 ++ Dockerfile.builder-ruby | 4 ++ Dockerfile.builder-rust | 4 ++ Dockerfile.builder-scala | 4 ++ Dockerfile.builder-swift | 4 ++ Dockerfile.builder-terraform | 4 ++ Makefile | 40 +++++++++++++------ pkg/helm/helm_helpers.go | 20 +++++++--- 14 files changed, 75 insertions(+), 17 deletions(-) rename Dockerfile.base => Dockerfile.builder-base (100%) rename Dockerfile.buildgo => Dockerfile.builder-go (100%) create mode 100644 Dockerfile.builder-gradle rename Dockerfile.maven => Dockerfile.builder-maven (100%) rename Dockerfile.nodejs => Dockerfile.builder-nodejs (100%) create mode 100644 Dockerfile.builder-python create mode 100644 Dockerfile.builder-python2 create mode 100644 Dockerfile.builder-ruby create mode 100644 Dockerfile.builder-rust create mode 100644 Dockerfile.builder-scala create mode 100644 Dockerfile.builder-swift create mode 100644 Dockerfile.builder-terraform diff --git a/Dockerfile.base b/Dockerfile.builder-base similarity index 100% rename from Dockerfile.base rename to Dockerfile.builder-base diff --git a/Dockerfile.buildgo b/Dockerfile.builder-go similarity index 100% rename from Dockerfile.buildgo rename to Dockerfile.builder-go diff --git a/Dockerfile.builder-gradle b/Dockerfile.builder-gradle new file mode 100644 index 0000000000..9679993331 --- /dev/null +++ b/Dockerfile.builder-gradle @@ -0,0 +1,4 @@ +# this is used for testing jx inside a cluster in development +FROM jenkinsxio/builder-gradle:latest + +COPY build/linux/jx /usr/bin/jx diff --git a/Dockerfile.maven b/Dockerfile.builder-maven similarity index 100% rename from Dockerfile.maven rename to Dockerfile.builder-maven diff --git a/Dockerfile.nodejs b/Dockerfile.builder-nodejs similarity index 100% rename from Dockerfile.nodejs rename to Dockerfile.builder-nodejs diff --git a/Dockerfile.builder-python b/Dockerfile.builder-python new file mode 100644 index 0000000000..818d8f0f8c --- /dev/null +++ b/Dockerfile.builder-python @@ -0,0 +1,4 @@ +# this is used for testing jx inside a cluster in development +FROM jenkinsxio/builder-python:latest + +COPY build/linux/jx /usr/bin/jx diff --git a/Dockerfile.builder-python2 b/Dockerfile.builder-python2 new file mode 100644 index 0000000000..ba95c0320f --- /dev/null +++ b/Dockerfile.builder-python2 @@ -0,0 +1,4 @@ +# this is used for testing jx inside a cluster in development +FROM jenkinsxio/builder-python2:latest + +COPY build/linux/jx /usr/bin/jx diff --git a/Dockerfile.builder-ruby b/Dockerfile.builder-ruby new file mode 100644 index 0000000000..0e810c934c --- /dev/null +++ b/Dockerfile.builder-ruby @@ -0,0 +1,4 @@ +# this is used for testing jx inside a cluster in development +FROM jenkinsxio/builder-ruby:latest + +COPY build/linux/jx /usr/bin/jx diff --git a/Dockerfile.builder-rust b/Dockerfile.builder-rust new file mode 100644 index 0000000000..b3f869c5a8 --- /dev/null +++ b/Dockerfile.builder-rust @@ -0,0 +1,4 @@ +# this is used for testing jx inside a cluster in development +FROM jenkinsxio/builder-rust:latest + +COPY build/linux/jx /usr/bin/jx diff --git a/Dockerfile.builder-scala b/Dockerfile.builder-scala new file mode 100644 index 0000000000..dcc20b956a --- /dev/null +++ b/Dockerfile.builder-scala @@ -0,0 +1,4 @@ +# this is used for testing jx inside a cluster in development +FROM jenkinsxio/builder-scala:latest + +COPY build/linux/jx /usr/bin/jx diff --git a/Dockerfile.builder-swift b/Dockerfile.builder-swift new file mode 100644 index 0000000000..c794cbd899 --- /dev/null +++ b/Dockerfile.builder-swift @@ -0,0 +1,4 @@ +# this is used for testing jx inside a cluster in development +FROM jenkinsxio/builder-swift:latest + +COPY build/linux/jx /usr/bin/jx diff --git a/Dockerfile.builder-terraform b/Dockerfile.builder-terraform new file mode 100644 index 0000000000..4c9aa2c728 --- /dev/null +++ b/Dockerfile.builder-terraform @@ -0,0 +1,4 @@ +# this is used for testing jx inside a cluster in development +FROM jenkinsxio/builder-terraform:latest + +COPY build/linux/jx /usr/bin/jx diff --git a/Makefile b/Makefile index ef9fb5bc56..0a1c573bd5 100644 --- a/Makefile +++ b/Makefile @@ -133,11 +133,11 @@ docker: linux docker build --no-cache -t rawlingsj/jx:dev35 . docker push rawlingsj/jx:dev35 -docker-go: linux Dockerfile.buildgo - docker build --no-cache -t builder-go -f Dockerfile.buildgo . +docker-go: linux Dockerfile.builder-go + docker build --no-cache -t builder-go -f Dockerfile.builder-go . -docker-maven: linux Dockerfile.maven - docker build --no-cache -t builder-maven -f Dockerfile.maven . +docker-maven: linux Dockerfile.builder-maven + docker build --no-cache -t builder-maven -f Dockerfile.builder-maven . docker-pipeline: linux docker build -t rawlingsj/builder-base:dev . -f Dockerfile-pipeline @@ -145,23 +145,39 @@ docker-pipeline: linux docker-dev: linux docker build --no-cache -t $(DOCKER_HUB_USER)/jx:dev . docker push $(DOCKER_HUB_USER)/jx:dev - docker build --no-cache -t $(DOCKER_HUB_USER)/builder-go:dev -f Dockerfile.buildgo . + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-base:dev -f Dockerfile.builder-base . + docker push $(DOCKER_HUB_USER)/builder-base:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-go:dev -f Dockerfile.builder-go . docker push $(DOCKER_HUB_USER)/builder-go:dev - docker build --no-cache -t $(DOCKER_HUB_USER)/builder-maven:dev -f Dockerfile.maven . + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-gradle:dev -f Dockerfile.builder-gradle . + docker push $(DOCKER_HUB_USER)/builder-gradle:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-maven:dev -f Dockerfile.builder-maven . docker push $(DOCKER_HUB_USER)/builder-maven:dev - docker build --no-cache -t $(DOCKER_HUB_USER)/builder-nodejs:dev -f Dockerfile.nodejs . + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-rust:dev -f Dockerfile.builder-rust . + docker push $(DOCKER_HUB_USER)/builder-rust:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-scala:dev -f Dockerfile.builder-scala . + docker push $(DOCKER_HUB_USER)/builder-scala:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-swift:dev -f Dockerfile.builder-swift . + docker push $(DOCKER_HUB_USER)/builder-swift:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-terraform:dev -f Dockerfile.builder-terraform . + docker push $(DOCKER_HUB_USER)/builder-terraform:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-nodejs:dev -f Dockerfile.builder-nodejs . docker push $(DOCKER_HUB_USER)/builder-nodejs:dev - docker build --no-cache -t $(DOCKER_HUB_USER)/builder-base:dev -f Dockerfile.base . - docker push $(DOCKER_HUB_USER)/builder-base:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-python:dev -f Dockerfile.builder-python . + docker push $(DOCKER_HUB_USER)/builder-python:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-python2:dev -f Dockerfile.builder-python2 . + docker push $(DOCKER_HUB_USER)/builder-python2:dev + docker build --no-cache -t $(DOCKER_HUB_USER)/builder-ruby:dev -f Dockerfile.builder-ruby . + docker push $(DOCKER_HUB_USER)/builder-ruby:dev .PHONY: release clean arm preview: - docker build --no-cache -t docker.io/jenkinsxio/builder-maven:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) -f Dockerfile.maven . + docker build --no-cache -t docker.io/jenkinsxio/builder-maven:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) -f Dockerfile.builder-maven . docker push docker.io/jenkinsxio/builder-maven:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) - docker build --no-cache -t docker.io/jenkinsxio/builder-go:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) -f Dockerfile.buildgo . + docker build --no-cache -t docker.io/jenkinsxio/builder-go:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) -f Dockerfile.builder-go . docker push docker.io/jenkinsxio/builder-go:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) - docker build --no-cache -t docker.io/jenkinsxio/builder-nodejs:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) -f Dockerfile.nodejs . + docker build --no-cache -t docker.io/jenkinsxio/builder-nodejs:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) -f Dockerfile.builder-nodejs . docker push docker.io/jenkinsxio/builder-nodejs:SNAPSHOT-JX-$(BRANCH_NAME)-$(BUILD_NUMBER) FGT := $(GOPATH)/bin/fgt diff --git a/pkg/helm/helm_helpers.go b/pkg/helm/helm_helpers.go index ba2f0de334..6c37bd4dbd 100644 --- a/pkg/helm/helm_helpers.go +++ b/pkg/helm/helm_helpers.go @@ -2,11 +2,13 @@ package helm import ( "fmt" + "io/ioutil" + "path/filepath" + "sort" + "github.com/ghodss/yaml" "github.com/jenkins-x/jx/pkg/util" - "io/ioutil" "k8s.io/helm/pkg/chartutil" - "path/filepath" ) const ( @@ -62,6 +64,13 @@ type Requirements struct { Dependencies []*Dependency `json:"dependencies"` } +// DepSorter Used to avoid merge conflicts by sorting deps by name +type DepSorter []*Dependency + +func (a DepSorter) Len() int { return len(a) } +func (a DepSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a DepSorter) Less(i, j int) bool { return a[i].Name < a[j].Name } + // SetAppVersion sets the version of the app to use func (r *Requirements) SetAppVersion(app string, version string, repository string) { if r.Dependencies == nil { @@ -79,6 +88,7 @@ func (r *Requirements) SetAppVersion(app string, version string, repository stri Version: version, Repository: repository, }) + sort.Sort(DepSorter(r.Dependencies)) } // RemoveApp removes the given app name. Returns true if a dependency was removed @@ -86,6 +96,7 @@ func (r *Requirements) RemoveApp(app string) bool { for i, dep := range r.Dependencies { if dep != nil && dep.Name == app { r.Dependencies = append(r.Dependencies[:i], r.Dependencies[i+1:]...) + sort.Sort(DepSorter(r.Dependencies)) return true } } @@ -152,10 +163,9 @@ func LoadRequirementsFile(fileName string) (*Requirements, error) { return nil, err } return LoadRequirements(data) - } else { - r := &Requirements{} - return r, nil } + r := &Requirements{} + return r, nil } // LoadRequirements loads the requirements from some data