Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.

Update to use config toolkit #64

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ fun main() {
Utils.setWorkflowOpts()

val connectionQN = Utils.reuseConnection("CONNECTION_QUALIFIED_NAME")
val apiTokenName = Utils.getEnvVar("API_TOKEN_NAME", "")
val apiTokenGuid = Utils.getEnvVar("API_TOKEN_GUID", "")

if (connectionQN == "" || apiTokenName == "") {
if (connectionQN == "" || apiTokenGuid == "") {
logger.error("Missing required parameter - you must provide BOTH a connection and the name of an API token.")
exitProcess(4)
}

val apiTokenId = getIdForToken(apiTokenName)
val apiTokenId = getIdForToken(apiTokenGuid)
val connection = getConnectionWithAdmins(connectionQN)
addTokenAsConnectionAdmin(connection, apiTokenId)
}

/**
* Retrieve the API token's pseudo-username, that can be used anywhere a username can be used.
*
* @param apiTokenName name of the API token for which to fetch the pseudo-username
* @param apiTokenGuid name of the API token for which to fetch the pseudo-username
* @return the pseudo-username of the API token
*/
fun getIdForToken(apiTokenName: String): String {
logger.info("Looking up API token: {}", apiTokenName)
val token = Atlan.getDefaultClient().apiTokens.get(apiTokenName)
fun getIdForToken(apiTokenGuid: String): String {
logger.info("Looking up API token: {}", apiTokenGuid)
val token = Atlan.getDefaultClient().apiTokens.getByGuid(apiTokenGuid)
if (token == null) {
logger.error("Unable to find any API token with the name: {}", apiTokenName)
logger.error("Unable to find any API token with the GUID: {}", apiTokenGuid)
exitProcess(5)
}
return "service-account-${token.clientId}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object ApiTokenConnectionAdminPkg : CustomPackage(
"API Token Connection Admin",
"Assigns an API token as a connection admin for an existing connection.",
"http://assets.atlan.com/assets/ph-key-light.svg",
"https://developer.atlan.com/samples/packages/api-token-connection-admin/",
"https://atlanhq.github.io/marketplace-csa-scripts/api-token-connection-admin/",
uiConfig = UIConfig(
steps = listOf(
UIStep(
Expand All @@ -39,7 +39,7 @@ object ApiTokenConnectionAdminPkg : CustomPackage(
),
),
),
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.3.0",
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.4.0",
containerCommand = listOf("/dumb-init", "--", "java", "ApiTokenConnectionAdminKt"),
outputs = WorkflowOutputs(mapOf("debug-logs" to "/tmp/debug.log")),
keywords = listOf("kotlin", "utility"),
Expand Down
1 change: 1 addition & 0 deletions packages/duplicate-detector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {

dependencies {
implementation(project(":common"))
implementation(project(":serde"))
implementation(project(":pkg-config"))
}

Expand Down
17 changes: 4 additions & 13 deletions packages/duplicate-detector/src/main/kotlin/DuplicateDetector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,13 @@ private val hashToAssetKeys = ConcurrentHashMap<Int, MutableSet<AssetKey>>()
private val hashToColumns = ConcurrentHashMap<Int, Set<String>>()
private val uniqueContainers = ConcurrentHashMap<AssetKey, AssetKey>()

fun main(args: Array<String>) {
fun main() {
Utils.setClient()
Utils.setWorkflowOpts()

val qnPrefix: String
val types: List<String>
val batchSize: Int
if (args.isNotEmpty()) {
qnPrefix = args[0]
types = args[1].split(",")
batchSize = 50
} else {
qnPrefix = Utils.getEnvVar("QN_PREFIX", "default")
types = Utils.getEnvVar("ASSET_TYPES", "Table,View,MaterialisedView").split(",")
batchSize = Utils.getEnvVar("BATCH_SIZE", "50").toInt()
}
val qnPrefix = Utils.getEnvVar("QN_PREFIX", "default")
val types = MultiSelectDeserializer.deserialize(Utils.getEnvVar("ASSET_TYPES", "[\"Table\",\"View\",\"MaterialisedView\"]"))
val batchSize = Utils.getEnvVar("BATCH_SIZE", "50").toInt()

logger.info("Detecting duplicates across {} (for prefix {}) on: {}", types, qnPrefix, Atlan.getDefaultClient().baseUrl)
findAssets(qnPrefix, types, batchSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object DuplicateDetectorPkg : CustomPackage(
"Duplicate Detector",
"Detect possible duplicate tables, views and materialized views based on their columns.",
"http://assets.atlan.com/assets/ph-copy-light.svg",
"https://developer.atlan.com/samples/packages/duplicate-detector/",
"https://atlanhq.github.io/marketplace-csa-scripts/duplicate-detector/",
uiConfig = UIConfig(
steps = listOf(
UIStep(
Expand Down Expand Up @@ -71,7 +71,7 @@ object DuplicateDetectorPkg : CustomPackage(
),
),
),
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.3.0",
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.4.0",
containerCommand = listOf("/dumb-init", "--", "java", "DuplicateDetectorKt"),
outputs = WorkflowOutputs(mapOf("debug-logs" to "/tmp/debug.log")),
keywords = listOf("kotlin", "utility"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object MigrationAssistantExportPkg : CustomPackage(
"Migration Assistant Export",
"Export manually-enriched assets and the manual enrichments made against them.",
"http://assets.atlan.com/assets/ph-cloud-arrow-down-light.svg",
"https://developer.atlan.com/samples/packages/migration-assistant-export/",
"https://atlanhq.github.io/marketplace-csa-scripts/migration-assistant/export/",
uiConfig = UIConfig(
steps = listOf(
UIStep(
Expand Down Expand Up @@ -55,7 +55,7 @@ object MigrationAssistantExportPkg : CustomPackage(
label = "Batch size",
required = false,
help = "Maximum number of results to process at a time (per API request).",
placeholder = "20",
placeholder = "50",
grid = 4,
),
),
Expand All @@ -68,9 +68,14 @@ object MigrationAssistantExportPkg : CustomPackage(
),
),
),
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.3.0",
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.4.0",
containerCommand = listOf("/dumb-init", "--", "java", "ExporterKt"),
outputs = WorkflowOutputs(mapOf("debug-logs" to "/tmp/debug.log")),
outputs = WorkflowOutputs(
mapOf(
"debug-logs" to "/tmp/debug.log",
"assets-csv" to "/tmp/asset-export.csv",
),
),
keywords = listOf("kotlin", "utility"),
preview = true,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object MigrationAssistantImportPkg : CustomPackage(
"Migration Assistant Import",
"Import manually-enriched assets from a CSV file.",
"http://assets.atlan.com/assets/ph-cloud-arrow-up-light.svg",
"https://developer.atlan.com/samples/packages/migration-assistant-import/",
"https://atlanhq.github.io/marketplace-csa-scripts/migration-assistant/import/",
uiConfig = UIConfig(
steps = listOf(
UIStep(
Expand All @@ -38,6 +38,7 @@ object MigrationAssistantImportPkg : CustomPackage(
possibleValues = mapOf(
"certificateStatus" to "Certificate",
"announcementType" to "Announcement",
"displayName" to "Display name",
"description" to "Description (system)",
"userDescription" to "Description (user)",
"ownerUsers" to "Owners (users)",
Expand All @@ -63,7 +64,7 @@ object MigrationAssistantImportPkg : CustomPackage(
label = "Batch size",
required = false,
help = "Maximum number of results to process at a time (per API request).",
placeholder = "20",
placeholder = "50",
grid = 4,
),
),
Expand All @@ -76,7 +77,7 @@ object MigrationAssistantImportPkg : CustomPackage(
),
),
),
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.3.0",
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.4.0",
containerCommand = listOf("/dumb-init", "--", "java", "ImporterKt"),
outputs = WorkflowOutputs(mapOf("debug-logs" to "/tmp/debug.log")),
keywords = listOf("kotlin", "utility"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object OpenAPISpecLoaderPkg : CustomPackage(
"OpenAPI Spec Loader",
"Loads API specs and paths from an OpenAPI (v3) definition.",
"http://assets.atlan.com/assets/apispec.png",
"https://developer.atlan.com/samples/loaders/openapi/",
"https://atlanhq.github.io/marketplace-csa-scripts/openapi-spec-loader/",
uiConfig = UIConfig(
steps = listOf(
UIStep(
Expand Down Expand Up @@ -73,7 +73,7 @@ object OpenAPISpecLoaderPkg : CustomPackage(
),
),
),
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.3.0",
containerImage = "ghcr.io/atlanhq/atlan-kotlin-samples:0.4.0",
containerCommand = listOf("/dumb-init", "--", "java", "OpenAPISpecLoaderKt"),
outputs = WorkflowOutputs(mapOf("debug-logs" to "/tmp/debug.log")),
keywords = listOf("kotlin", "crawler", "openapi"),
Expand Down