From 7ca8b765c384bf7358cd42a7265cd6f8a26ee054 Mon Sep 17 00:00:00 2001 From: fabrue Date: Mon, 14 Aug 2023 16:00:20 +0200 Subject: [PATCH 1/2] chore: install pre-commit and run it for all files --- .gitignore | 2 +- .pre-commit-config.yaml | 11 +++++++++++ nexus3/pkg/security/testfiles/saml-testconfig.xml | 2 +- scripts/gofmtcheck.sh | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.gitignore b/.gitignore index a44137e..8accb56 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -scripts/license.lic \ No newline at end of file +scripts/license.lic diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1e46462 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/commitizen-tools/commitizen + rev: v2.27.1 + hooks: + - id: commitizen + stages: [commit-msg] diff --git a/nexus3/pkg/security/testfiles/saml-testconfig.xml b/nexus3/pkg/security/testfiles/saml-testconfig.xml index 66b6a4e..90336a1 100644 --- a/nexus3/pkg/security/testfiles/saml-testconfig.xml +++ b/nexus3/pkg/security/testfiles/saml-testconfig.xml @@ -119,4 +119,4 @@ facing addresses if this IdP is hosted behind a reverse proxy. --> - \ No newline at end of file + diff --git a/scripts/gofmtcheck.sh b/scripts/gofmtcheck.sh index 254ed87..1c05581 100755 --- a/scripts/gofmtcheck.sh +++ b/scripts/gofmtcheck.sh @@ -10,4 +10,4 @@ if [[ -n ${gofmt_files} ]]; then exit 1 fi -exit 0 \ No newline at end of file +exit 0 From 9f28310fa993596ef061bc3b37ceed6f80a63ec3 Mon Sep 17 00:00:00 2001 From: fabrue Date: Mon, 14 Aug 2023 16:47:29 +0200 Subject: [PATCH 2/2] ran pre-commit --- .pre-commit-config.yaml | 9 +++++++++ nexus3/pkg/repository/bower/proxy.go | 2 +- nexus3/pkg/repository/bower/service.go | 1 + nexus3/pkg/repository/maven/proxy_test.go | 2 +- nexus3/pkg/repository/npm/group_test.go | 1 - nexus3/schema/repository/bower.go | 2 +- nexus3/schema/repository/http_client.go | 8 ++++---- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e46462..7e15a0a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,3 +9,12 @@ repos: hooks: - id: commitizen stages: [commit-msg] +- repo: https://github.com/tekwizely/pre-commit-golang + rev: v1.0.0-rc.1 + hooks: + - id: go-fmt + - id: go-mod-tidy + - id: go-imports + # FIX ME: See https://github.com/datadrivers/go-nexus-client/issues/122 + # - id: go-vet + # - id: golangci-lint-mod diff --git a/nexus3/pkg/repository/bower/proxy.go b/nexus3/pkg/repository/bower/proxy.go index edd589b..43f3a6a 100644 --- a/nexus3/pkg/repository/bower/proxy.go +++ b/nexus3/pkg/repository/bower/proxy.go @@ -12,7 +12,7 @@ import ( ) const ( - bowerProxyAPIEndpoint = repositoryBowerAPIEndpoint + "/proxy" + bowerProxyAPIEndpoint = repositoryBowerAPIEndpoint + "/proxy" ) type RepositoryBowerProxyService struct { diff --git a/nexus3/pkg/repository/bower/service.go b/nexus3/pkg/repository/bower/service.go index 746239f..02cd40f 100644 --- a/nexus3/pkg/repository/bower/service.go +++ b/nexus3/pkg/repository/bower/service.go @@ -8,6 +8,7 @@ import ( const ( repositoryBowerAPIEndpoint = common.RepositoryAPIEndpoint + "/bower" ) + type RepositoryBowerService struct { client *client.Client diff --git a/nexus3/pkg/repository/maven/proxy_test.go b/nexus3/pkg/repository/maven/proxy_test.go index c30e3f3..c096bb5 100644 --- a/nexus3/pkg/repository/maven/proxy_test.go +++ b/nexus3/pkg/repository/maven/proxy_test.go @@ -31,7 +31,7 @@ func getTestMavenProxyRepository(name string) repository.MavenProxyRepository { Proxy: repository.Proxy{ ContentMaxAge: 1440, MetadataMaxAge: 1440, - RemoteURL: "https://archive.ubuntu.com/ubuntu/", + RemoteURL: "https://archive.ubuntu.com/ubuntu/", }, Storage: repository.Storage{ BlobStoreName: "default", diff --git a/nexus3/pkg/repository/npm/group_test.go b/nexus3/pkg/repository/npm/group_test.go index f9d1160..3697d63 100644 --- a/nexus3/pkg/repository/npm/group_test.go +++ b/nexus3/pkg/repository/npm/group_test.go @@ -46,7 +46,6 @@ func TestNpmGroupRepository(t *testing.T) { repo.Group.MemberNames = append(repo.Group.MemberNames, testProxyRepo.Name) } - err = service.Group.Create(repo) assert.Nil(t, err) generatedRepo, err := service.Group.Get(repo.Name) diff --git a/nexus3/schema/repository/bower.go b/nexus3/schema/repository/bower.go index d41efc4..1d0ad93 100644 --- a/nexus3/schema/repository/bower.go +++ b/nexus3/schema/repository/bower.go @@ -32,7 +32,7 @@ type BowerProxyRepository struct { RoutingRuleName *string `json:"routingRuleName,omitempty"` *Cleanup `json:"cleanup,omitempty"` - Bower `json:"bower"` + Bower `json:"bower"` } type Bower struct { diff --git a/nexus3/schema/repository/http_client.go b/nexus3/schema/repository/http_client.go index ee8fbcb..04d9ff9 100644 --- a/nexus3/schema/repository/http_client.go +++ b/nexus3/schema/repository/http_client.go @@ -54,11 +54,11 @@ type HTTPClientAuthentication struct { // HTTPClientAuthenticationWithPreemptive ... type HTTPClientAuthenticationWithPreemptive struct { - NTLMDomain string `json:"ntlmDomain,omitempty"` - NTLMHost string `json:"ntlmHost,omitempty"` - Password string `json:"password,omitempty"` + NTLMDomain string `json:"ntlmDomain,omitempty"` + NTLMHost string `json:"ntlmHost,omitempty"` + Password string `json:"password,omitempty"` Type HTTPClientAuthenticationType `json:"type"` - Username string `json:"username,omitempty"` + Username string `json:"username,omitempty"` // Whether to use pre-emptive authentication. Use with caution. Defaults to false. Preemptive *bool `json:"preemptive,omitempty"` }