Skip to content

Commit

Permalink
Merge pull request #600 from mortent/ExtendDelegatingStatusReader
Browse files Browse the repository at this point in the history
Allow easier creation of DelegatedStatusReader with custom status readers
  • Loading branch information
k8s-ci-robot authored Aug 4, 2022
2 parents 89e1603 + f65372b commit 99ba319
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pkg/kstatus/polling/statusreaders/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,27 @@ import (
// statusreaders to cover all built-in Kubernetes resources and other CRDs that
// follow known status conventions.
func NewDefaultStatusReader(mapper meta.RESTMapper) engine.StatusReader {
return NewStatusReader(mapper)
}

// NewStatusReader returns a DelegatingStatusReader that includes the statusreaders
// for the build-in Kubernetes resources and also any provided custom status readers.
func NewStatusReader(mapper meta.RESTMapper, statusReaders ...engine.StatusReader) engine.StatusReader {
defaultStatusReader := NewGenericStatusReader(mapper, status.Compute)

replicaSetStatusReader := NewReplicaSetStatusReader(mapper, defaultStatusReader)
deploymentStatusReader := NewDeploymentResourceReader(mapper, replicaSetStatusReader)
statefulSetStatusReader := NewStatefulSetResourceReader(mapper, defaultStatusReader)

statusReaders = append(statusReaders,
deploymentStatusReader,
statefulSetStatusReader,
replicaSetStatusReader,
defaultStatusReader,
)

return &DelegatingStatusReader{
StatusReaders: []engine.StatusReader{
deploymentStatusReader,
statefulSetStatusReader,
replicaSetStatusReader,
defaultStatusReader,
},
StatusReaders: statusReaders,
}
}

Expand Down

0 comments on commit 99ba319

Please sign in to comment.