Skip to content

Commit

Permalink
Split imports into 3 parts (#10)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 23, 2019
1 parent 1c447f4 commit f89adec
Show file tree
Hide file tree
Showing 106 changed files with 575 additions and 270 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@master
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@master
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

Expand Down
43 changes: 36 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

SHELL=/bin/bash -o pipefail

# The binary to build (just the basename).
GO_PKG := stash.appscode.dev
REPO := $(notdir $(shell pwd))
BIN := stash-mongodb
COMPRESS ?= no

Expand Down Expand Up @@ -50,7 +51,8 @@ NEW_RESTIC_VER := 0.9.5
### These variables should not need tweaking.
###

SRC_DIRS := cmd pkg # directories which hold app source (not vendored)
SRC_PKGS := cmd pkg
SRC_DIRS := $(SRC_PKGS) # directories which hold app source (not vendored)

DOCKER_PLATFORMS := linux/amd64
BIN_PLATFORMS := $(DOCKER_PLATFORMS)
Expand Down Expand Up @@ -80,7 +82,11 @@ endif
# Directories that we need created to build/test.
BUILD_DIRS := bin/$(OS)_$(ARCH) \
.go/bin/$(OS)_$(ARCH) \
.go/cache
.go/cache \
hack/config \
$(HOME)/.credentials \
$(HOME)/.kube \
$(HOME)/.minikube

DOCKERFILE_PROD = Dockerfile.in
DOCKERFILE_DBG = Dockerfile.dbg
Expand Down Expand Up @@ -141,7 +147,10 @@ fmt: $(BUILD_DIRS)
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \
./hack/fmt.sh $(SRC_DIRS)
/bin/bash -c " \
REPO_PKG=$(GO_PKG) \
./hack/fmt.sh $(SRC_DIRS) \
"

build: $(OUTBIN)

Expand Down Expand Up @@ -231,7 +240,10 @@ docker-manifest-%:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a $(IMAGE):$(VERSION_$*) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(VERSION_$*)_$(subst /,_,$(PLATFORM)))
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push $(IMAGE):$(VERSION_$*)

test: $(BUILD_DIRS)
.PHONY: test
test: unit-tests

unit-tests: $(BUILD_DIRS)
@docker run \
-i \
--rm \
Expand Down Expand Up @@ -270,16 +282,33 @@ lint: $(BUILD_DIRS)
--env GO111MODULE=on \
--env GOFLAGS="-mod=vendor" \
$(BUILD_IMAGE) \
golangci-lint run --enable $(ADDTL_LINTERS) --deadline=10m --skip-files="generated.*\.go$\" --skip-dirs-use-default --skip-dirs=client,vendor
golangci-lint run --enable $(ADDTL_LINTERS) --deadline=10m --skip-files="generated.*\.go$\" --skip-dirs-use-default

$(BUILD_DIRS):
@mkdir -p $@

.PHONY: dev
dev: gen fmt push

.PHONY: verify
verify: verify-modules verify-gen

.PHONY: verify-modules
verify-modules:
GO111MODULE=on go mod tidy
GO111MODULE=on go mod vendor
@if !(git diff --exit-code HEAD); then \
echo "go module files are out of date"; exit 1; \
fi

.PHONY: verify-gen
verify-gen: gen fmt
@if !(git diff --exit-code HEAD); then \
echo "files are out of date, run make gen fmt"; exit 1; \
fi

.PHONY: ci
ci: lint test build #cover
ci: verify-gen lint build unit-tests #cover

.PHONY: qa
qa:
Expand Down
5 changes: 3 additions & 2 deletions cmd/stash-mongodb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"os"
"runtime"

"stash.appscode.dev/mongodb/pkg"
_ "stash.appscode.dev/stash/client/clientset/versioned/fake"

"github.com/appscode/go/log"
_ "k8s.io/client-go/kubernetes/fake"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"kmodules.xyz/client-go/logs"
"stash.appscode.dev/mongodb/pkg"
_ "stash.appscode.dev/stash/client/clientset/versioned/fake"
)

