Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinash Patnala committed Sep 25, 2024
1 parent d7d2405 commit dabdc7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions apis/status/v1beta1/configpodstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ func NewConfigStatusForPod(pod *corev1.Pod, configNamespace string, configName s

// KeyForConfig returns a unique status object name given the Pod ID and
// a config object.
// The object name must satisfy RFC 1123 Label Names spec
// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/)
// and Kubernetes validation rules for object names.
//
// It's possible that dash packing/unpacking would result in a name
// that exceeds the maximum length allowed, but for Config resources,
// the configName should always be "config", and namespace would be "gatekeeper-system",
// so this validation will hold.
func KeyForConfig(id string, configNamespace string, configName string) (string, error) {
return DashPacker(id, configNamespace, configName)
}
2 changes: 1 addition & 1 deletion pkg/controller/config/config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (r *ReconcileConfig) Reconcile(ctx context.Context, request reconcile.Reque
if deleted {
return reconcile.Result{}, r.deleteStatus(ctx, request.NamespacedName.Namespace, request.NamespacedName.Name)
}
return reconcile.Result{}, r.updateOrCreatePodStatus(ctx, instance, err)
return reconcile.Result{}, r.updateOrCreatePodStatus(ctx, instance, nil)
}

func (r *ReconcileConfig) deleteStatus(ctx context.Context, cfgNamespace string, cfgName string) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/configstatus/configstatus_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func PodStatusToConfigMapper(selfOnly bool) handler.TypedMapFunc[*v1beta1.Config
// Add creates a new config status Controller and adds it to the Manager. The Manager will set fields on the Controller
// and Start it when the Manager is Started.
func add(mgr manager.Manager, r reconcile.Reconciler) error {
// Create a new controller
c, err := controller.New("config-status-controller", mgr, controller.Options{Reconciler: r})
if err != nil {
return err
Expand All @@ -125,7 +124,8 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {

var _ reconcile.Reconciler = &ReconcileConfigStatus{}

// ReconcileConfigStatus reconciles an arbitrary config object described by Kind.
// ReconcileConfigStatus provides the dependencies required to reconcile
// the status of a Config resource.
type ReconcileConfigStatus struct {
reader client.Reader
writer client.Writer
Expand Down

0 comments on commit dabdc7b

Please sign in to comment.