-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ability to seperate port into its own secret
- Loading branch information
Showing
23 changed files
with
1,718 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
pkg/controller/postgresuser/postgresuser_controller_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package postgresuser | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
dbv1alpha1 "github.com/movetokube/postgres-operator/pkg/apis/db/v1alpha1" | ||
) | ||
|
||
func assertEqual(t *testing.T, a interface{}, b interface{}) { | ||
t.Helper() | ||
|
||
if a == b { | ||
return | ||
} | ||
|
||
// debug.PrintStack() | ||
t.Errorf("Received %v (type %v), expected %v (type %v)", a, reflect.TypeOf(a), b, reflect.TypeOf(b)) | ||
} | ||
|
||
func TestReconcilePostgresUser_newSecretForCR(t *testing.T) { | ||
rpu := &ReconcilePostgresUser{ | ||
pgHost: "localhost", | ||
pgPort: 5432, | ||
} | ||
|
||
cr := &dbv1alpha1.PostgresUser{ | ||
Status: dbv1alpha1.PostgresUserStatus{ | ||
DatabaseName: "dbname", | ||
}, | ||
Spec: dbv1alpha1.PostgresUserSpec{ | ||
SecretTemplate: map[string]string{ | ||
"all": "host={{.Host}} host_no_port={{.HostNoPort}} port={{.Port}} user={{.Role}} login={{.Login}} password={{.Password}} dbname={{.Database}}", | ||
}, | ||
}, | ||
} | ||
|
||
secret, err := rpu.newSecretForCR(cr, "role", "password", "login") | ||
if err != nil { | ||
t.Fatalf("could not patch object: (%v)", err) | ||
} | ||
|
||
if secret == nil { | ||
t.Fatalf("no secret returned") | ||
} | ||
|
||
// keep old behavior of merging host and port | ||
assertEqual(t, string(secret.Data["HOST"]), "localhost:5432") | ||
assertEqual(t, string(secret.Data["all"]), "host=localhost:5432 host_no_port=localhost port=5432 user=role login=login password=password dbname=dbname") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.