Skip to content

Commit

Permalink
docs: Update go docs of pkg/controller
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Zhao <[email protected]>
  • Loading branch information
sczyh30 committed Nov 7, 2022
1 parent 91ef7e9 commit e2612c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions pkg/controller/crd_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ type CRDObjectsHolder struct {
version int64
}

// CRDCache caches versioned CRD objects in local.
type CRDCache struct {
kind string
crdEntityMap map[types.NamespacedName]client.Object
kind string
// crdEntityMap represents a map: (namespace, name) -> unique CRD
crdEntityMap map[types.NamespacedName]client.Object
// namespaceAppMap represents a map for CRD group: (namespace, app) -> versionedCRDs
namespaceAppMap map[model.NamespacedApp]*CRDObjectsHolder

updateMux sync.RWMutex
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/crd_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
)

type CRDKind = string

// CRDGenerator represents a generator function of an OpenSergo CRD.
type CRDGenerator = func() client.Object

type CRDMetadata struct {
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/crd_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,25 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

// CRDWatcher reconciles a specific CRD object.
// CRDWatcher watches a specific kind of CRD.
type CRDWatcher struct {
kind model.SubscribeKind

client.Client
logger logr.Logger
scheme *runtime.Scheme

// crdCache represents associated local cache for current kind of CRD.
crdCache *CRDCache

// subscribedList consists of all subscribed target of current kind of CRD.
subscribedList map[model.SubscribeTarget]bool
subscribedNamespaces map[string]bool
subscribedApps map[string]bool

crdGenerator func() client.Object
sendDataHandler model.DataEntirePushHandler

crdCache *CRDCache
updateMux sync.RWMutex
}

Expand Down

0 comments on commit e2612c2

Please sign in to comment.