func main() {
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ require (
github.com/spf13/cobra v0.0.5
k8s.io/apimachinery v0.0.0-20190508063446-a3da69d3723c
k8s.io/client-go v11.0.0+incompatible
kmodules.xyz/client-go v0.0.0-20191016085444-3044854ca625
kmodules.xyz/client-go v0.0.0-20191023042933-b12d1ccfaf57
kmodules.xyz/custom-resources v0.0.0-20190927035424-65fe358bb045
kubedb.dev/apimachinery v0.13.0-rc.1.0.20191018033414-e2aca1186349
stash.appscode.dev/stash v0.9.0-rc.1.0.20191018180359-9ef3cfeba2a2
kubedb.dev/apimachinery v0.13.0-rc.2
stash.appscode.dev/stash v0.9.0-rc.2
)

replace (
git.apache.org/thrift.git => github.com/apache/thrift v0.12.0
github.com/Azure/go-autorest => github.com/Azure/go-autorest v12.4.2+incompatible
k8s.io/api => k8s.io/api v0.0.0-20190313235455-40a48860b5ab
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190315093550-53c4693659ed
Expand All @@ -30,6 +29,6 @@ replace (
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30
k8s.io/kubernetes => k8s.io/kubernetes v1.14.0
k8s.io/metrics => k8s.io/metrics v0.0.0-20190314001731-1bd6a4002213
k8s.io/utils => k8s.io/utils v0.0.0-20190221042446-c2654d5206da
k8s.io/utils => k8s.io/utils v0.0.0-20190514214443-0a167cbac756
sigs.k8s.io/structured-merge-diff => sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2
)
26 changes: 13 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
contrib.go.opencensus.io/exporter/ocagent v0.4.1/go.mod h1:b6YwD5Q3Yvj4yk0CDK5vGXexygNzI09aXUdDEakQBgA=
contrib.go.opencensus.io/exporter/ocagent v0.4.6 h1:xVeoJwnzMbseoL9YWhohR6SN/GncvP1p/fznasLkT/E=
contrib.go.opencensus.io/exporter/ocagent v0.4.6/go.mod h1:YuG83h+XWwqWjvCqn7vK4KSyLKhThY3+gNGQ37iS2V0=
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
git.apache.org/thrift.git v0.0.0-20181218151757-9b75e4fe745a/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
github.com/Azure/azure-pipeline-go v0.1.8/go.mod h1:XA1kFWRVhSK+KNFiOhfv83Fv8L9achrP7OxIzeTn1Yg=
github.com/Azure/azure-sdk-for-go v23.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v31.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
Expand Down Expand Up @@ -513,6 +516,7 @@ gomodules.xyz/envsubst v0.1.0/go.mod h1:2o5f7bd13XIITbE2ZKieE05YkqB2KDoZkqKccGeb
gomodules.xyz/jsonpatch/v2 v2.0.0 h1:OyHbl+7IOECpPKfVK42oFr6N7+Y2dR+Jsb/IiDV3hOo=
gomodules.xyz/jsonpatch/v2 v2.0.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
gomodules.xyz/stow v0.2.0/go.mod h1:YDDPM4nmJgQhxq4I5aGtLM/xrvJzDSVM/fbc7NGizpY=
gomodules.xyz/stow v0.2.2/go.mod h1:YDDPM4nmJgQhxq4I5aGtLM/xrvJzDSVM/fbc7NGizpY=
gomodules.xyz/version v0.0.0-20190507203204-7cec7ee542d3/go.mod h1:Y8xuV02mL/45psyPKG3NCVOwvAOy6T5Kx0l3rCjKSjU=
gomodules.xyz/version v0.1.0 h1:inGItCg/egI0jPMeIE0SQkiDIJaodOMoCrxYqasQLR0=
gomodules.xyz/version v0.1.0/go.mod h1:Y8xuV02mL/45psyPKG3NCVOwvAOy6T5Kx0l3rCjKSjU=
Expand Down Expand Up @@ -587,18 +591,15 @@ k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86
k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
k8s.io/kubernetes v1.14.0 h1:6T2iAEoOYQnzQb3WvPlUkcczEEXZ7+YPlAO8olwujRw=
k8s.io/kubernetes v1.14.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4=
k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
k8s.io/utils v0.0.0-20190514214443-0a167cbac756 h1:2XBbostlqrw13zVYimyqcj/Om2P4B26oMzv+m2cj//k=
k8s.io/utils v0.0.0-20190514214443-0a167cbac756/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
kmodules.xyz/client-go v0.0.0-20190808141354-bbb9e14f60ab/go.mod h1:1GI6h5D31op/2D+Hrn9DhXW6iUd5wsHBQRoLeY7fndM=
kmodules.xyz/client-go v0.0.0-20191006173540-91f8ee6b6b4b/go.mod h1:1GI6h5D31op/2D+Hrn9DhXW6iUd5wsHBQRoLeY7fndM=
kmodules.xyz/client-go v0.0.0-20191014080252-6458e3cb3ca6/go.mod h1:VgT/bx3wEwarnLoDMMH5vjmKYIOO0WBPyvoCAiWKWxg=
kmodules.xyz/client-go v0.0.0-20191016085444-3044854ca625 h1:A/ceKV+HXdheKSpaY2CF7Q70E/iDKoysxiWtAuYMXyE=
kmodules.xyz/client-go v0.0.0-20191016085444-3044854ca625/go.mod h1:wFUBDofZzgkLW1sFJT5SSt6/G3ph2P8zUi5v81q5BKQ=
kmodules.xyz/client-go v0.0.0-20191023042933-b12d1ccfaf57 h1:4IsITvsVOl0W8IRABEMOqEMyJYwTCmhmfpJVIpwD4lM=
kmodules.xyz/client-go v0.0.0-20191023042933-b12d1ccfaf57/go.mod h1:BChXGI3zd3lNSjUUfDcGmvufMdqrofLI/nrndcZ4LUo=
kmodules.xyz/constants v0.0.0-20191009183447-fbd33067b8a6/go.mod h1:DbiFk1bJ1KEO94t1SlAn7tzc+Zz95rSXgyUKa2nzPmY=
kmodules.xyz/custom-resources v0.0.0-20190927035424-65fe358bb045 h1:DuvD64ouPDbv3egAUUCy5rBqs/vc218DeVVivcqfa+U=
kmodules.xyz/custom-resources v0.0.0-20190927035424-65fe358bb045/go.mod h1:vlKyFcCXC+2Kfn3Fa5Z7RnBWyp4t46FSeEutNqpqMm8=
kmodules.xyz/monitoring-agent-api v0.0.0-20190808150221-601a4005b7f7/go.mod h1:9v6LM+dmaAP3jjDiPOPOLPfsvD7jNjBJsi37JNCiFho=
kmodules.xyz/objectstore-api v0.0.0-20191006080053-fc8b57fadcf0/go.mod h1:mT7lEi2IehAi64DomCPMPtlsWXOD5Fr3/mPqLIzU7T8=
kmodules.xyz/objectstore-api v0.0.0-20191014164602-39104ec912b7/go.mod h1:mT7lEi2IehAi64DomCPMPtlsWXOD5Fr3/mPqLIzU7T8=
kmodules.xyz/objectstore-api v0.0.0-20191014210450-ac380fa650a3 h1:64QSexLk/Dio4+L8Ge1tb4c44aBiwmUwTNP2kCu6YQU=
kmodules.xyz/objectstore-api v0.0.0-20191014210450-ac380fa650a3/go.mod h1:mT7lEi2IehAi64DomCPMPtlsWXOD5Fr3/mPqLIzU7T8=
kmodules.xyz/offshoot-api v0.0.0-20190901210649-de049192326c h1:y54FqF02HNs2d4eJh6w+7Q2sfVLORzvZd/ueGm/t7Fg=
Expand All @@ -607,15 +608,14 @@ kmodules.xyz/openshift v0.0.0-20190808144841-c8f9a927f1d1 h1:NmVj5+kPpUgoxRans2X
kmodules.xyz/openshift v0.0.0-20190808144841-c8f9a927f1d1/go.mod h1:+E8HHcxBx6ja4oKOXZ6DCoQ+NjujODTgFOfgOe+ejXw=
kmodules.xyz/webhook-runtime v0.0.0-20190808145328-4186c470d56b h1:yd/uzBgLgsir3X4kGoznJY7CdrkgfznsNKvD4p2xUaQ=
kmodules.xyz/webhook-runtime v0.0.0-20190808145328-4186c470d56b/go.mod h1:X8J6YJvk3NqufXEDqcl2oFuL8T6+mV+AN30/miV4iJU=
kubedb.dev/apimachinery v0.13.0-rc.1.0.20191018033414-e2aca1186349 h1:GbB+QOpXyBjwj7JpFnbPG4q5Inp9CExId/h5Rl6r4x4=
kubedb.dev/apimachinery v0.13.0-rc.1.0.20191018033414-e2aca1186349/go.mod h1:XPKlQEFXiVsVasIlY6wku8iOiwqsHTsdwRI6EtnwVPk=
kubedb.dev/apimachinery v0.13.0-rc.2 h1:I/KXiJfXN/jB6zxHYsXhiVeuELjvsq17fFlTFwkIRb0=
kubedb.dev/apimachinery v0.13.0-rc.2/go.mod h1:pBjAo1UtqY09U0oqkHoDVQCO+06+aYLh9/cy4F3wasI=
labix.org/v2/mgo v0.0.0-20140701140051-000000000287/go.mod h1:Lg7AYkt1uXJoR9oeSZ3W/8IXLdvOfIITgZnommstyz4=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
stash.appscode.dev/stash v0.9.0-rc.1.0.20191007102408-f5a271be821a/go.mod h1:GZphLGASEViwv3yAoVSmImaHQ7qDIkY+8Cd/DQjl6g8=
stash.appscode.dev/stash v0.9.0-rc.1.0.20191018180359-9ef3cfeba2a2 h1:H2a7zLOI7Q6OxHuI8gzQKYJx/BPREOgQjbkVCLVUXYY=
stash.appscode.dev/stash v0.9.0-rc.1.0.20191018180359-9ef3cfeba2a2/go.mod h1:N8pJqTaV01TZpspiGEGfRBkJTNHkJ0ihflN0LYx3wPw=
stash.appscode.dev/stash v0.9.0-rc.2 h1:oZTmaDDTjANefmsNWYjqb0cqZYGl4JAeiewAlJJPnlE=
stash.appscode.dev/stash v0.9.0-rc.2/go.mod h1:DgbSJa5P8tV+V9dX/CxURZDnudLvgnKyuZksJF/Fp7Q=
2 changes: 1 addition & 1 deletion hack/fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export GOFLAGS="-mod=vendor"
TARGETS="$@"

echo "Running reimport.py"
cmd="reimport.py ${TARGETS}"
cmd="reimport3.py ${REPO_PKG} ${TARGETS}"
$cmd
echo

Expand Down
11 changes: 6 additions & 5 deletions pkg/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import (
"syscall"
"time"

api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1"
stash_cs "stash.appscode.dev/stash/client/clientset/versioned"
stash_cs_util "stash.appscode.dev/stash/client/clientset/versioned/typed/stash/v1beta1/util"
"stash.appscode.dev/stash/pkg/restic"
"stash.appscode.dev/stash/pkg/util"

"github.com/appscode/go/flags"
"github.com/appscode/go/log"
"github.com/appscode/go/types"
Expand All @@ -24,11 +30,6 @@ import (
"k8s.io/client-go/tools/clientcmd"
appcatalog_cs "kmodules.xyz/custom-resources/client/clientset/versioned"
"kubedb.dev/apimachinery/apis/config/v1alpha1"
api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1"
stash_cs "stash.appscode.dev/stash/client/clientset/versioned"
stash_cs_util "stash.appscode.dev/stash/client/clientset/versioned/typed/stash/v1beta1/util"
"stash.appscode.dev/stash/pkg/restic"
"stash.appscode.dev/stash/pkg/util"
)

var (
Expand Down
11 changes: 6 additions & 5 deletions pkg/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import (
"path/filepath"
"strings"

api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1"
stash_cs "stash.appscode.dev/stash/client/clientset/versioned"
stash_cs_util "stash.appscode.dev/stash/client/clientset/versioned/typed/stash/v1beta1/util"
"stash.appscode.dev/stash/pkg/restic"
"stash.appscode.dev/stash/pkg/util"

"github.com/appscode/go/flags"
"github.com/appscode/go/log"
"github.com/appscode/go/types"
Expand All @@ -19,11 +25,6 @@ import (
"k8s.io/client-go/tools/clientcmd"
appcatalog_cs "kmodules.xyz/custom-resources/client/clientset/versioned"
"kubedb.dev/apimachinery/apis/config/v1alpha1"
api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1"
stash_cs "stash.appscode.dev/stash/client/clientset/versioned"
stash_cs_util "stash.appscode.dev/stash/client/clientset/versioned/typed/stash/v1beta1/util"
"stash.appscode.dev/stash/pkg/restic"
"stash.appscode.dev/stash/pkg/util"
)

func NewCmdRestore() *cobra.Command {
Expand Down
5 changes: 3 additions & 2 deletions pkg/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package pkg
import (
"flag"

"stash.appscode.dev/stash/client/clientset/versioned/scheme"
"stash.appscode.dev/stash/pkg/util"

"github.com/appscode/go/flags"
v "github.com/appscode/go/version"
"github.com/spf13/cobra"
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
"kmodules.xyz/client-go/logs"
"kmodules.xyz/client-go/tools/cli"
"stash.appscode.dev/stash/client/clientset/versioned/scheme"
"stash.appscode.dev/stash/pkg/util"
)

func NewRootCmd() *cobra.Command {
Expand Down
5 changes: 3 additions & 2 deletions pkg/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"strings"
"time"

stash_cs "stash.appscode.dev/stash/client/clientset/versioned"
"stash.appscode.dev/stash/pkg/restic"

"github.com/appscode/go/log"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/kubernetes"
appcatalog_cs "kmodules.xyz/custom-resources/client/clientset/versioned"
stash_cs "stash.appscode.dev/stash/client/clientset/versioned"
"stash.appscode.dev/stash/pkg/restic"
)

const (
Expand Down
5 changes: 5 additions & 0 deletions vendor/kmodules.xyz/client-go/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ dist/
**/.env
.vscode/
coverage.txt

/bin
/.go

apiserver.local.config/**
25 changes: 0 additions & 25 deletions vendor/kmodules.xyz/client-go/.travis.yml

This file was deleted.

Loading

0 comments on commit f89adec

Please sign in to comment.