Skip to content

Commit 582d70b

Browse files
committed
Add code comment next to workspace ID saying what the org / ws is
1 parent 2301b12 commit 582d70b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

modules/nextflow/src/main/groovy/nextflow/cli/CmdAuth.groovy

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import java.security.MessageDigest
3333
import java.security.SecureRandom
3434
import java.util.concurrent.CompletableFuture
3535
import java.util.concurrent.TimeUnit
36+
import java.util.regex.Pattern
3637

3738
/**
3839
* Implements the 'nextflow auth' commands
@@ -210,6 +211,11 @@ class CmdAuth extends CmdBase implements UsageAware {
210211
configText.append("tower {\n")
211212
towerConfig.each { key, value ->
212213
def configKey = key.toString().substring(6) // Remove "tower." prefix
214+
if (configKey.endsWith('.comment')) {
215+
// Skip comment keys - they're handled below
216+
return
217+
}
218+
213219
if (value instanceof String) {
214220
configText.append(" ${configKey} = '${value}'\n")
215221
} else {
@@ -218,7 +224,19 @@ class CmdAuth extends CmdBase implements UsageAware {
218224
}
219225
configText.append("}\n")
220226

221-
Files.writeString(configFile, configText.toString(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)
227+
def finalConfig = configText.toString()
228+
229+
// Add workspace comment if available
230+
if (config.containsKey('tower.workspaceId.comment')) {
231+
def workspaceId = config['tower.workspaceId']
232+
def comment = config['tower.workspaceId.comment']
233+
finalConfig = finalConfig.replaceAll(
234+
/workspaceId = '${Pattern.quote(workspaceId.toString())}'/,
235+
"workspaceId = '${workspaceId}' // ${comment}"
236+
)
237+
}
238+
239+
Files.writeString(configFile, finalConfig, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)
222240
}
223241

224242
//
@@ -864,6 +882,7 @@ class CmdAuth extends CmdBase implements UsageAware {
864882
} else {
865883
def hadWorkspaceId = config.containsKey('tower.workspaceId')
866884
config.remove('tower.workspaceId')
885+
config.remove('tower.workspaceId.comment')
867886
return hadWorkspaceId
868887
}
869888
} else if (selection > 0 && selection <= workspaces.size()) {
@@ -874,6 +893,7 @@ class CmdAuth extends CmdBase implements UsageAware {
874893
} else {
875894
def currentId = config.get('tower.workspaceId')
876895
config['tower.workspaceId'] = selectedId
896+
config['tower.workspaceId.comment'] = "${selectedWorkspace.orgName} / ${selectedWorkspace.workspaceFullName}"
877897
return currentId != selectedId
878898
}
879899
} else {
@@ -943,6 +963,7 @@ class CmdAuth extends CmdBase implements UsageAware {
943963
} else {
944964
def hadWorkspaceId = config.containsKey('tower.workspaceId')
945965
config.remove('tower.workspaceId')
966+
config.remove('tower.workspaceId.comment')
946967
return hadWorkspaceId
947968
}
948969
} else if (wsSelection > 0 && wsSelection <= orgWorkspaceList.size()) {
@@ -953,6 +974,7 @@ class CmdAuth extends CmdBase implements UsageAware {
953974
} else {
954975
def currentId = config.get('tower.workspaceId')
955976
config['tower.workspaceId'] = selectedId
977+
config['tower.workspaceId.comment'] = "${selectedWorkspace.orgName} / ${selectedWorkspace.workspaceFullName}"
956978
return currentId != selectedId
957979
}
958980
} else {

0 commit comments

Comments
 (0)