Provisioning: Configurable Repository Types in monolith and operators (#110822)
* Configurable repository types in monolith and operator * Default to Github in operators * Regenerate wire * Fix and implement unit tests * Same types for enterprise tests * Remove unnecessary conversion * Remove the issue with import cycles
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
authrt "github.com/grafana/grafana/apps/provisioning/pkg/auth"
|
||||
client "github.com/grafana/grafana/apps/provisioning/pkg/generated/clientset/versioned"
|
||||
"github.com/grafana/grafana/apps/provisioning/pkg/repository"
|
||||
"github.com/grafana/grafana/apps/provisioning/pkg/repository/git"
|
||||
"github.com/grafana/grafana/apps/provisioning/pkg/repository/github"
|
||||
"github.com/grafana/grafana/apps/provisioning/pkg/repository/local"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/resources"
|
||||
@@ -64,9 +65,10 @@ type provisioningControllerConfig struct {
|
||||
// tls_key_file =
|
||||
// tls_ca_file =
|
||||
// resync_interval =
|
||||
// repository_types =
|
||||
// home_path =
|
||||
// local_permitted_prefixes =
|
||||
// [provisioning]
|
||||
// repository_types =
|
||||
func setupFromConfig(cfg *setting.Cfg) (controllerCfg *provisioningControllerConfig, err error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("no configuration available")
|
||||
@@ -220,7 +222,11 @@ func setupRepoFactory(
|
||||
provisioningClient *client.Clientset,
|
||||
) (repository.Factory, error) {
|
||||
operatorSec := cfg.SectionWithEnvOverrides("operator")
|
||||
repoTypes := operatorSec.Key("repository_types").Strings("|")
|
||||
provisioningSec := cfg.SectionWithEnvOverrides("provisioning")
|
||||
repoTypes := provisioningSec.Key("repository_types").Strings("|")
|
||||
if len(repoTypes) == 0 {
|
||||
repoTypes = []string{"github"}
|
||||
}
|
||||
|
||||
// TODO: This depends on the different flavor of Grafana
|
||||
// https://github.com/grafana/git-ui-sync-project/issues/495
|
||||
@@ -234,6 +240,8 @@ func setupRepoFactory(
|
||||
alreadyRegistered[provisioning.RepositoryType(t)] = struct{}{}
|
||||
|
||||
switch provisioning.RepositoryType(t) {
|
||||
case provisioning.GitRepositoryType:
|
||||
extras = append(extras, git.Extra(decrypter))
|
||||
case provisioning.GitHubRepositoryType:
|
||||
var webhook *webhooks.WebhookExtraBuilder
|
||||
provisioningAppURL := operatorSec.Key("provisioning_server_public_url").String()
|
||||
@@ -267,7 +275,7 @@ func setupRepoFactory(
|
||||
}
|
||||
}
|
||||
|
||||
repoFactory, err := repository.ProvideFactory(extras)
|
||||
repoFactory, err := repository.ProvideFactory(alreadyRegistered, extras)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("create repository factory: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user