Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotCLI: Add ability to send site variables when sending a host #28059

Closed
wezell opened this issue Mar 22, 2024 · 8 comments · Fixed by #28340 or #28421
Closed

dotCLI: Add ability to send site variables when sending a host #28059

wezell opened this issue Mar 22, 2024 · 8 comments · Fixed by #28340 or #28421

Comments

@wezell
Copy link
Contributor

wezell commented Mar 22, 2024

Parent Issue

No response

User Story

Customers would like the ability to add site variables via the CLI - this would be helpful to customers when developing new sites.

The variables could simply be contained in a dot_SiteVariable property that is included in the Site.json files. We should follow the pattern we use for setting other collections. If the dotSiteVariable is set, we sync the site variables to match what is being passed in. If the dotSiteVariable exists and is empty, then we delete all the site variables in the target site. If the dotSiteVariable property does not exist, we do not touch the site variables.

Acceptance Criteria

It should be possible to add or edit site variables using the CLI.

Proposed Objective

Please Select

Proposed Priority

Please Select

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

Feedback from customer

We make heavy use of site variables. We tested by creating a variable in the admin site and ran a Pull. The variables never show up in the site descriptor JSON file. Ideally, we’d love to be able to read/write these locally as well. This would be extremely helpful in the development of Velocity templates that leverage these variables.

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

@fabrizzio-dotCMS
Copy link
Contributor

Some work on this has been done here

@nollymar nollymar removed the Triage label Apr 16, 2024
jgambarios added a commit that referenced this issue Apr 18, 2024
jgambarios added a commit that referenced this issue Apr 18, 2024
jgambarios added a commit that referenced this issue Apr 23, 2024
@jgambarios jgambarios linked a pull request Apr 23, 2024 that will close this issue
jgambarios added a commit that referenced this issue Apr 24, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 25, 2024
* #28059

* #28059 Adding support for site variables when using the site related endpoints

* #28059 Updating postman tests

* #28059 Updating postman tests

* #28059 Adding support for site variables in the CLI

* #28059 Adding integration tests to the site variables functionality

* #28059 Updating integrations tests

* #28059 Applying sonarlint feedback

---------

Co-authored-by: fabrizzio-dotCMS <fabrizzio@dotCMS.com>
@jgambarios jgambarios removed their assignment Apr 25, 2024
@nollymar nollymar reopened this Apr 25, 2024
@fabrizzio-dotCMS fabrizzio-dotCMS self-assigned this Apr 25, 2024
@fabrizzio-dotCMS
Copy link
Contributor

fabrizzio-dotCMS commented Apr 26, 2024

we need a small improvement error handling wise I was able to push the following request

{
  "dotCMSObjectType" : "Site",
  "inode" : "b92c1727-772a-4ad1-a18d-10646655ecaf",
  "identifier" : "8a7d5e23-da1e-420a-b4f0-471e7da8ea2d",
  "aliases" : null,
  "systemHost" : false,
  "siteName" : "default",
  "tagStorage" : "8a7d5e23-da1e-420a-b4f0-471e7da8ea2d",
  "siteThumbnail" : "",
  "runDashboard" : false,
  "keywords" : null,
  "description" : null,
  "googleMap" : null,
  "googleAnalytics" : null,
  "addThis" : null,
  "proxyUrlForEditMode" : null,
  "embeddedDashboard" : null,
  "languageId" : 1,
  "variables" : [ {
    "name" : "var1",
    "key" : "var1",
    "value" : "value-1"
  }, {
    "name" : "var3",
    "key" : "var3",
    "value" : "lol"
  }, {
    "name" : "var3",
    "key" : "var3",
    "value" : "lol2"
  } ],
  "modDate" : "2024-04-26T22:25:48.084+00:00",
  "modUser" : "dotcms.org.1",
  "live" : true,
  "default" : true,
  "locked" : true,
  "archived" : false,
  "working" : true
}

I can send dups. And the second key is the one that prevails. But since the UI prevents such situation we should do the same. We need to modify the endpoint to report an error and present it in the cli

Additionally I got an error when pushing from within the sites folder whenever I do :

fabrizzioaraya@Fabrizzios-MacBook-Pro sites % dot push --dry-run
|
 ──────
 No changes in Languages to push

|
 ──────
 Push Data: [1] Sites to push: (0 New - 1 Modified)

 Sites:
     └── default.json ✎

-
 ──────
 No changes in ContentTypes to push


[ERROR] ❗  Error in command [push] with message:
  Invalid source path. Source path must be inside the files folder or at the root of the workspace
run with -e or --errors for full details on the exception.

@fabrizzio-dotCMS
Copy link
Contributor

Per @wezell's comment Im passing it

@fabrizzio-dotCMS
Copy link
Contributor

fabrizzio-dotCMS commented Apr 29, 2024

If I introduce an error in a json site descriptor like
a dupe or a blank in a key then I push the file. No error is reported back from the server. That is OK
But the json descriptor should be refreshed. The json description should get refreshed. So no errors remind there

@nollymar nollymar reopened this Apr 29, 2024
@jgambarios jgambarios self-assigned this May 1, 2024
@jgambarios jgambarios linked a pull request May 2, 2024 that will close this issue
jgambarios added a commit that referenced this issue May 3, 2024
The HostVariableAPIImpl was refactored to make use of Google's Immutable List implementation for returned site variables in the getUniqueSiteVariables() method. We previously used an ArrayList, but have made the shift for its immutable properties and thread-safety.
github-merge-queue bot pushed a commit that referenced this issue May 3, 2024
* #28059 Improving duplicated variables handling.

* #28059 Refactor HostVariableAPIImpl to use ImmutableList

The HostVariableAPIImpl was refactored to make use of Google's Immutable List implementation for returned site variables in the getUniqueSiteVariables() method. We previously used an ArrayList, but have made the shift for its immutable properties and thread-safety.
@jgambarios jgambarios removed their assignment May 3, 2024
@jgambarios jgambarios reopened this May 3, 2024
@fabrizzio-dotCMS fabrizzio-dotCMS self-assigned this May 6, 2024
@fabrizzio-dotCMS fabrizzio-dotCMS removed their assignment May 7, 2024
@fabrizzio-dotCMS
Copy link
Contributor

Passing it to QA as I was able to manipulate site vars without any problem
a new issue was found and it is filed here

@nollymar nollymar closed this as completed May 8, 2024
@bryanboza
Copy link
Member

Fixed, able to get site variables after this change:

{
  "dotCMSObjectType" : "Site",
  "inode" : "9a8f37fb-d70b-4f54-a299-a3a0a4e4c011",
  "identifier" : "415ad4ca0aa0fb002e4593537a32c2bf",
  "aliases" : null,
  "systemHost" : false,
  "siteName" : "testSite",
  "tagStorage" : "48190c8c-42c4-46af-8d1a-0cd5db894797",
  "siteThumbnail" : "",
  "runDashboard" : false,
  "keywords" : null,
  "description" : null,
  "googleMap" : null,
  "googleAnalytics" : null,
  "addThis" : null,
  "proxyUrlForEditMode" : null,
  "embeddedDashboard" : null,
  "languageId" : 1,
  "variables" : [ {
    "name" : "test1",
    "key" : "test1",
    "value" : "test1"
  } ],
  "modDate" : "2024-05-08T22:36:28.144+00:00",
  "modUser" : "dotcms.org.1",
  "default" : false,
  "locked" : false,
  "live" : true,
  "archived" : false,
  "working" : true
}

@bryanboza
Copy link
Member

Fixed, new task related to the test improvements created here: #28543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment