-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compat work for nexus 3.21 and molecule 3.0 (#247)
* CI now uses molecule 3.0 * Cross-platform test_groovySyntax.sh (fix for MacOS) * Fix repo creation for Nexus 3.21+ (integration of #246 + idempotency) * Backward compatibility for content selectors * Content selectors creation script is now idempotent Co-authored-by: Oleksii <[email protected]>
- Loading branch information
1 parent
56f2d1d
commit e959cc3
Showing
34 changed files
with
153 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import groovy.json.JsonOutput | ||
import groovy.json.JsonSlurper | ||
import org.sonatype.nexus.selector.SelectorConfiguration | ||
import org.sonatype.nexus.selector.SelectorManager | ||
|
||
parsed_args = new JsonSlurper().parseText(args) | ||
|
||
List<Map<String, String>> actionDetails = [] | ||
Map scriptResults = [changed: false, error: false] | ||
scriptResults.put('action_details', actionDetails) | ||
|
||
SelectorManager selectorManager = container.lookup(SelectorManager.class.name) | ||
|
||
parsed_args.each { currentSelector -> | ||
|
||
Map<String, String> currentResult = [name: currentSelector.name] | ||
|
||
try { | ||
boolean update = true | ||
|
||
SelectorConfiguration selectorConfig = selectorManager.browse().find { it -> it.name == currentSelector.name } | ||
|
||
if (selectorConfig == null) { | ||
update = false | ||
try { | ||
selectorConfig = selectorManager.newSelectorConfiguration() | ||
} catch (MissingMethodException) { | ||
selectorConfig = SelectorConfiguration.newInstance() | ||
} | ||
selectorConfig.setName(currentSelector.name) | ||
} else { | ||
existingConfigDump = selectorConfig.dump() | ||
} | ||
|
||
selectorConfig.setDescription(currentSelector.description) | ||
selectorConfig.setType('csel') | ||
selectorConfig.setAttributes([ | ||
'expression': currentSelector.search_expression | ||
] as Map<String, Object>) | ||
|
||
if (update) { | ||
if (existingConfigDump != selectorConfig.dump()) { | ||
selectorManager.update(selectorConfig) | ||
currentResult.put('status', 'updated') | ||
scriptResults['changed'] = true | ||
} else { | ||
currentResult.put('status', 'no change') | ||
} | ||
} else { | ||
selectorManager.create(selectorConfig) | ||
currentResult.put('status', 'created') | ||
scriptResults['changed'] = true | ||
} | ||
} catch (Exception e) { | ||
currentResult.put('status', 'error') | ||
currentResult.put('error_msg', e.toString()) | ||
scriptResults['error'] = true | ||
} | ||
|
||
scriptResults['action_details'].add(currentResult) | ||
} | ||
|
||
return JsonOutput.toJson(scriptResults) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
- import_playbook: ../default-converge.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
- import_playbook: ../default-converge.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
- import_playbook: ../default-converge.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
- import_playbook: ../default-converge.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
- import_playbook: ../default-converge.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.