POC/Provisioning: Minor cleanups (#98089)
This commit is contained in:
1 parent
87808c0868
commit
bb20d128f0
6 files changed
+29
-13
No files matched your search
@@ -177,7 +177,7 @@ func (rc *RepositoryController) sync(key string) error {
|
||||
|
||||
// The repository is deleted
|
||||
if cachedRepo.DeletionTimestamp != nil {
|
||||
return rc.processDeletedItem(context.Background(), cachedRepo)
|
||||
return nil //rc.processDeletedItem(context.Background(), cachedRepo)
|
||||
}
|
||||
|
||||
// Did the spec change
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer/yaml"
|
||||
yamlutil "k8s.io/apimachinery/pkg/util/yaml"
|
||||
|
||||
"github.com/grafana/grafana/pkg/apis/dashboard"
|
||||
dashboard "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1"
|
||||
provisioning "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/repository"
|
||||
)
|
||||
@@ -63,7 +63,7 @@ func ReadClassicResource(ctx context.Context, logger *slog.Logger, info *reposit
|
||||
value["tags"] != nil {
|
||||
gvk := &schema.GroupVersionKind{
|
||||
Group: dashboard.GROUP,
|
||||
Version: "v0alpha1",
|
||||
Version: dashboard.VERSION, // v1
|
||||
Kind: "Dashboard"}
|
||||
return &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
|
||||
@@ -55,8 +55,8 @@ func NamesFromHashedRepoPath(repo string, fpath string, _ metav1.Object) (object
|
||||
|
||||
hasher := func(fpath string) string {
|
||||
name := path.Base(fpath)
|
||||
if len(name) > 12 {
|
||||
name = name[0:12]
|
||||
if len(name) > 16 {
|
||||
name = name[0:16]
|
||||
}
|
||||
hash := sha256.New()
|
||||
_, _ = hash.Write([]byte(repo))
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
dashboard "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1"
|
||||
provisioning "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/provisioning/repository/github"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
@@ -87,7 +88,7 @@ func TestIntegrationProvisioning(t *testing.T) {
|
||||
User: helper.Org1.Admin,
|
||||
Namespace: "default", // actually org1
|
||||
GVR: schema.GroupVersionResource{
|
||||
Group: "dashboard.grafana.app", Version: "v2alpha1", Resource: "dashboards",
|
||||
Group: dashboard.GROUP, Version: dashboard.VERSION, Resource: "dashboards",
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { css } from '@emotion/css';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { Card, EmptySearchResult, EmptyState, FilterInput, LinkButton, Stack, TextLink } from '@grafana/ui';
|
||||
import { Alert, Card, EmptySearchResult, EmptyState, FilterInput, LinkButton, Stack, TextLink } from '@grafana/ui';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
|
||||
import { DeleteRepositoryButton } from './DeleteRepositoryButton';
|
||||
@@ -51,6 +51,7 @@ function RepositoryListPageContent({ items }: { items?: Repository[] }) {
|
||||
{!!filteredItems.length ? (
|
||||
filteredItems.map((item) => {
|
||||
const name = item.metadata?.name ?? '';
|
||||
const healthy = Boolean(item.status?.health.healthy)
|
||||
return (
|
||||
<Card key={item.metadata?.name} className={css({ alignItems: 'center' })}>
|
||||
<Stack direction={'column'}>
|
||||
@@ -60,11 +61,25 @@ function RepositoryListPageContent({ items }: { items?: Repository[] }) {
|
||||
<Card.Meta>{item.spec?.type}</Card.Meta>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<LinkButton variant="secondary" href={`${PROVISIONING_URL}/${name}/edit`}>
|
||||
Edit
|
||||
</LinkButton>
|
||||
<SyncRepository repository={item} />
|
||||
<DeleteRepositoryButton name={name} />
|
||||
{healthy ? <>
|
||||
<LinkButton variant="secondary" href={`${PROVISIONING_URL}/${name}/edit`}>
|
||||
Edit
|
||||
</LinkButton>
|
||||
<SyncRepository repository={item} />
|
||||
<DeleteRepositoryButton name={name} />
|
||||
</> : <>
|
||||
<Alert title='Repository is unhealthy'>
|
||||
<>
|
||||
{item.status?.health.message && item.status.health.message.map(v => <div>{v}<br/><br/></div>)}
|
||||
<div>
|
||||
<LinkButton variant="secondary" href={`${PROVISIONING_URL}/${name}/edit`}>
|
||||
Edit
|
||||
</LinkButton>
|
||||
<DeleteRepositoryButton name={name} />
|
||||
</div>
|
||||
</>
|
||||
</Alert>
|
||||
</>}
|
||||
</Stack>
|
||||
</Card>
|
||||
);
|
||||
|
||||
@@ -255,7 +255,7 @@ function FolderView({ repo }: RepoProps) {
|
||||
<div>
|
||||
<h2>TODO, show folder: {repo.metadata?.name}</h2>
|
||||
<br />
|
||||
<a href={`/dashboards/f/${repo.spec?.folder} /`}>{repo.spec?.folder} </a>
|
||||
<a href={`/dashboards/f/${repo.spec?.folder}/`}>{repo.spec?.folder} </a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user