Skip to content

Commit f768597

Browse files
committed
fix: Casing
1 parent 896a7d9 commit f768597

1 file changed

Lines changed: 32 additions & 30 deletions

File tree

cloudquery/sdk/serve/plugin.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ def _package(self, args):
234234
Path(dist_dir).mkdir(0o755, exist_ok=True, parents=True)
235235

236236
self._copy_docs(logger, docs_dir, dist_dir)
237-
self._writeTablesJSON(logger, dist_dir)
238-
supportedTargets = self._buildDockerFile(
237+
self._write_tables_json(logger, dist_dir)
238+
supported_targets = self._build_dockerfile(
239239
logger, plugin_directory, dist_dir, version
240240
)
241-
self._write_package_json(logger, dist_dir, message, version, supportedTargets)
241+
self._write_package_json(logger, dist_dir, message, version, supported_targets)
242242
logger.info("Done packaging plugin to '%s'" % dist_dir)
243243

244244
def _write_package_json(self, logger, dist_dir, message, version, supportedTargets):
245-
packageJsonPath = "%s/package.json" % dist_dir
246-
logger.info("Writing package.json to '%s'" % packageJsonPath)
245+
package_json_path = "%s/package.json" % dist_dir
246+
logger.info("Writing package.json to '%s'" % package_json_path)
247247
content = {
248248
"schema_version": 1,
249249
"name": self._plugin.name(),
@@ -267,7 +267,7 @@ def _copy_docs(self, logger, docs_dir, dist_dir):
267267
logger.info("Copying docs from '%s' to '%s'" % (docs_dir, output_docs_dir))
268268
shutil.copytree(docs_dir, output_docs_dir, dirs_exist_ok=True)
269269

270-
def _writeTablesJSON(self, logger, dist_dir):
270+
def _write_tables_json(self, logger, dist_dir):
271271
if self._plugin.kind() != "source":
272272
return
273273

@@ -310,10 +310,10 @@ def table_to_json(table: table.Table):
310310
"Wrote %d tables to '%s'" % (len(tables_json), tables_json_output_path)
311311
)
312312

313-
def _buildDockerFile(self, logger, plugin_dir, dist_dir, version):
314-
dockerFilePath = "%s/%s" % (plugin_dir, self._plugin.dockerfile())
315-
if not os.path.isfile(dockerFilePath):
316-
raise Exception("Dockerfile '%s' does not exist" % dockerFilePath)
313+
def _build_dockerfile(self, logger, plugin_dir, dist_dir, version):
314+
dockerfile_path = "%s/%s" % (plugin_dir, self._plugin.dockerfile())
315+
if not os.path.isfile(dockerfile_path):
316+
raise Exception("Dockerfile '%s' does not exist" % dockerfile_path)
317317

318318
def run_docker_cmd(cmd, plugin_dir):
319319
result = subprocess.run(cmd, capture_output=True, cwd=plugin_dir)
@@ -326,57 +326,59 @@ def run_docker_cmd(cmd, plugin_dir):
326326
raise ChildProcessError("Unable to run Docker command: %s" % err)
327327

328328
def build_target(target: plugin.plugin.BuildTarget):
329-
imageRepository = "registry.cloudquery.io/%s/%s-%s" % (
329+
image_repository = "registry.cloudquery.io/%s/%s-%s" % (
330330
self._plugin.team(),
331331
self._plugin.kind(),
332332
self._plugin.name(),
333333
)
334-
imageTag = "%s:%s-%s-%s" % (
335-
imageRepository,
334+
image_tag = "%s:%s-%s-%s" % (
335+
image_repository,
336336
version,
337337
target.os,
338338
target.arch,
339339
)
340-
imageTar = "plugin-%s-%s-%s-%s.tar" % (
340+
image_tar = "plugin-%s-%s-%s-%s.tar" % (
341341
self._plugin.name(),
342342
version,
343343
target.os,
344344
target.arch,
345345
)
346-
imagePath = "%s/%s" % (dist_dir, imageTar)
347-
logger.info("Building docker image %s" % imageTag)
348-
dockerBuildArguments = [
346+
image_path = "%s/%s" % (dist_dir, image_tar)
347+
logger.info("Building docker image %s" % image_tag)
348+
docker_build_arguments = [
349349
"docker",
350350
"buildx",
351351
"build",
352352
"-t",
353-
imageTag,
353+
image_tag,
354354
"--platform",
355355
"%s/%s" % (target.os, target.arch),
356356
"-f",
357-
dockerFilePath,
357+
dockerfile_path,
358358
".",
359359
"--progress",
360360
"plain",
361361
"--load",
362362
]
363-
logger.debug("Running command 'docker %s'" % " ".join(dockerBuildArguments))
364-
run_docker_cmd(dockerBuildArguments, plugin_dir)
365-
logger.debug("Saving docker image '%s' to '%s'" % (imageTag, imagePath))
366-
dockerSaveArguments = ["docker", "save", "-o", imagePath, imageTag]
367-
logger.debug("Running command 'docker %s'", " ".join(dockerSaveArguments))
368-
run_docker_cmd(dockerSaveArguments, plugin_dir)
363+
logger.debug(
364+
"Running command 'docker %s'" % " ".join(docker_build_arguments)
365+
)
366+
run_docker_cmd(docker_build_arguments, plugin_dir)
367+
logger.debug("Saving docker image '%s' to '%s'" % (image_tag, image_path))
368+
docker_save_arguments = ["docker", "save", "-o", image_path, image_tag]
369+
logger.debug("Running command 'docker %s'", " ".join(docker_save_arguments))
370+
run_docker_cmd(docker_save_arguments, plugin_dir)
369371
return {
370372
"os": target.os,
371373
"arch": target.arch,
372-
"path": imageTar,
373-
"checksum": calc_sha256_checksum(imagePath),
374-
"docker_image_tag": imageTag,
374+
"path": image_tar,
375+
"checksum": calc_sha256_checksum(image_path),
376+
"docker_image_tag": image_tag,
375377
}
376378

377379
logger.info("Building %d targets" % len(self._plugin.build_targets()))
378-
supportedTargets = list(map(build_target, self._plugin.build_targets()))
379-
return supportedTargets
380+
supported_targets = list(map(build_target, self._plugin.build_targets()))
381+
return supported_targets
380382

381383
def _serve(self, args):
382384
logger = get_logger(args)

0 commit comments

Comments
 (0)