Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Correcting issue with connectorSubDir.
Browse files Browse the repository at this point in the history
  • Loading branch information
sandonjacobs committed Jun 7, 2021
1 parent eabff82 commit 93ffd5a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group 'com.github.sandonjacobs'
version '0.8.0'
version '0.8.1'

githubRelease {
token = getProperty('github.token')
Expand All @@ -20,7 +20,7 @@ githubRelease {
}

repositories {
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class SubmitConnectorsTask extends DefaultTask {
@Option(option = "connector", description = "If set, only process this specified connector jsonnet file in the connectorSubDir.")
String connectorName

private String pathBase = project.extensions.kafkaConnect.getConnectorsPath()
private String connectorPath = connectorSubDir ? "$pathBase/$connectorSubDir" : pathBase

SubmitConnectorsTask() {
group = project.extensions.kafkaConnect.taskGroup
description = "Load Kafka Connector Configuration files."
Expand All @@ -56,29 +53,41 @@ class SubmitConnectorsTask extends DefaultTask {

@TaskAction
def loadConnectors() {

String pathBase = project.extensions.kafkaConnect.getConnectorsPath()
logger.debug("connector sub dir => {}", connectorSubDir)
String connectorPath = connectorSubDir ? pathBase + '/' + connectorSubDir : pathBase

logger.debug("input param connect-endpoint => {}", connectorEndpoint)
ConnectRest rest = new ConnectRest()
rest.setRestUrl(connectorEndpoint)

logger.debug("connectorPath => {}", connectorPath)
logger.debug("******************************")
logger.debug("pathBae => {}", pathBase)
logger.debug("connectorPath => {}", connectorPath)
logger.debug("connector sub dir => {}", connectorSubDir)
logger.debug("connector name => {}", connectorName)
logger.debug("******************************")

if (connectorName) {
logger.info("processing connector {} from directory {}", connectorName, connectorPath)
def file = new File("${connectorPath}/${connectorName}.jsonnet")
processFile(rest, file)
processFile(rest, connectorPath, file)
} else {
logger.info("processing connectors from directory {}", connectorPath)
def listing = new File(connectorPath)
listing.eachFile { f ->
logger.debug(f.name)
if (!f.isDirectory() && f.name.endsWith(".jsonnet")) {
logger.debug(f.name)
processFile(rest, f)
processFile(rest, connectorPath, f)
}
}
}
}

def processFile(ConnectRest rest, File f) {
def jsonnetOutput = jsonnet(f).toString()
def processFile(ConnectRest rest, String connectorPath, File f) {
def jsonnetOutput = jsonnet(f, connectorPath).toString()
def name = new JsonSlurper().parseText(jsonnetOutput).name
processPayload(rest, name, jsonnetOutput)
}
Expand All @@ -97,7 +106,7 @@ class SubmitConnectorsTask extends DefaultTask {
}
}

def jsonnet(File f) {
def jsonnet(File f, String connectorPath) {
def sout = new StringBuilder(), serr = new StringBuilder()

def command = "jsonnet ${f.path} ${JsonnetUtils.createExtCodeFileArg(connectorPath, extCodeFile)} " +
Expand Down

0 comments on commit 93ffd5a

Please sign in to comment.