hieunguyen30 commented on code in PR #518: URL: https://github.com/apache/airavata-custos/pull/518#discussion_r4464527625
########## connectors/LDAP/Provisioner/internal/subscribers/cluster_user.go: ########## @@ -0,0 +1,101 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Package subscribers wires ComputeClusterUserCreateEvent to the LDAP +// orchestrator. Parallels the COmanage connector's subscriber; a +// deployment picks one or the other depending on whether it fronts LDAP +// with COmanage. +package subscribers + +import ( + "context" + "log/slog" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + + "github.com/apache/airavata-custos/connectors/LDAP/Provisioner/internal/client" + "github.com/apache/airavata-custos/connectors/LDAP/Provisioner/internal/operations" + "github.com/apache/airavata-custos/internal/audit" + "github.com/apache/airavata-custos/internal/tracing" + "github.com/apache/airavata-custos/pkg/events" + "github.com/apache/airavata-custos/pkg/models" + "github.com/apache/airavata-custos/pkg/service" +) + +// ClusterUserSubscriber listens for ComputeClusterUserCreateEvent and +// drives the orchestrator. Events whose ComputeClusterID does not match +// CustosClusterID are dropped — a deployment servicing multiple clusters +// runs one subscriber instance per cluster. +type ClusterUserSubscriber struct { + ops *operations.Orchestrator + bus *events.Bus + core *service.Service + custosClusterID string +} + +func NewClusterUserSubscriber(c *client.Client, uids operations.UIDAllocator, bus *events.Bus, core *service.Service, custosClusterID string) *ClusterUserSubscriber { + return &ClusterUserSubscriber{ + ops: operations.New(c, core, uids), + bus: bus, + core: core, + custosClusterID: custosClusterID, + } +} + +func (s *ClusterUserSubscriber) RegisterSubscribers() { + s.bus.Subscribe(events.ComputeClusterUserCreateEvent, s.handleClusterUserCreate) Review Comment: The connector now listens for the deleted event as well. It removes the entry (and the group if its gid matches) and marks the row INACTIVE, so the uid is not reused. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
