mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-11 10:44:41 +00:00
1452faf510
cmd/containerboot,kube,ipn/store/kubestore: allow interactive login and empty state Secrets, check perms * Allow users to pre-create empty state Secrets * Add a fake internal kube client, test functionality that has dependencies on kube client operations. * Fix an issue where interactive login was not allowed in an edge case where state Secret does not exist * Make the CheckSecretPermissions method report whether we have permissions to create/patch a Secret if it's determined that these operations will be needed Updates tailscale/tailscale#11170 Signed-off-by: Irbe Krumina <irbe@tailscale.com>
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Package kube provides a client to interact with Kubernetes.
|
|
// This package is Tailscale-internal and not meant for external consumption.
|
|
// Further, the API should not be considered stable.
|
|
package kube
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
)
|
|
|
|
var _ Client = &FakeClient{}
|
|
|
|
type FakeClient struct {
|
|
GetSecretImpl func(context.Context, string) (*Secret, error)
|
|
CheckSecretPermissionsImpl func(ctx context.Context, name string) (bool, bool, error)
|
|
}
|
|
|
|
func (fc *FakeClient) CheckSecretPermissions(ctx context.Context, name string) (bool, bool, error) {
|
|
return fc.CheckSecretPermissionsImpl(ctx, name)
|
|
}
|
|
func (fc *FakeClient) GetSecret(ctx context.Context, name string) (*Secret, error) {
|
|
return fc.GetSecretImpl(ctx, name)
|
|
}
|
|
func (fc *FakeClient) SetURL(_ string) {}
|
|
func (fc *FakeClient) SetDialer(dialer func(ctx context.Context, network, addr string) (net.Conn, error)) {
|
|
}
|
|
func (fc *FakeClient) StrategicMergePatchSecret(context.Context, string, *Secret, string) error {
|
|
return nil
|
|
}
|
|
func (fc *FakeClient) JSONPatchSecret(context.Context, string, []JSONPatch) error {
|
|
return nil
|
|
}
|
|
func (fc *FakeClient) UpdateSecret(context.Context, *Secret) error { return nil }
|
|
func (fc *FakeClient) CreateSecret(context.Context, *Secret) error { return nil }
|