Skip to content

Commit

Permalink
rename FleetCluster to KubeConfigSecretRef (#484)
Browse files Browse the repository at this point in the history
* rename FleetCluster to RenderableFleetCluster

Signed-off-by: Xieql <xieqianglong@huawei.com>

* refactor name to KubeConfigsecretRef

Signed-off-by: Xieql <xieqianglong@huawei.com>

---------

Signed-off-by: Xieql <xieqianglong@huawei.com>
  • Loading branch information
Xieql authored Nov 29, 2023
1 parent 524e86b commit 984b852
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/fleet-manager/fleet_plugin_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (f *FleetManager) reconcileBackupPlugin(ctx context.Context, fleet *v1alpha
// Iterating through each fleet cluster to generate and apply Velero helm configurations.
for key, cluster := range fleetClusters {
// generate Velero helm config for each fleet cluster
b, err := plugin.RenderVelero(f.Manifests, fleetNN, fleetOwnerRef, plugin.FleetCluster{
b, err := plugin.RenderVelero(f.Manifests, fleetNN, fleetOwnerRef, plugin.KubeConfigSecretRef{
Name: key.Name,
SecretName: cluster.Secret,
SecretKey: cluster.SecretKey,
Expand Down
4 changes: 2 additions & 2 deletions pkg/fleet-manager/fleet_plugin_distributedstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (f *FleetManager) reconcileDistributedStoragePlugin(ctx context.Context, fl

// First install rook-operator for the specified multicluster.
for key, cluster := range fleetClusters {
b, err := plugin.RendeStorageOperator(f.Manifests, fleetNN, fleetOwnerRef, plugin.FleetCluster{
b, err := plugin.RendeStorageOperator(f.Manifests, fleetNN, fleetOwnerRef, plugin.KubeConfigSecretRef{
Name: key.Name,
SecretName: cluster.Secret,
SecretKey: cluster.SecretKey,
Expand Down Expand Up @@ -75,7 +75,7 @@ func (f *FleetManager) reconcileDistributedStoragePlugin(ctx context.Context, fl
// After Rook operator are created, starts to install rook-ceph
if distributedStorageCfg.Storage != nil {
for key, cluster := range fleetClusters {
b, err := plugin.RenderClusterStorage(f.Manifests, fleetNN, fleetOwnerRef, plugin.FleetCluster{
b, err := plugin.RenderClusterStorage(f.Manifests, fleetNN, fleetOwnerRef, plugin.KubeConfigSecretRef{
Name: key.Name,
SecretName: cluster.Secret,
SecretKey: cluster.SecretKey,
Expand Down
4 changes: 2 additions & 2 deletions pkg/fleet-manager/fleet_plugin_kyverno.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (f *FleetManager) reconcileKyvernoPlugin(ctx context.Context, fleet *fleetv
fleetOwnerRef := ownerReference(fleet)
var resources kube.ResourceList
for key, cluster := range fleetClusters {
b, err := plugin.RenderKyverno(f.Manifests, fleetNN, fleetOwnerRef, plugin.FleetCluster{
b, err := plugin.RenderKyverno(f.Manifests, fleetNN, fleetOwnerRef, plugin.KubeConfigSecretRef{
Name: key.Name,
SecretName: cluster.Secret,
SecretKey: cluster.SecretKey,
Expand Down Expand Up @@ -78,7 +78,7 @@ func (f *FleetManager) reconcileKyvernoPlugin(ctx context.Context, fleet *fleetv
if kyvernoCfg.PodSecurity != nil {
for key, cluster := range fleetClusters {
// generate policies for pod security admission
b, err := plugin.RenderKyvernoPolicy(f.Manifests, fleetNN, fleetOwnerRef, plugin.FleetCluster{
b, err := plugin.RenderKyvernoPolicy(f.Manifests, fleetNN, fleetOwnerRef, plugin.KubeConfigSecretRef{
Name: key.Name,
SecretName: cluster.Secret,
SecretKey: cluster.SecretKey,
Expand Down
2 changes: 1 addition & 1 deletion pkg/fleet-manager/fleet_plugin_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (f *FleetManager) reconcileMetricPlugin(ctx context.Context, fleet *fleetap
return nil, ctrl.Result{}, fmt.Errorf("failed to reconcile objstore secret for cluster %s: %w", c.Name, err)
}

b, err := plugin.RenderPrometheus(f.Manifests, fleetNN, fleetOwnerRef, plugin.FleetCluster{
b, err := plugin.RenderPrometheus(f.Manifests, fleetNN, fleetOwnerRef, plugin.KubeConfigSecretRef{
Name: c.Name,
SecretName: fleetCluster.Secret,
SecretKey: fleetCluster.SecretKey,
Expand Down
12 changes: 6 additions & 6 deletions pkg/fleet-manager/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type GrafanaDataSource struct {
IsDefault bool `json:"isDefault"`
}

func RenderKyvernoPolicy(fsys fs.FS, fleetNN types.NamespacedName, fleetRef *metav1.OwnerReference, cluster FleetCluster, kyvernoCfg *fleetv1a1.KyvernoConfig) ([]byte, error) {
func RenderKyvernoPolicy(fsys fs.FS, fleetNN types.NamespacedName, fleetRef *metav1.OwnerReference, cluster KubeConfigSecretRef, kyvernoCfg *fleetv1a1.KyvernoConfig) ([]byte, error) {
c, err := getFleetPluginChart(fsys, KyvernoPolicyComponentName)
if err != nil {
return nil, err
Expand All @@ -84,7 +84,7 @@ func RenderKyvernoPolicy(fsys fs.FS, fleetNN types.NamespacedName, fleetRef *met
})
}

func RenderKyverno(fsys fs.FS, fleetNN types.NamespacedName, fleetRef *metav1.OwnerReference, cluster FleetCluster, kyvernoCfg *fleetv1a1.KyvernoConfig) ([]byte, error) {
func RenderKyverno(fsys fs.FS, fleetNN types.NamespacedName, fleetRef *metav1.OwnerReference, cluster KubeConfigSecretRef, kyvernoCfg *fleetv1a1.KyvernoConfig) ([]byte, error) {
c, err := getFleetPluginChart(fsys, KyvernoComponentName)
if err != nil {
return nil, err
Expand Down Expand Up @@ -181,7 +181,7 @@ func RenderThanos(fsys fs.FS, fleetNN types.NamespacedName, fleetRef *metav1.Own
return renderFleetPlugin(fsys, thanosCfg)
}

func RenderPrometheus(fsys fs.FS, fleetName types.NamespacedName, fleetRef *metav1.OwnerReference, cluster FleetCluster, metricCfg *fleetv1a1.MetricConfig) ([]byte, error) {
func RenderPrometheus(fsys fs.FS, fleetName types.NamespacedName, fleetRef *metav1.OwnerReference, cluster KubeConfigSecretRef, metricCfg *fleetv1a1.MetricConfig) ([]byte, error) {
promChart, err := getFleetPluginChart(fsys, PrometheusComponentName)
if err != nil {
return nil, err
Expand Down Expand Up @@ -230,7 +230,7 @@ func RenderVelero(
fsys fs.FS,
fleetNN types.NamespacedName,
fleetRef *metav1.OwnerReference,
cluster FleetCluster,
cluster KubeConfigSecretRef,
backupCfg *fleetv1a1.BackupConfig,
veleroSecretName string,
) ([]byte, error) {
Expand Down Expand Up @@ -305,7 +305,7 @@ func RendeStorageOperator(
fsys fs.FS,
fleetNN types.NamespacedName,
fleetRef *metav1.OwnerReference,
cluster FleetCluster,
cluster KubeConfigSecretRef,
distributedStorageCfg *fleetv1a1.DistributedStorageConfig,
) ([]byte, error) {
// get and merge the chart config
Expand Down Expand Up @@ -336,7 +336,7 @@ func RenderClusterStorage(
fsys fs.FS,
fleetNN types.NamespacedName,
fleetRef *metav1.OwnerReference,
cluster FleetCluster,
cluster KubeConfigSecretRef,
distributedStorageCfg *fleetv1a1.DistributedStorageConfig,
) ([]byte, error) {
c, err := getFleetPluginChart(fsys, RookClusterComponentName)
Expand Down
12 changes: 6 additions & 6 deletions pkg/fleet-manager/plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestRenderKyvernoPolicy(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := RenderKyvernoPolicy(manifestFS, tc.fleet, tc.ref, FleetCluster{
got, err := RenderKyvernoPolicy(manifestFS, tc.fleet, tc.ref, KubeConfigSecretRef{
Name: "cluster1",
SecretName: "cluster1",
SecretKey: "kubeconfig.yaml",
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestRenderKyverno(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := RenderKyverno(manifestFS, tc.fleet, tc.ref, FleetCluster{
got, err := RenderKyverno(manifestFS, tc.fleet, tc.ref, KubeConfigSecretRef{
Name: "cluster1",
SecretName: "cluster1",
SecretKey: "kubeconfig.yaml",
Expand Down Expand Up @@ -271,7 +271,7 @@ func TestRenderPrometheus(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := RenderPrometheus(manifestFS, tc.fleet, tc.ref, FleetCluster{
got, err := RenderPrometheus(manifestFS, tc.fleet, tc.ref, KubeConfigSecretRef{
Name: "cluster1",
SecretName: "cluster1",
SecretKey: "kubeconfig.yaml",
Expand Down Expand Up @@ -383,7 +383,7 @@ func TestRenderVelero(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := RenderVelero(manifestFS, tc.fleet, tc.ref, FleetCluster{
got, err := RenderVelero(manifestFS, tc.fleet, tc.ref, KubeConfigSecretRef{
Name: "cluster1",
SecretName: "cluster1",
SecretKey: "kubeconfig.yaml",
Expand Down Expand Up @@ -438,7 +438,7 @@ func TestRenderStorageOperator(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := RendeStorageOperator(manifestFS, tc.fleet, tc.ref, FleetCluster{
got, err := RendeStorageOperator(manifestFS, tc.fleet, tc.ref, KubeConfigSecretRef{
Name: "cluster1",
SecretName: "cluster1",
SecretKey: "kubeconfig.yaml",
Expand Down Expand Up @@ -544,7 +544,7 @@ func TestRenderClusterStorage(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, err := RenderClusterStorage(manifestFS, tc.fleet, tc.ref, FleetCluster{
got, err := RenderClusterStorage(manifestFS, tc.fleet, tc.ref, KubeConfigSecretRef{
Name: "cluster1",
SecretName: "cluster1",
SecretKey: "kubeconfig.yaml",
Expand Down
4 changes: 2 additions & 2 deletions pkg/fleet-manager/plugin/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type FleetPluginConfig struct {
Component string
Fleet types.NamespacedName
OwnerReference *metav1.OwnerReference
Cluster *FleetCluster
Cluster *KubeConfigSecretRef
Chart ChartConfig
Values map[string]interface{}
}
Expand All @@ -55,7 +55,7 @@ func (plugin FleetPluginConfig) StorageNamespace() string {
return plugin.Fleet.Namespace
}

type FleetCluster struct {
type KubeConfigSecretRef struct {
Name string
SecretName string
SecretKey string
Expand Down

0 comments on commit 984b852

Please sign in to comment.