Skip to content

Commit fd12c33

Browse files
authored
fix: dynamically detect value (#42)
1 parent 007b1a9 commit fd12c33

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

pkg/config/config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import (
1313
)
1414

1515
type ServiceConfig struct {
16-
ProviderWorkspaceID string `mapstructure:"provider-workspace-id" default:"2pkfvpweuy7symvj"`
17-
Kubeconfig string `mapstructure:"kubeconfig"`
18-
ServerURL string `mapstructure:"server-url"`
19-
EntityLabel string `mapstructure:"entity-label" default:"ui.platform-mesh.ui/entity"`
20-
ContentForLabel string `mapstructure:"content-for-label" default:"ui.platform-mesh.io/content-for"`
16+
Kubeconfig string `mapstructure:"kubeconfig"`
17+
ServerURL string `mapstructure:"server-url"`
18+
EntityLabel string `mapstructure:"entity-label" default:"ui.platform-mesh.ui/entity"`
19+
ContentForLabel string `mapstructure:"content-for-label" default:"ui.platform-mesh.io/content-for"`
2120

2221
ResourceSchemaName string `mapstructure:"resource-schema-name" default:"v250704-6d57f16.contentconfigurations.ui.platform-mesh.io"`
2322
ResourceSchemaWorkspace string `mapstructure:"resource-schema-workspace" default:"root:openmfp-system"`

pkg/contentconfiguration/server.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ func BuildVirtualWorkspace(
7575
return nil, err
7676
}
7777

78+
providerWSCluster, err := clusterResolver(ctx, logicalcluster.NewPath(cfg.ResourceSchemaWorkspace))
79+
if err != nil {
80+
return nil, err
81+
}
82+
7883
storeageProvider := storage.CreateStorageProviderFunc(
7984
dynamicClient,
80-
storage.ContentConfigurationLookup(dynamicClient, cfg),
85+
storage.ContentConfigurationLookup(dynamicClient, cfg, providerWSCluster.Name.String()),
8186
)
8287

8388
gvr := schema.GroupVersionResource{

pkg/storage/filter.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ func ClusterPathFrom(ctx context.Context) (logicalcluster.Path, bool) {
4242
return path, true
4343
}
4444

45-
func ContentConfigurationLookup(client dynamic.ClusterInterface, cfg config.ServiceConfig) forwardingregistry.StorageWrapper {
45+
func ContentConfigurationLookup(client dynamic.ClusterInterface, cfg config.ServiceConfig, providerWorkspaceID string) forwardingregistry.StorageWrapper {
46+
4647
return forwardingregistry.StorageWrapperFunc(func(resource schema.GroupResource, storage *forwardingregistry.StoreFuncs) {
4748
delegateLister := storage.ListerFunc
4849
storage.ListerFunc = func(ctx context.Context, options *internalversion.ListOptions) (runtime.Object, error) {
@@ -117,7 +118,7 @@ func ContentConfigurationLookup(client dynamic.ClusterInterface, cfg config.Serv
117118
}
118119

119120
providerCtx := genericapirequest.WithCluster(ctx, genericapirequest.Cluster{
120-
Name: logicalcluster.Name(cfg.ProviderWorkspaceID),
121+
Name: logicalcluster.Name(providerWorkspaceID),
121122
})
122123

123124
providerOpts := options.DeepCopy()

0 commit comments

Comments
 (0)