vmware / build-tools-for-vmware-aria

Build Tools for VMware Aria provides development and release management tools for implementing automation solutions based on the VMware Aria Suite and VMware Cloud Director. The solution enables Virtual Infrastructure Administrators and Automation Developers to use standard DevOps practices for managing and deploying content.
Other
48 stars 24 forks source link

Content Sharing Policy not pulled if the scope (project) is different than the configured in maven settings.xml #279

Closed alekskolev closed 5 months ago

alekskolev commented 6 months ago

Description

When pulling the content sharing policies from vRA there are no files created under policies/content-sharing folder

Steps to Reproduce

  1. Create projects proj1 and proj2
  2. Create blueprint under proj1 shared with all projects
  3. Create templates content source for proj1 (ex. proj1CS)
  4. Create content sharing policy (proj2CSP) with scope proj2 and content source from step 3 (proj1CS)
  5. Add the policy in the content.yaml
    policy:
    content-sharing:
    - proj2CSP
  6. Set proj1</vrang.project.name> in maven settings.xml
  7. Execute mvn vra-ng:pull

Preconditions:

Expected behavior: File proj2CSP.json created under policies/content-sharing

Actual behavior: File proj2CSP.json is not created (no "Storing contentSharingPolicy 'proj2CSP'" line in the log)

Reproduces how often: 100%

Component/s: maven/plugins/vra-ng

Affects Build/s: 2.38.1

Environment

vRA8.16.0

Client

Server

Failure Logs

Related issues and PRs

Additional Context

When I change the project name in maven setting to proj2 (and empty all else in content.yaml so there is no errors fetching other items) the file is created. After this when you put back the proj1 in maven settings and push vra code - there is additional policy with scope proj1 created (expected but not correct)

Discussed with development team: In the response from vRA for the policies there is a field projectId. It should be populated in the policy file (as projectName) on pull so it can be looked up on push for the proper projectId (CATALOG_SOURCE_IDENTIFIER is done similarly). If it's missing in the file then the configured on maven settings could be used for backward compatibility Current API response:

{
   "id": "policy_id",
   "name": "proj2CSP",
   "typeId": "com.vmware.policy.catalog.entitlement",
   "enforcementType": "HARD",
   "orgId": "org_Id",
   "projectId": "proj2_Id",
   "definition": {
      "entitledUsers": [{
            "items": [{
                  "id": "proj1CS_Id",
                  "type": "CATALOG_SOURCE_IDENTIFIER"
               }
            ],
            "userType": "USER",
            "principals": [{
                  "type": "PROJECT",
                  "referenceId": ""
               }
            ]
         }
      ]
   }
}

The documentation should be updated with a detailed description Should be checked also the case when there are more than one Content Sharing Policy with the same name as currently a file with index is created for each additional one

akantchev commented 5 months ago

Issue resolved with PR: https://github.com/vmware/build-tools-for-vmware-aria/pull/281