lordgamez commented on a change in pull request #1270:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1270#discussion_r817453930



##########
File path: docker/test/integration/minifi/core/KindProxy.py
##########
@@ -0,0 +1,112 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import glob
+import os
+import stat
+import subprocess
+import time
+from textwrap import dedent
+
+
+class KindProxy:
+    REPOSITORY = 'minifi-kubernetes-test'
+    TAG = 'v1'
+
+    def __init__(self, temp_directory):
+        self.temp_directory = temp_directory
+        self.kind_binary_path = os.path.join(self.temp_directory, 'kind')
+        self.kind_config_path = os.path.join(self.temp_directory, 
'kind-config.yml')
+        self.__download_kind()
+
+    def __download_kind(self):
+        if subprocess.run(['curl', '-Lo', self.kind_binary_path, 
'https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64']).returncode != 0:
+            raise Exception("Could not download kind")
+        os.chmod(self.kind_binary_path, stat.S_IXUSR)
+
+    def create_config(self, volumes):
+        kind_config = dedent("""\
+                apiVersion: kind.x-k8s.io/v1alpha4
+                kind: Cluster
+                nodes:
+                   - role: control-plane
+                """)
+
+        if volumes:
+            kind_config += "     extraMounts:\n"
+
+        for host_path, container_path in volumes.items():
+            kind_config += "      - hostPath: {path}\n".format(path=host_path)
+            kind_config += "        containerPath: 
{path}\n".format(path=container_path['bind'])
+            if container_path['mode'] != 'rw':
+                kind_config += "        readOnly: true\n"
+
+        with open(self.kind_config_path, 'wb') as config_file:
+            config_file.write(kind_config.encode('utf-8'))
+
+    def start_cluster(self):
+        subprocess.run([self.kind_binary_path, 'delete', 'cluster'])
+
+        if subprocess.run([self.kind_binary_path, 'create', 'cluster', 
'--config=' + self.kind_config_path]).returncode != 0:
+            raise Exception("Could not start the kind cluster")
+
+    def load_docker_image(self, image_store):
+        image_store.get_image('minifi-cpp-in-kubernetes')

Review comment:
       I was thinking about the `'minifi-cpp-in-kubernetes'` as the 
`load_docker_image` in the `KindProxy` class doesn't really suggest that it is 
only used for loading a specific minifi image. Maybe we could reflect this in 
either the class or the method name that this i minifi specific.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to