-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from sabaini/feature/remove-node
Implement node removal
- Loading branch information
Showing
7 changed files
with
491 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"github.com/canonical/microceph/microceph/api/types" | ||
|
||
microCli "github.com/canonical/microcluster/client" | ||
) | ||
|
||
// ClientInterface wraps client functions | ||
// This is useful for mocking in unit tests | ||
type ClientInterface interface { | ||
GetClusterMembers(*microCli.Client) ([]string, error) | ||
GetDisks(*microCli.Client) (types.Disks, error) | ||
GetServices(*microCli.Client) (types.Services, error) | ||
DeleteService(*microCli.Client, string, string) error | ||
DeleteClusterMember(*microCli.Client, string, bool) error | ||
} | ||
|
||
type ClientImpl struct{} | ||
|
||
// GetClusterMembers gets the cluster member names | ||
// We return names only here because the Member type is internal to microclient | ||
func (c ClientImpl) GetClusterMembers(cli *microCli.Client) ([]string, error) { | ||
memberNames := make([]string, 3) | ||
members, err := cli.GetClusterMembers(context.Background()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, member := range members { | ||
memberNames = append(memberNames, member.Name) | ||
} | ||
|
||
return memberNames, nil | ||
} | ||
|
||
// GetDisks wraps the GetDisks function above | ||
func (c ClientImpl) GetDisks(cli *microCli.Client) (types.Disks, error) { | ||
return GetDisks(context.Background(), cli) | ||
} | ||
|
||
// GetServices wraps the GetServices function above | ||
func (c ClientImpl) GetServices(cli *microCli.Client) (types.Services, error) { | ||
return GetServices(context.Background(), cli) | ||
} | ||
|
||
// DeleteService wraps the DeleteService function | ||
func (c ClientImpl) DeleteService(cli *microCli.Client, target string, service string) error { | ||
return DeleteService(context.Background(), cli, target, service) | ||
} | ||
|
||
// DeleteClusterMember wraps the DeleteClusterMember function | ||
func (c ClientImpl) DeleteClusterMember(cli *microCli.Client, name string, force bool) error { | ||
return cli.DeleteClusterMember(context.Background(), name, force) | ||
} | ||
|
||
// mocking point for unit tests | ||
var MClient ClientInterface = ClientImpl{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.