fix: rename module to github.com/zalando/postgres-operator/v2 (#3156)

* fix: rename module to github.com/zalando/postgres-operator/v2

Upgrade performed using https://github.com/icholy/gomajor

```
gomajor path -version v2
```

Signed-off-by: Benjamin Ritter <benjamin.ritter@x-cellent.com>

* fix: make fmt

Signed-off-by: Benjamin Ritter <benjamin.ritter@x-cellent.com>

* fix: adjust codegen module name

Signed-off-by: Benjamin Ritter <benjamin.ritter@x-cellent.com>

---------

Signed-off-by: Benjamin Ritter <benjamin.ritter@x-cellent.com>
Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
This commit is contained in:
Benjamin Ritter
2026-08-20 19:28:36 +02:00
committed by Felix Kunde
co-authored by Felix Kunde
parent 00f75115e0
commit 6138bc4a69
86 changed files with 523 additions and 523 deletions
+2 -2
View File
@@ -6,8 +6,8 @@ import (
"fmt"
"github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando/postgres-operator/v2/pkg/spec"
"github.com/zalando/postgres-operator/v2/pkg/util/constants"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
+1 -1
View File
@@ -17,7 +17,7 @@ const (
resize2fs = "resize2fs"
)
//Ext234Resize implements the FilesystemResizer interface for the ext4/3/2fs.
// Ext234Resize implements the FilesystemResizer interface for the ext4/3/2fs.
type Ext234Resize struct {
}
+5 -5
View File
@@ -7,11 +7,11 @@ import (
b64 "encoding/base64"
"encoding/json"
apiacidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
zalandoclient "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned"
acidv1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1"
zalandov1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/typed/zalando.org/v1"
"github.com/zalando/postgres-operator/pkg/spec"
apiacidv1 "github.com/zalando/postgres-operator/v2/pkg/apis/acid.zalan.do/v1"
zalandoclient "github.com/zalando/postgres-operator/v2/pkg/generated/clientset/versioned"
acidv1 "github.com/zalando/postgres-operator/v2/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1"
zalandov1 "github.com/zalando/postgres-operator/v2/pkg/generated/clientset/versioned/typed/zalando.org/v1"
"github.com/zalando/postgres-operator/v2/pkg/spec"
apiappsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
+3 -3
View File
@@ -11,11 +11,11 @@ import (
"strconv"
"time"
"github.com/zalando/postgres-operator/pkg/util/constants"
httpclient "github.com/zalando/postgres-operator/pkg/util/httpclient"
"github.com/zalando/postgres-operator/v2/pkg/util/constants"
httpclient "github.com/zalando/postgres-operator/v2/pkg/util/httpclient"
"github.com/sirupsen/logrus"
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
acidv1 "github.com/zalando/postgres-operator/v2/pkg/apis/acid.zalan.do/v1"
v1 "k8s.io/api/core/v1"
)
+2 -2
View File
@@ -12,9 +12,9 @@ import (
"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/zalando/postgres-operator/mocks"
"github.com/zalando/postgres-operator/v2/mocks"
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
acidv1 "github.com/zalando/postgres-operator/v2/pkg/apis/acid.zalan.do/v1"
v1 "k8s.io/api/core/v1"
)
+243 -243
View File
@@ -1,243 +1,243 @@
package teams
import (
"fmt"
"net/http"
"net/http/httptest"
"reflect"
"testing"
"github.com/sirupsen/logrus"
)
var (
logger = logrus.New().WithField("pkg", "teamsapi")
token = "ec45b1cfbe7100c6315d183a3eb6cec0M2U1LWJkMzEtZDgzNzNmZGQyNGM3IiwiYXV0aF90aW1lIjoxNDkzNzMwNzQ1LCJpc3MiOiJodHRwcz"
input = `{
"dn": "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
"id": "acid",
"id_name": "acid",
"team_id": "111222",
"type": "official",
"name": "Acid team name",
"mail": [
"email1@example.com",
"email2@example.com"
],
"alias": [
"acid"
],
"member": [
"member1",
"member2",
"member3"
],
"infrastructure-accounts": [
{
"id": "1234512345",
"name": "acid",
"provider": "aws",
"type": "aws",
"description": "",
"owner": "acid",
"owner_dn": "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
"disabled": false
},
{
"id": "5432154321",
"name": "db",
"provider": "aws",
"type": "aws",
"description": "",
"owner": "acid",
"owner_dn": "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
"disabled": false
}
],
"cost_center": "00099999",
"delivery_lead": "member4",
"parent_team_id": "111221"
}`
)
var teamsAPItc = []struct {
in string
inCode int
inTeam string
out *Team
err error
}{
{
input,
200,
"acid",
&Team{
Dn: "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
ID: "acid",
TeamName: "acid",
TeamID: "111222",
Type: "official",
FullName: "Acid team name",
Aliases: []string{"acid"},
Mails: []string{"email1@example.com", "email2@example.com"},
Members: []string{"member1", "member2", "member3"},
CostCenter: "00099999",
DeliveryLead: "member4",
ParentTeamID: "111221",
InfrastructureAccounts: []infrastructureAccount{
{
ID: "1234512345",
Name: "acid",
Provider: "aws",
Type: "aws",
Description: "",
Owner: "acid",
OwnerDn: "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
Disabled: false},
{
ID: "5432154321",
Name: "db",
Provider: "aws",
Type: "aws",
Description: "",
Owner: "acid",
OwnerDn: "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
Disabled: false},
},
},
nil}, {
`{"error": "Access Token not valid"}`,
401,
"acid",
nil,
fmt.Errorf(`team API query failed with status code 401 and message: '"Access Token not valid"'`),
},
{
`{"status": "I'm a teapot'"}`,
418,
"acid",
nil,
fmt.Errorf(`team API query failed with status code 418`),
},
{
`{"status": "I'm a teapot`,
418,
"acid",
nil,
fmt.Errorf(`team API query failed with status code 418 and malformed response: unexpected EOF`),
},
{
`{"status": "I'm a teapot`,
200,
"acid",
nil,
fmt.Errorf(`could not parse team API response: unexpected EOF`),
},
{
input,
404,
"banana",
nil,
fmt.Errorf(`team API query failed with status code 404`),
},
}
var requestsURLtc = []struct {
url string
err error
}{
{
"coffee://localhost/",
fmt.Errorf(`Get "coffee://localhost/teams/acid": unsupported protocol scheme "coffee"`),
},
{
"http://192.168.0.%31/",
fmt.Errorf(`parse "http://192.168.0.%%31/teams/acid": invalid URL escape "%%31"`),
},
}
func TestInfo(t *testing.T) {
for _, tc := range teamsAPItc {
func() {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Authorization") != "Bearer "+token {
t.Errorf("authorization token is wrong or not provided")
}
w.WriteHeader(tc.inCode)
if _, err := fmt.Fprint(w, tc.in); err != nil {
t.Errorf("error writing teams api response %v", err)
}
}))
defer ts.Close()
api := NewTeamsAPI(ts.URL, logger)
actual, statusCode, err := api.TeamInfo(tc.inTeam, token)
if err != nil && err.Error() != tc.err.Error() {
t.Errorf("expected error: %v, got: %v", tc.err, err)
return
}
if !reflect.DeepEqual(actual, tc.out) {
t.Errorf("expected %#v, got: %#v", tc.out, actual)
}
if statusCode != tc.inCode {
t.Errorf("expected %d, got: %d", tc.inCode, statusCode)
}
}()
}
}
type mockHTTPClient struct {
}
type mockBody struct {
}
func (b *mockBody) Read(p []byte) (n int, err error) {
return 2, nil
}
func (b *mockBody) Close() error {
return fmt.Errorf("close error")
}
func (c *mockHTTPClient) Do(req *http.Request) (*http.Response, error) {
resp := http.Response{
Status: "200 OK",
StatusCode: 200,
ContentLength: 2,
Close: false,
Request: req,
}
resp.Body = &mockBody{}
return &resp, nil
}
func TestHttpClientClose(t *testing.T) {
ts := httptest.NewServer(nil)
api := NewTeamsAPI(ts.URL, logger)
api.httpClient = &mockHTTPClient{}
_, _, err := api.TeamInfo("acid", token)
expError := fmt.Errorf("error when closing response: close error")
if err.Error() != expError.Error() {
t.Errorf("expected error: %v, got: %v", expError, err)
}
}
func TestRequest(t *testing.T) {
for _, tc := range requestsURLtc {
api := NewTeamsAPI(tc.url, logger)
resp, _, err := api.TeamInfo("acid", token)
if resp != nil {
t.Errorf("response expected to be nil")
continue
}
if err.Error() != tc.err.Error() {
t.Errorf("expected error: %v, got: %v", tc.err, err)
}
}
}
package teams
import (
"fmt"
"net/http"
"net/http/httptest"
"reflect"
"testing"
"github.com/sirupsen/logrus"
)
var (
logger = logrus.New().WithField("pkg", "teamsapi")
token = "ec45b1cfbe7100c6315d183a3eb6cec0M2U1LWJkMzEtZDgzNzNmZGQyNGM3IiwiYXV0aF90aW1lIjoxNDkzNzMwNzQ1LCJpc3MiOiJodHRwcz"
input = `{
"dn": "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
"id": "acid",
"id_name": "acid",
"team_id": "111222",
"type": "official",
"name": "Acid team name",
"mail": [
"email1@example.com",
"email2@example.com"
],
"alias": [
"acid"
],
"member": [
"member1",
"member2",
"member3"
],
"infrastructure-accounts": [
{
"id": "1234512345",
"name": "acid",
"provider": "aws",
"type": "aws",
"description": "",
"owner": "acid",
"owner_dn": "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
"disabled": false
},
{
"id": "5432154321",
"name": "db",
"provider": "aws",
"type": "aws",
"description": "",
"owner": "acid",
"owner_dn": "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
"disabled": false
}
],
"cost_center": "00099999",
"delivery_lead": "member4",
"parent_team_id": "111221"
}`
)
var teamsAPItc = []struct {
in string
inCode int
inTeam string
out *Team
err error
}{
{
input,
200,
"acid",
&Team{
Dn: "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
ID: "acid",
TeamName: "acid",
TeamID: "111222",
Type: "official",
FullName: "Acid team name",
Aliases: []string{"acid"},
Mails: []string{"email1@example.com", "email2@example.com"},
Members: []string{"member1", "member2", "member3"},
CostCenter: "00099999",
DeliveryLead: "member4",
ParentTeamID: "111221",
InfrastructureAccounts: []infrastructureAccount{
{
ID: "1234512345",
Name: "acid",
Provider: "aws",
Type: "aws",
Description: "",
Owner: "acid",
OwnerDn: "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
Disabled: false},
{
ID: "5432154321",
Name: "db",
Provider: "aws",
Type: "aws",
Description: "",
Owner: "acid",
OwnerDn: "cn=100100,ou=official,ou=foobar,dc=zalando,dc=net",
Disabled: false},
},
},
nil}, {
`{"error": "Access Token not valid"}`,
401,
"acid",
nil,
fmt.Errorf(`team API query failed with status code 401 and message: '"Access Token not valid"'`),
},
{
`{"status": "I'm a teapot'"}`,
418,
"acid",
nil,
fmt.Errorf(`team API query failed with status code 418`),
},
{
`{"status": "I'm a teapot`,
418,
"acid",
nil,
fmt.Errorf(`team API query failed with status code 418 and malformed response: unexpected EOF`),
},
{
`{"status": "I'm a teapot`,
200,
"acid",
nil,
fmt.Errorf(`could not parse team API response: unexpected EOF`),
},
{
input,
404,
"banana",
nil,
fmt.Errorf(`team API query failed with status code 404`),
},
}
var requestsURLtc = []struct {
url string
err error
}{
{
"coffee://localhost/",
fmt.Errorf(`Get "coffee://localhost/teams/acid": unsupported protocol scheme "coffee"`),
},
{
"http://192.168.0.%31/",
fmt.Errorf(`parse "http://192.168.0.%%31/teams/acid": invalid URL escape "%%31"`),
},
}
func TestInfo(t *testing.T) {
for _, tc := range teamsAPItc {
func() {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Authorization") != "Bearer "+token {
t.Errorf("authorization token is wrong or not provided")
}
w.WriteHeader(tc.inCode)
if _, err := fmt.Fprint(w, tc.in); err != nil {
t.Errorf("error writing teams api response %v", err)
}
}))
defer ts.Close()
api := NewTeamsAPI(ts.URL, logger)
actual, statusCode, err := api.TeamInfo(tc.inTeam, token)
if err != nil && err.Error() != tc.err.Error() {
t.Errorf("expected error: %v, got: %v", tc.err, err)
return
}
if !reflect.DeepEqual(actual, tc.out) {
t.Errorf("expected %#v, got: %#v", tc.out, actual)
}
if statusCode != tc.inCode {
t.Errorf("expected %d, got: %d", tc.inCode, statusCode)
}
}()
}
}
type mockHTTPClient struct {
}
type mockBody struct {
}
func (b *mockBody) Read(p []byte) (n int, err error) {
return 2, nil
}
func (b *mockBody) Close() error {
return fmt.Errorf("close error")
}
func (c *mockHTTPClient) Do(req *http.Request) (*http.Response, error) {
resp := http.Response{
Status: "200 OK",
StatusCode: 200,
ContentLength: 2,
Close: false,
Request: req,
}
resp.Body = &mockBody{}
return &resp, nil
}
func TestHttpClientClose(t *testing.T) {
ts := httptest.NewServer(nil)
api := NewTeamsAPI(ts.URL, logger)
api.httpClient = &mockHTTPClient{}
_, _, err := api.TeamInfo("acid", token)
expError := fmt.Errorf("error when closing response: close error")
if err.Error() != expError.Error() {
t.Errorf("expected error: %v, got: %v", expError, err)
}
}
func TestRequest(t *testing.T) {
for _, tc := range requestsURLtc {
api := NewTeamsAPI(tc.url, logger)
resp, _, err := api.TeamInfo("acid", token)
if resp != nil {
t.Errorf("response expected to be nil")
continue
}
if err.Error() != tc.err.Error() {
t.Errorf("expected error: %v, got: %v", tc.err, err)
}
}
}
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"reflect"
"github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando/postgres-operator/v2/pkg/spec"
"github.com/zalando/postgres-operator/v2/pkg/util"
"github.com/zalando/postgres-operator/v2/pkg/util/constants"
)
const (
+1 -1
View File
@@ -21,7 +21,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando/postgres-operator/v2/pkg/spec"
"golang.org/x/crypto/pbkdf2"
)
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"regexp"
"github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando/postgres-operator/v2/pkg/spec"
)
var pgUsers = []struct {
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
v1 "k8s.io/api/core/v1"
"github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando/postgres-operator/pkg/util/retryutil"
"github.com/zalando/postgres-operator/v2/pkg/util/constants"
"github.com/zalando/postgres-operator/v2/pkg/util/retryutil"
)
// EBSVolumeResizer implements volume resizing interface for AWS EBS volumes.
+2 -2
View File
@@ -2,9 +2,9 @@ package volumes
import (
"fmt"
"testing"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"
)
func TestGetProviderVolumeID(t *testing.T) {
@@ -88,7 +88,7 @@ func TestVolumeBelongsToProvider(t *testing.T) {
name: "AWS EBS volume handle",
pv: &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string {
Annotations: map[string]string{
"pv.kubernetes.io/provisioned-by": "kubernetes.io/aws-ebs",
},
},