mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
* chore(migrate): mockery migrate to packages migrate interface - remove go:generate - generate mock Signed-off-by: Jack-R-lantern <tjdfkr2421@gmail.com> * chore(migrate: mockery migrate to package add mockgen stage - add mockgen command to Makefile - add generate-mock.sh - add install mockery to install-codegen-go-tool.sh Signed-off-by: Jack-R-lantern <tjdfkr2421@gmail.com> --------- Signed-off-by: Jack-R-lantern <tjdfkr2421@gmail.com>
This commit is contained in:
parent
c6f96d7615
commit
06b0f957b8
28 changed files with 88 additions and 40 deletions
48
.mockery.yaml
Normal file
48
.mockery.yaml
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# global config
|
||||
filename: "{{.InterfaceName}}.go"
|
||||
dir: "{{.InterfaceDir}}/mocks"
|
||||
outpkg: "mocks"
|
||||
mockname: "{{.InterfaceName}}"
|
||||
with-expecter: false
|
||||
# individual interface config
|
||||
packages:
|
||||
github.com/argoproj/argo-cd/v2/applicationset/generators:
|
||||
interfaces:
|
||||
Generator:
|
||||
github.com/argoproj/argo-cd/v2/applicationset/services:
|
||||
interfaces:
|
||||
Repos:
|
||||
github.com/microsoft/azure-devops-go-api/azuredevops/git:
|
||||
config:
|
||||
dir: "applicationset/services/scm_provider/azure_devops/git/mocks"
|
||||
interfaces:
|
||||
Client:
|
||||
github.com/argoproj/argo-cd/v2/applicationset/utils:
|
||||
interfaces:
|
||||
Renderer:
|
||||
github.com/argoproj/argo-cd/v2/controller/cache:
|
||||
interfaces:
|
||||
LiveStateCache:
|
||||
github.com/argoproj/argo-cd/v2/reposerver/apiclient:
|
||||
interfaces:
|
||||
RepoServerServiceClient:
|
||||
github.com/argoproj/argo-cd/v2/util/db:
|
||||
interfaces:
|
||||
ArgoDB:
|
||||
github.com/argoproj/argo-cd/v2/util/git:
|
||||
interfaces:
|
||||
Client:
|
||||
github.com/argoproj/argo-cd/v2/util/helm:
|
||||
interfaces:
|
||||
Client:
|
||||
github.com/argoproj/argo-cd/v2/util/notification/argocd:
|
||||
interfaces:
|
||||
Service:
|
||||
# These mocks are not currently used, but they are part of the public API of this package.
|
||||
github.com/argoproj/argo-cd/v2/pkg/apiclient/session:
|
||||
interfaces:
|
||||
SessionServiceServer:
|
||||
SessionServiceClient:
|
||||
github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster:
|
||||
interfaces:
|
||||
ClusterServiceServer:
|
||||
8
Makefile
8
Makefile
|
|
@ -192,6 +192,10 @@ endif
|
|||
.PHONY: all
|
||||
all: cli image
|
||||
|
||||
.PHONY: mockgen
|
||||
mockgen:
|
||||
./hack/generate-mock.sh
|
||||
|
||||
.PHONY: gogen
|
||||
gogen:
|
||||
export GO111MODULE=off
|
||||
|
|
@ -231,11 +235,11 @@ clidocsgen:
|
|||
|
||||
|
||||
.PHONY: codegen-local
|
||||
codegen-local: mod-vendor-local gogen protogen clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
|
||||
codegen-local: mod-vendor-local mockgen gogen protogen clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
|
||||
rm -rf vendor/
|
||||
|
||||
.PHONY: codegen-local-fast
|
||||
codegen-local-fast: gogen protogen-fast clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
|
||||
codegen-local-fast: mockgen gogen protogen-fast clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
|
||||
|
||||
.PHONY: codegen
|
||||
codegen: test-tools-image
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import (
|
|||
argoprojiov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=Generator
|
||||
|
||||
// Generator defines the interface implemented by all ApplicationSet generators.
|
||||
type Generator interface {
|
||||
// GenerateParams interprets the ApplicationSet and generates all relevant parameters for the application template.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ type argoCDService struct {
|
|||
newFileGlobbingEnabled bool
|
||||
}
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=Repos
|
||||
|
||||
type Repos interface {
|
||||
// GetFiles returns content of files (not directories) within the target repo
|
||||
GetFiles(ctx context.Context, repoURL string, revision string, pattern string, noRevisionCache, verifyCommit bool) (map[string][]byte, error)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ import (
|
|||
azureMock "github.com/argoproj/argo-cd/v2/applicationset/services/scm_provider/azure_devops/git/mocks"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --srcpkg=github.com/microsoft/azure-devops-go-api/azuredevops/git --name=Client --output=azure_devops/git/mocks --outpkg=mocks
|
||||
|
||||
func s(input string) *string {
|
||||
return ptr.To(input)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
@ -25,8 +25,6 @@ import (
|
|||
argoappsv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=Renderer
|
||||
|
||||
var sprigFuncMap = sprig.GenericFuncMap() // a singleton for better performance
|
||||
|
||||
func init() {
|
||||
|
|
|
|||
2
controller/cache/cache.go
vendored
2
controller/cache/cache.go
vendored
|
|
@ -41,8 +41,6 @@ import (
|
|||
"github.com/argoproj/argo-cd/v2/util/settings"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=LiveStateCache
|
||||
|
||||
const (
|
||||
// EnvClusterCacheResyncDuration is the env variable that holds cluster cache re-sync duration
|
||||
EnvClusterCacheResyncDuration = "ARGOCD_CLUSTER_CACHE_RESYNC_DURATION"
|
||||
|
|
|
|||
2
controller/cache/mocks/LiveStateCache.go
vendored
2
controller/cache/mocks/LiveStateCache.go
vendored
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
18
hack/generate-mock.sh
Executable file
18
hack/generate-mock.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# shellcheck disable=SC2128
|
||||
PROJECT_ROOT=$(
|
||||
cd "$(dirname "${BASH_SOURCE}")"/..
|
||||
pwd
|
||||
)
|
||||
PATH="${PROJECT_ROOT}/dist:${PATH}"
|
||||
|
||||
# output tool versions
|
||||
mockery --version
|
||||
|
||||
mockery --config ${PROJECT_ROOT}/.mockery.yaml
|
||||
|
|
@ -52,3 +52,6 @@ go install github.com/go-swagger/go-swagger/cmd/swagger@v0.28.0
|
|||
|
||||
# goimports is used to auto-format generated code
|
||||
go install golang.org/x/tools/cmd/goimports@v0.1.8
|
||||
|
||||
# mockery is used to generate mock
|
||||
go install github.com/vektra/mockery/v2@v2.43.2
|
||||
|
|
@ -56,12 +56,6 @@ import (
|
|||
tls_util "github.com/argoproj/argo-cd/v2/util/tls"
|
||||
)
|
||||
|
||||
// These mocks are not currently used, but they are part of the public API of this package.
|
||||
//go:generate -command mockery go run github.com/vektra/mockery/v2@v2.40.2
|
||||
//go:generate mockery --dir=./session --name=SessionServiceServer --output=./session/mocks
|
||||
//go:generate mockery --dir=./session --name=SessionServiceClient --output=./session/mocks
|
||||
//go:generate mockery --dir=./cluster --name=ClusterServiceServer --output=./cluster/mocks
|
||||
|
||||
const (
|
||||
MetaDataTokenKey = "token"
|
||||
// EnvArgoCDServer is the environment variable to look for an Argo CD server address
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ import (
|
|||
"github.com/argoproj/argo-cd/v2/util/io"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=RepoServerServiceClient
|
||||
|
||||
// MaxGRPCMessageSize contains max grpc message size
|
||||
var MaxGRPCMessageSize = env.ParseNumFromEnv(common.EnvGRPCMaxSizeMB, 100, 0, math.MaxInt32) * 1024 * 1024
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ type SecretMaperValidation struct {
|
|||
Transform func(string) string
|
||||
}
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name ArgoDB
|
||||
|
||||
type ArgoDB interface {
|
||||
// ListClusters lists configured clusters
|
||||
ListClusters(ctx context.Context) (*appv1.ClusterList, error)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@ import (
|
|||
"github.com/argoproj/argo-cd/v2/util/proxy"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=Client
|
||||
|
||||
var ErrInvalidRepoURL = fmt.Errorf("repo URL is invalid")
|
||||
|
||||
type RevisionMetadata struct {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ import (
|
|||
"github.com/argoproj/argo-cd/v2/util/proxy"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=Client
|
||||
|
||||
var (
|
||||
globalLock = sync.NewKeyLock()
|
||||
indexLock = sync.NewKeyLock()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.40.2. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/argoproj/argo-cd/v2/util/settings"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/vektra/mockery/v2@v2.40.2 --name=Service
|
||||
type Service interface {
|
||||
GetCommitMetadata(ctx context.Context, repoURL string, commitSHA string, project string) (*shared.CommitMetadata, error)
|
||||
GetAppDetails(ctx context.Context, app *v1alpha1.Application) (*shared.AppDetail, error)
|
||||
|
|
|
|||
Loading…
Reference in a new issue