Skip to content

Commit

Permalink
feat(tenant): add label with tenant name for each tenant
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
  • Loading branch information
oliverbaehler committed Nov 25, 2023
1 parent 52aa837 commit 1a6d7f8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v1beta2/owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
PriorityClassesProxy ProxyServiceKind = "PriorityClasses"
RuntimeClassesProxy ProxyServiceKind = "RuntimeClasses"
PersistentVolumesProxy ProxyServiceKind = "PersistentVolumes"
TenantProxy ProxyServiceKind = "Tenant"

ListOperation ProxyOperation = "List"
UpdateOperation ProxyOperation = "Update"
Expand Down
7 changes: 7 additions & 0 deletions controllers/tenant/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ func (r Manager) Reconcile(ctx context.Context, request ctrl.Request) (result ct

return
}
// Ensuring Metadata
if err = r.ensureMetadata(ctx, instance); err != nil {
r.Log.Error(err, "Cannot ensure metadata")

return
}

// Ensuring ResourceQuota
r.Log.Info("Ensuring limit resources count is updated")

Expand Down
23 changes: 23 additions & 0 deletions controllers/tenant/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2020-2023 Project Capsule Authors.
// SPDX-License-Identifier: Apache-2.0

package tenant

import (
"context"

capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
)

const (
TenantNameLabel = "kubernetes.io/metadata.name"
)

// Sets a label on the Tenant object with it's name

Check failure on line 16 in controllers/tenant/metadata.go

View workflow job for this annotation

GitHub Actions / lint

Comment should end in a period (godot)
func (r *Manager) ensureMetadata(ctx context.Context, tnt *capsulev1beta2.Tenant) (err error) {
tnt.SetLabels(map[string]string{
TenantNameLabel: tnt.Name,
})

return r.Client.Update(ctx, tnt)
}

0 comments on commit 1a6d7f8

Please sign in to comment.