sigs.k8s.io/cluster-api@v1.7.1/controlplane/kubeadm/internal/etcd/fake/client.go (about)

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // Package fake implements testing fakes.
    18  package fake
    19  
    20  import (
    21  	"context"
    22  
    23  	clientv3 "go.etcd.io/etcd/client/v3"
    24  )
    25  
    26  type FakeEtcdClient struct { //nolint:revive
    27  	AlarmResponse        *clientv3.AlarmResponse
    28  	EtcdEndpoints        []string
    29  	MemberListResponse   *clientv3.MemberListResponse
    30  	MemberRemoveResponse *clientv3.MemberRemoveResponse
    31  	MemberUpdateResponse *clientv3.MemberUpdateResponse
    32  	MoveLeaderResponse   *clientv3.MoveLeaderResponse
    33  	StatusResponse       *clientv3.StatusResponse
    34  	ErrorResponse        error
    35  	MovedLeader          uint64
    36  	RemovedMember        uint64
    37  }
    38  
    39  func (c *FakeEtcdClient) Endpoints() []string {
    40  	return c.EtcdEndpoints
    41  }
    42  
    43  func (c *FakeEtcdClient) MoveLeader(_ context.Context, i uint64) (*clientv3.MoveLeaderResponse, error) {
    44  	c.MovedLeader = i
    45  	return c.MoveLeaderResponse, c.ErrorResponse
    46  }
    47  
    48  func (c *FakeEtcdClient) Close() error {
    49  	return nil
    50  }
    51  
    52  func (c *FakeEtcdClient) AlarmList(_ context.Context) (*clientv3.AlarmResponse, error) {
    53  	return c.AlarmResponse, c.ErrorResponse
    54  }
    55  
    56  func (c *FakeEtcdClient) MemberList(_ context.Context) (*clientv3.MemberListResponse, error) {
    57  	return c.MemberListResponse, c.ErrorResponse
    58  }
    59  func (c *FakeEtcdClient) MemberRemove(_ context.Context, i uint64) (*clientv3.MemberRemoveResponse, error) {
    60  	c.RemovedMember = i
    61  	return c.MemberRemoveResponse, c.ErrorResponse
    62  }
    63  func (c *FakeEtcdClient) MemberUpdate(_ context.Context, _ uint64, _ []string) (*clientv3.MemberUpdateResponse, error) {
    64  	return c.MemberUpdateResponse, c.ErrorResponse
    65  }
    66  func (c *FakeEtcdClient) Status(_ context.Context, _ string) (*clientv3.StatusResponse, error) {
    67  	return c.StatusResponse, nil
    68  }