datadrivers/terraform-provider-nexus

Resource and data source nexus_privilege_script

anmoel opened this issue · 4 comments

Resource and data source nexus_privilege_script

This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 7 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

fabrue commented

some refinement:

assuming there is a script named create-repo-pypi-internal that might has been created using already existing TF resource nexus_script

resource "nexus_script" "repo_pypi_internal" {
  name    = "create-repo-pypi-internal"
  type    = "groovy"
  content = "repository.createPyPiHosted('pypi-internal')"
}

one can run

curl -X POST 'localhost:8081/service/rest/v1/security/privileges/script' \
-H 'Content-Type: application/json' \
-d '{
  "name": "script-privilege-unique-name",
  "description": "descrp",
  "actions": [
    "ADD"
  ],
  "scriptName": "create-repo-pypi-internal"
}'

to create and

curl -X PUT 'localhost:8081/service/rest/v1/security/privileges/script/script-privilege-unique-name' \
-H 'Content-Type: application/json' \
-d '{
  "name": "script-privilege-unique-name",
  "description": "descrp",
  "actions": [
    "ADD",
    "RUN"
  ],
  "scriptName": "create-repo-pypi-internal"
}'

to update.
Valid values for actions are: BROWSE, READ, EDIT, ADD, DELETE, RUN, see here for reference

fabrue commented

Some thoughts concerning the new data resource for nexus_privilege_script:

one can get all privileges running curl localhost:8081/service/rest/v1/security/privileges but there is no HTTP parameter or header available that allows selection of a single privilege (actually the call returns all kinds of privileges):

[
    {
        "type": "script",
        "name": "new-unique-name-for-privilege-script",
        "description": "DESCRIPTION",
        "readOnly": false,
        "actions": [
            "ADD"
        ],
        "scriptName": "create-repo-pypi-internal"
    },
        {
        "type": "application",
        "name": "nx-apikey-all",
        "description": "All permissions for APIKey",
        "readOnly": true,
        "actions": [
            "ALL"
        ],
        "domain": "apikey"
    },
    (..........)
]