mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-05 20:26:47 +02:00
This commit modifies the kubernetes operator to use the `tailscale-client-go-v2` package instead of the internal tailscale client it was previously using. This now gives us the ability to expand out custom resources and features as they become available via the API module. The tailnet reconciler has also been modified to manage clients as tailnets are created and removed, providing each subsequent reconciler with a single `ClientProvider` that obtains a tailscale client for the respective tailnet by name, or the operator's default when presented with a blank string. Fixes: https://github.com/tailscale/corp/issues/38418 Signed-off-by: David Bond <davidsbond93@gmail.com>
82 lines
1.4 KiB
Go
82 lines
1.4 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build !plan9
|
|
|
|
package tailnet_test
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"tailscale.com/client/tailscale/v2"
|
|
|
|
"tailscale.com/k8s-operator/tsclient"
|
|
)
|
|
|
|
type (
|
|
MockTailnetClient struct {
|
|
ErrorOnDevices bool
|
|
ErrorOnKeys bool
|
|
ErrorOnServices bool
|
|
}
|
|
|
|
MockDeviceResource struct {
|
|
tsclient.DeviceResource
|
|
|
|
Error bool
|
|
}
|
|
|
|
MockKeyResource struct {
|
|
tsclient.KeyResource
|
|
|
|
Error bool
|
|
}
|
|
|
|
MockVIPServiceResource struct {
|
|
tsclient.VIPServiceResource
|
|
|
|
Error bool
|
|
}
|
|
)
|
|
|
|
func (m MockKeyResource) List(_ context.Context, _ bool) ([]tailscale.Key, error) {
|
|
if m.Error {
|
|
return nil, io.EOF
|
|
}
|
|
|
|
return nil, nil
|
|
}
|
|
|
|
func (m MockDeviceResource) List(_ context.Context, _ ...tailscale.ListDevicesOptions) ([]tailscale.Device, error) {
|
|
if m.Error {
|
|
return nil, io.EOF
|
|
}
|
|
|
|
return nil, nil
|
|
}
|
|
|
|
func (m MockVIPServiceResource) List(_ context.Context) ([]tailscale.VIPService, error) {
|
|
if m.Error {
|
|
return nil, io.EOF
|
|
}
|
|
|
|
return nil, nil
|
|
}
|
|
|
|
func (m MockTailnetClient) Devices() tsclient.DeviceResource {
|
|
return MockDeviceResource{Error: m.ErrorOnDevices}
|
|
}
|
|
|
|
func (m MockTailnetClient) Keys() tsclient.KeyResource {
|
|
return MockKeyResource{Error: m.ErrorOnKeys}
|
|
}
|
|
|
|
func (m MockTailnetClient) VIPServices() tsclient.VIPServiceResource {
|
|
return MockVIPServiceResource{Error: m.ErrorOnServices}
|
|
}
|
|
|
|
func (m MockTailnetClient) LoginURL() string {
|
|
return ""
|
|
}
|