-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for a chunked release storage driver (#350)
This commit adds a custom helm release storage driver that overcomes limitations in the size of a single value that can be stored in etcd. In order to remain backward-compatible and also make this storage driver available, this commit also refactors the ActionConfigGetter options so that a custom function can be provided to the ActionConfigGetter that can create the desired storage driver. This commit also separates the rest config mapping into two separate options. One for interactions with the storage backend, and the other for managing release content. Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
- Loading branch information
1 parent
d6fdc05
commit 2e18c5b
Showing
7 changed files
with
1,043 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
clientcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" | ||
) | ||
|
||
var _ clientcorev1.SecretInterface = &ownerRefSecretClient{} | ||
|
||
// NewOwnerRefSecretClient returns a SecretInterface that injects the provided owner references | ||
// to all created or updated secrets that match the provided match function. If match is nil, all | ||
// secrets are matched. | ||
func NewOwnerRefSecretClient(client clientcorev1.SecretInterface, refs []metav1.OwnerReference, match func(*corev1.Secret) bool) clientcorev1.SecretInterface { | ||
if match == nil { | ||
match = MatchAllSecrets | ||
} | ||
return &ownerRefSecretClient{ | ||
SecretInterface: client, | ||
match: match, | ||
refs: refs, | ||
} | ||
} | ||
|
||
func MatchAllSecrets(_ *corev1.Secret) bool { | ||
return true | ||
} | ||
|
||
type ownerRefSecretClient struct { | ||
clientcorev1.SecretInterface | ||
match func(secret *corev1.Secret) bool | ||
refs []metav1.OwnerReference | ||
} | ||
|
||
func (c *ownerRefSecretClient) appendMissingOwnerRefs(secret *corev1.Secret) { | ||
hasOwnerRef := func(secret *corev1.Secret, ref metav1.OwnerReference) bool { | ||
for _, r := range secret.OwnerReferences { | ||
if r.UID == ref.UID { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
for i := range c.refs { | ||
if !hasOwnerRef(secret, c.refs[i]) { | ||
secret.OwnerReferences = append(secret.OwnerReferences, c.refs[i]) | ||
} | ||
} | ||
} | ||
|
||
func (c *ownerRefSecretClient) Create(ctx context.Context, in *corev1.Secret, opts metav1.CreateOptions) (*corev1.Secret, error) { | ||
if c.match == nil || c.match(in) { | ||
c.appendMissingOwnerRefs(in) | ||
} | ||
return c.SecretInterface.Create(ctx, in, opts) | ||
} | ||
|
||
func (c *ownerRefSecretClient) Update(ctx context.Context, in *corev1.Secret, opts metav1.UpdateOptions) (*corev1.Secret, error) { | ||
if c.match == nil || c.match(in) { | ||
c.appendMissingOwnerRefs(in) | ||
} | ||
return c.SecretInterface.Update(ctx, in, opts) | ||
} |
Oops, something went wrong.