Extend clusterctl client interface with GetKubeconfig function
Appropriate function will allow us to retrieve kubeconfig using native function from cluster-api. Change-Id: I5b3c9995c03228245b4a76e7034fba99ac03d9a6 Signed-off-by: Ruslan Aliev <raliev@mirantis.com> Relates-To: #374
This commit is contained in:
parent
19360953b0
commit
569d3c3872
1
go.sum
1
go.sum
@ -850,6 +850,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
|
|||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac h1:8R1esu+8QioDxo4E4mX6bFztO+dMTM49DNAaWfO5OeY=
|
||||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||||
|
@ -30,6 +30,7 @@ var _ Interface = &Client{}
|
|||||||
type Interface interface {
|
type Interface interface {
|
||||||
Init(kubeconfigPath, kubeconfigContext string) error
|
Init(kubeconfigPath, kubeconfigContext string) error
|
||||||
Move(fromKubeconfigPath, fromKubeconfigContext, toKubeconfigPath, toKubeconfigContext, namespace string) error
|
Move(fromKubeconfigPath, fromKubeconfigContext, toKubeconfigPath, toKubeconfigContext, namespace string) error
|
||||||
|
GetKubeconfig(options GetKubeconfigOptions) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client Implements interface to Clusterctl
|
// Client Implements interface to Clusterctl
|
||||||
@ -39,6 +40,19 @@ type Client struct {
|
|||||||
moveOptions clusterctlclient.MoveOptions
|
moveOptions clusterctlclient.MoveOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetKubeconfigOptions carries all the options to retrieve kubeconfig from parent cluster
|
||||||
|
type GetKubeconfigOptions struct {
|
||||||
|
// Path to parent kubeconfig file
|
||||||
|
ParentKubeconfigPath string
|
||||||
|
// Specify context within the kubeconfig file. If empty, cluster client
|
||||||
|
// will use the current context.
|
||||||
|
ParentKubeconfigContext string
|
||||||
|
// Namespace is the namespace in which secret is placed.
|
||||||
|
ManagedClusterNamespace string
|
||||||
|
// ManagedClusterName is the name of the managed cluster.
|
||||||
|
ManagedClusterName string
|
||||||
|
}
|
||||||
|
|
||||||
// NewClient returns instance of clusterctl client
|
// NewClient returns instance of clusterctl client
|
||||||
func NewClient(root string, debug bool, options *airshipv1.Clusterctl) (Interface, error) {
|
func NewClient(root string, debug bool, options *airshipv1.Clusterctl) (Interface, error) {
|
||||||
if debug {
|
if debug {
|
||||||
@ -108,3 +122,15 @@ func newClusterctlClient(root string, options *airshipv1.Clusterctl) (clusterctl
|
|||||||
occf := clusterctlclient.InjectClusterClientFactory(rf.ClusterClientFactory())
|
occf := clusterctlclient.InjectClusterClientFactory(rf.ClusterClientFactory())
|
||||||
return clusterctlclient.New("", ocf, orf, occf)
|
return clusterctlclient.New("", ocf, orf, occf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetKubeconfig is a wrapper for related cluster-api function
|
||||||
|
func (c *Client) GetKubeconfig(options GetKubeconfigOptions) (string, error) {
|
||||||
|
return c.clusterctlClient.GetKubeconfig(clusterctlclient.GetKubeconfigOptions{
|
||||||
|
Kubeconfig: clusterctlclient.Kubeconfig{
|
||||||
|
Path: options.ParentKubeconfigPath,
|
||||||
|
Context: options.ParentKubeconfigContext,
|
||||||
|
},
|
||||||
|
Namespace: options.ManagedClusterNamespace,
|
||||||
|
WorkloadClusterName: options.ManagedClusterName,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user