* Move repository package to apps
* Move operators to grafana/grafana
* Go mod tidy
* Own package by git sync team for now
* Merged
* Do not use settings in local extra
* Remove dependency on webhook extra
* Hack to work around issue with secure contracts
* Sync Go modules
* Revert "Move operators to grafana/grafana"
This reverts commit 9f19b30a2e.
33 lines
688 B
Go
33 lines
688 B
Go
package github
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
|
|
provisioning "github.com/grafana/grafana/apps/provisioning/pkg/apis/provisioning/v0alpha1"
|
|
)
|
|
|
|
func Mutate(ctx context.Context, obj runtime.Object) error {
|
|
repo, ok := obj.(*provisioning.Repository)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
if repo.Spec.GitHub == nil {
|
|
return nil
|
|
}
|
|
|
|
// Trim trailing ".git" and any trailing slash from the GitHub URL, if present, using the strings package.
|
|
if repo.Spec.GitHub.URL != "" {
|
|
url := repo.Spec.GitHub.URL
|
|
url = strings.TrimRight(url, "/")
|
|
url = strings.TrimSuffix(url, ".git")
|
|
url = strings.TrimRight(url, "/")
|
|
repo.Spec.GitHub.URL = url
|
|
}
|
|
|
|
return nil
|
|
}
|