Skip to content

Commit 03704fe

Browse files
committed
Update plugin kubeconfig handling
Removed the return of the kubeconfig filepath from the `create_cluster` method as we do not use this handling. Signed-off-by: Toni Finger <toni.finger@cloudandheat.com>
1 parent 733f0c7 commit 03704fe

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

Tests/kaas/plugin/interface.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class KubernetesClusterPlugin():
88
99
To implement fill the methods `create_cluster` and `delete_cluster` with
1010
api provider-specific functionalities for creating and deleting clusters.
11+
The `create_cluster` method must ensure that the kubeconfigfile is provided
12+
at the position in the file system defined by the parameter
13+
`kubeconfig_filepath`
1114
1215
- Implement `create_cluster` and `delete_cluster` methods
1316
- Create `__init__(self, config_file=None)` method to handle api specific
@@ -24,31 +27,29 @@ class PluginX(KubernetesClusterPlugin):
2427
def __init__(self, config_file=None):
2528
self.config = config_file
2629
27-
def create_cluster(self):
28-
self.cluster = ClusterAPI(name=cluster_name, image=cluster_image)
30+
def create_cluster(self, cluster_name="scs-cluster", version=None, kubeconfig_filepath=None):
31+
self.cluster = ClusterAPI(name=cluster_name, image=cluster_image, kubeconfig_filepath)
2932
self.cluster.create(self.config)
30-
kubeconfig_filepath = str(self.cluster.kubeconfig_path.resolve())
31-
return self.kubeconfig_filepath
3233
33-
def delete_cluster(self):
34+
def delete_cluster(self, cluster_name=None, version=None):
3435
self.cluster = ClusterAPI(cluster_name)
3536
self.cluster.delete()
3637
..
3738
"""
3839

39-
def create_cluster(self, cluster_name="scs-cluster", version=None, kubeconfig_filepath=None) -> (str):
40+
def create_cluster(self, cluster_name="scs-cluster", version=None, kubeconfig_filepath=None):
4041
"""
4142
This method is to be called to create a k8s cluster
4243
:param: cluster_name:
4344
:param: version:
4445
:param: kubeconfig_filepath:
45-
:return: kubeconfig_filepath
4646
"""
4747
raise NotImplementedError
4848

49-
def delete_cluster(self, cluster_name=None):
49+
def delete_cluster(self, cluster_name=None, version=None):
5050
"""
5151
This method is to be called in order to unprovision a cluster
5252
:param: cluster_name:
53+
:param: version:
5354
"""
5455
raise NotImplementedError

Tests/kaas/plugin/plugin_kind.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PluginKind(KubernetesClusterPlugin):
1515
conformance testing purpose with the use of Kind
1616
"""
1717
def __init__(self, config_file=None):
18-
logger.info(f"Init provider plug-in of type {self.__class__.__name__}")
18+
logger.info(f"Init PluginKind")
1919
self.config = config_file
2020
logger.debug(self.config)
2121
self.working_directory = os.getcwd()
@@ -44,8 +44,7 @@ def create_cluster(self, cluster_name="scs-cluster", version=None, kubeconfig=No
4444
self.cluster.create()
4545
else:
4646
self.cluster.create(self.config)
47-
return str(self.cluster.kubeconfig_path.resolve())
4847

49-
def delete_cluster(self, cluster_name=None):
48+
def delete_cluster(self, cluster_name=None, version=None):
5049
self.cluster = KindCluster(cluster_name)
5150
self.cluster.delete()

Tests/kaas/plugin/run_plugin.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ def init_plugin(plugin_kind, config=None):
2121
return plugin_maker(config)
2222

2323

24-
def run_plugin_create(plugin_kind, plugin_config, clusterspec_cluster, clusterspec):
25-
plugin = init_plugin(plugin_kind, plugin_config)
26-
clusterinfo = clusterspec[clusterspec_cluster]
27-
plugin.create_cluster(clusterspec_cluster, clusterinfo['branch'], os.path.abspath(clusterinfo['kubeconfig']))
28-
29-
30-
def run_plugin_delete(plugin_kind, plugin_config, clusterspec_cluster, clusterspec):
31-
plugin = init_plugin(plugin_kind, plugin_config)
32-
plugin.delete_cluster(clusterspec_cluster)
33-
34-
3524
def load_spec(clusterspec_path):
3625
with open(clusterspec_path, "rb") as fileobj:
3726
return yaml.load(fileobj, Loader=yaml.SafeLoader)
@@ -49,7 +38,10 @@ def cli():
4938
@click.argument('clusterspec_cluster', type=str, default="default")
5039
def create(plugin_kind, plugin_config, clusterspec_path, clusterspec_cluster):
5140
clusterspec = load_spec(clusterspec_path)['clusters']
52-
run_plugin_create(plugin_kind, plugin_config, clusterspec_cluster, clusterspec)
41+
plugin = init_plugin(plugin_kind, plugin_config)
42+
clusterinfo = clusterspec[clusterspec_cluster]
43+
cluster_id = clusterspec_cluster
44+
plugin.create_cluster(cluster_id, clusterinfo['branch'], os.path.abspath(clusterinfo['kubeconfig']))
5345

5446

5547
@cli.command()
@@ -59,7 +51,10 @@ def create(plugin_kind, plugin_config, clusterspec_path, clusterspec_cluster):
5951
@click.argument('clusterspec_cluster', type=str, default="default")
6052
def delete(plugin_kind, plugin_config, clusterspec_path, clusterspec_cluster):
6153
clusterspec = load_spec(clusterspec_path)['clusters']
62-
run_plugin_delete(plugin_kind, plugin_config, clusterspec_cluster, clusterspec)
54+
clusterinfo = clusterspec[clusterspec_cluster]
55+
cluster_id = clusterspec_cluster
56+
plugin = init_plugin(plugin_kind, plugin_config)
57+
plugin.delete_cluster(cluster_id, clusterinfo['branch'])
6358

6459

6560
if __name__ == '__main__':

0 commit comments

Comments
 (0)