Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetType for components #237

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/ytsaurus/yt-k8s-operator/pkg/apiproxy"
"github.com/ytsaurus/yt-k8s-operator/pkg/consts"
"github.com/ytsaurus/yt-k8s-operator/pkg/labeller"
)

Expand Down Expand Up @@ -47,6 +48,7 @@ type Component interface {
Sync(ctx context.Context) error
Status(ctx context.Context) (ComponentStatus, error)
GetName() string
GetType() consts.ComponentType
SetReadyCondition(status ComponentStatus)

// TODO(nadya73): refactor it
Expand Down
22 changes: 16 additions & 6 deletions pkg/components/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

"github.com/ytsaurus/yt-k8s-operator/pkg/consts"
mock_yt "github.com/ytsaurus/yt-k8s-operator/pkg/mock"
)

Expand All @@ -31,12 +32,17 @@ var _ = BeforeSuite(func() {
})

type FakeComponent struct {
name string
status ComponentStatus
name string
compType consts.ComponentType
status ComponentStatus
}

func NewFakeComponent(name string) *FakeComponent {
return &FakeComponent{name: name, status: SimpleStatus(SyncStatusReady)}
func NewFakeComponent(name string, compType consts.ComponentType) *FakeComponent {
return &FakeComponent{
name: name,
compType: compType,
status: SimpleStatus(SyncStatusReady),
}
}

func (fc *FakeComponent) IsUpdatable() bool {
Expand All @@ -63,6 +69,10 @@ func (fc *FakeComponent) GetName() string {
return fc.name
}

func (fc *FakeComponent) GetType() consts.ComponentType {
return fc.compType
}

func (fc *FakeComponent) SetReadyCondition(status ComponentStatus) {}

type FakeServer struct {
Expand Down Expand Up @@ -132,7 +142,7 @@ type FakeYtsaurusClient struct {

func NewFakeYtsaurusClient(client *mock_yt.MockClient) *FakeYtsaurusClient {
return &FakeYtsaurusClient{
FakeComponent: *NewFakeComponent("ytsaurus_client"),
FakeComponent: *NewFakeComponent("ytsaurus_client", consts.YtsaurusClientType),
client: client,
}
}
Expand All @@ -145,6 +155,6 @@ func (fyc *FakeYtsaurusClient) SetStatus(status ComponentStatus) {
fyc.status = status
}

func (fc *FakeYtsaurusClient) IsUpdatable() bool {
func (fyc *FakeYtsaurusClient) IsUpdatable() bool {
return false
}
Loading