-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLOUDP-266544: Support local credentials for Users (#1812)
* CLOUDP-265544: Support local credentials for Users Signed-off-by: jose.vazquez <[email protected]> * Improve tests * Do not expose reconcile listing * Separate the specific indexer parts away * Remove unused code --------- Signed-off-by: jose.vazquez <[email protected]>
- Loading branch information
Showing
19 changed files
with
630 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package api | ||
|
||
type LocalRef string | ||
|
||
// +k8s:deepcopy-gen=false | ||
|
||
// CredentialsProvider gives access to custom local credentials | ||
type CredentialsProvider interface { | ||
Credentials() *LocalObjectReference | ||
} | ||
|
||
// +k8s:deepcopy-gen=false | ||
|
||
// ResourceWithCredentials is to be implemented by all CRDs using custom local credentials | ||
type ResourceWithCredentials interface { | ||
CredentialsProvider | ||
GetName() string | ||
GetNamespace() string | ||
} | ||
|
||
// LocalCredentialHolder is to be embedded by Specs of CRDs using custom local credentials | ||
type LocalCredentialHolder struct { | ||
ConnectionSecret *LocalObjectReference `json:"connectionSecret,omitempty"` | ||
} | ||
|
||
func (ch *LocalCredentialHolder) Credentials() *LocalObjectReference { | ||
return ch.ConnectionSecret | ||
} |
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,8 @@ | ||
package api | ||
|
||
// LocalObjectReference is a reference to an object in the same namespace as the referent | ||
type LocalObjectReference struct { | ||
// Name of the resource being referred to | ||
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names | ||
Name string `json:"name"` | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package indexer | ||
|
||
import ( | ||
"go.uber.org/zap" | ||
"sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
|
||
akov2 "github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1" | ||
) | ||
|
||
const ( | ||
AtlasDatabaseUserCredentialsIndex = "atlasdatabaseuser.credentials" | ||
) | ||
|
||
func NewAtlasDatabaseUserByCredentialIndexer(logger *zap.Logger) *LocalCredentialIndexer { | ||
return NewLocalCredentialsIndexer(AtlasDatabaseUserCredentialsIndex, &akov2.AtlasDatabaseUser{}, logger) | ||
} | ||
|
||
func DatabaseUserRequests(list *akov2.AtlasDatabaseUserList) []reconcile.Request { | ||
requests := make([]reconcile.Request, 0, len(list.Items)) | ||
for _, item := range list.Items { | ||
requests = append(requests, toRequest(&item)) | ||
} | ||
return requests | ||
} |
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.