-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Description
Kyma CRs are named according to their runtimeId. In many places in our code, we use the Kyma name and therefore runtimeId as identifier. Currently, almost anything in KLM depends somehow on the Kyma name:
- Kyma CRs (obviously)
- SKR clients (getting the right one)
- Manifests belonging to that Kyma
- Certificate + Secret belonging to that Kyma
- kube access secret belongig to that Kyma
- ...
We also often use the Kyma name slightly different, e.g.:
- ClientCache uses client.ObjectKey:
lifecycle-manager/internal/remote/client_cache.go
Lines 27 to 33 in 73dbb30
func (c *ClientCache) Get(key client.ObjectKey) client.Client { cachedClient := c.internal.Get(key) if cachedClient != nil { return cachedClient.Value() } return nil } - we pass the kyma.NamespacedName
- KCP Kyma Repo uses distinct name and namespace strings:
lifecycle-manager/internal/repository/kyma/kyma_repo.go
Lines 22 to 29 in 73dbb30
func (r *Repository) Get(ctx context.Context, kymaName string, kymaNamespace string) (*v1beta2.Kyma, error) { kyma := &v1beta2.Kyma{} err := r.client.Get(ctx, client.ObjectKey{Name: kymaName, Namespace: kymaNamespace}, kyma) if err != nil { return nil, fmt.Errorf("failed to get Kyma %s in namespace %s: %w", kymaName, kymaNamespace, err) } return kyma, nil } - SKR Repos (new) use types.NamespacedName:
lifecycle-manager/internal/repository/skr/kyma/repo.go
Lines 32 to 36 in 4f19a57
func (r *Repository) Exists(ctx context.Context, kymaName types.NamespacedName) (bool, error) { skrClient, err := r.getSkrClient(kymaName) if err != nil { return false, err } - (only needed to get the required SKR client from the cache)
- CertificateService uses it to determine how the related certs and secrets are called:
lifecycle-manager/internal/service/watcher/certificate/certificate_service.go
Lines 88 to 100 in 4f19a57
func (c *Service) DeleteSkrCertificate(ctx context.Context, kymaName string) error { err := c.certRepo.Delete(ctx, name.SkrCertificate(kymaName)) if err != nil { return fmt.Errorf("failed to delete SKR certificate: %w", err) } err = c.secretRepo.Delete(ctx, name.SkrCertificate(kymaName)) if err != nil { return fmt.Errorf("failed to delete SKR certificate secret: %w", err) } return nil }
We should consider to introduce an explicit type for and pass it uniformly to all functionality that somehow depends on this id.
Reasons
This will make it easier for us (and newcomers) to understand what our key identifier is and how we use it.
Acceptance Criteria
- type KymaId defined (or we explicitily use a RuntimeId type?)
- Kyma type provides a method
Id() KymaId - KymaId uniformly passed to all funcs depending on it
Feature Testing
No response
Testing approach
No response
Attachments
No response