Provisioning: Use inline secrets for gitsync (#109908)
Co-authored-by: Clarity-89 <homes89@ukr.net> Co-authored-by: Roberto Jimenez Sanchez <roberto.jimenez@grafana.com>
This commit is contained in:
co-authored by
Clarity-89
Roberto Jimenez Sanchez
parent
04f392d37b
commit
ce65391067
@@ -89,22 +89,31 @@ func (s *testConnector) Connect(ctx context.Context, name string, opts runtime.O
|
||||
// HACK: Set the name and namespace if not set so that the temporary repository can be created
|
||||
// This can be removed once we deprecate legacy secrets is deprecated or we use InLineSecureValues as we
|
||||
// use the same field and repository name to detect which one to use.
|
||||
if cfg.GetName() == "" {
|
||||
if name == "new" {
|
||||
// HACK: frontend is passing a "new" we need to remove the hack there as well
|
||||
// Otherwise creation will fail as `new` is a reserved word. Not relevant here as we only "test"
|
||||
name = "hack-on-hack-for-new"
|
||||
if name == "new" {
|
||||
// HACK: frontend is passing a "new" we need to remove the hack there as well
|
||||
// Otherwise creation will fail as `new` is a reserved word. Not relevant here as we only "test"
|
||||
name = "hack-on-hack-for-new"
|
||||
} else {
|
||||
// Copy previous secure values if they exist
|
||||
old, _ := s.getter.GetRepository(ctx, name)
|
||||
if old != nil && !old.Config().Secure.IsZero() {
|
||||
secure := old.Config().Secure
|
||||
if cfg.Secure.Token.IsZero() {
|
||||
cfg.Secure.Token = secure.Token
|
||||
}
|
||||
if cfg.Secure.WebhookSecret.IsZero() {
|
||||
cfg.Secure.WebhookSecret = secure.WebhookSecret
|
||||
}
|
||||
}
|
||||
|
||||
cfg.SetName(name)
|
||||
}
|
||||
|
||||
cfg.SetName(name)
|
||||
if cfg.GetNamespace() == "" {
|
||||
cfg.SetNamespace(ns)
|
||||
}
|
||||
|
||||
// Create a temporary repository
|
||||
tmp, err := s.getter.AsRepository(ctx, &cfg)
|
||||
tmp, err := s.getter.RepositoryFromConfig(ctx, &cfg)
|
||||
if err != nil {
|
||||
responder.Error(err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user