Gerrit settings how to notify author when a change has merge conflict by default - configuration

For either All Projects or for a specific project, I can't find a way to notify the author of an open change submitted to Gerrit that this change has now a merge conflict.
I looked into the documentation in Project owner guide, Email Notifications and Notifications, Project level settings.
This would be useful if, by default, a project owner wants his team of developers to have these notifications by default, not to all persons in the team, but, only to the author of the open change which now has a merge conflict.
According to the documentation a specific user may add this specific email notification globally in Settings > Watched Projects with:
Repo: All-projects
Search expression: owner:self status:open -is:mergeable
Select "Changes".

You can't do that using watched projects. You'll need to execute a script periodically to search for this information in Gerrit using REST.
Step 1
Find the open changes with merge conflicts.
The following command will search for all open changes, not WIP, not private and not mergeable, and return their change number and the change owner id:
curl -s --request GET --user USER:PASS https://GERRIT-SERVER/a/changes/?q=status:open+AND+-is:wip+AND+-is:private+AND+-is:mergeable | sed 1d | jq --raw-output '.[] | [._number, .owner._account_id | tostring] | join(" ")'
Step 2
Find the users e-mails.
The following command will search for the change owner id and return his/her e-mail:
curl -s --request GET --user USER:PASS https://GERRIT-SERVER/a/accounts/CHANGE-OWNER-ID | sed 1d | jq --raw-output .email
Step 3
Send the e-mail notifications.

Related

How to get who or what turned off a pod?

We are currently trying to debug an issue with a pod and figured out that 6 other pod (not related) was turned off and would want to figure out when that happens and who or what turned it off (to see if it's related or not with the first issue).
Is it possible to get this kind of information with openshift ?
These operations are typically recorded in the audit logs (if you have enabled those): https://docs.openshift.com/container-platform/4.7/security/audit-log-view.html
So you can filter certain actions for example like so (GET actions):
oc adm node-logs node-1.example.com --path=oauth-apiserver/audit.log \
| jq 'select(.verb != "get")'

POSTMAN - Newman Run Iteration Json File on Specific Endpoint

I have a postman collection that contains some endpoint. Something like this
my-collection
|- Get All Users
|- Get User
|- Delete User
I also have some newman scenario/iteration json files (1. get-all-users.json, 2. get-user.json, 3. delete-user.json).
How do i run single scenario/iteration json file to specific endpoint on my-collection?
Lets say get-all-users.json run for Get All Users endpoint only, instead of run for all endpoints.
By 'single endpoint', you mean running a single sub-folder for 1 iteration, say, 'Get All Users'. Right?
If so, you can export your my-collection as a JSON on your system (No need to individually export the sub-folders to get-all-users.json, get-user.json, delete-user.json).
You can use --folder option (See here for reference). Just give the folder name you want to run, i.e., "Get All Users"
So, your newman command should be (your environment json and global json being "env.json" and "global.json" respectively) :
newman run "<my_collection_path>/my-collection.json" --folder "Get All Users" -e "<env_path>/env.json" -g "<global_path>/global.json"
This way you should be able to run a requests in a single sub-folder at a time.

Deeplinking URLs don't show up in Branch.io Dashboard

I am using branch.io for my android app. I am trying to generate via POST method and this is the code:
{"branch_key":"key_test_lerbZ22zyjfpfFtl2auzukafywi220dN", "campaign":"new_product_annoucement", "channel":"email", "tags":["monday", "test123"],
"data":"{\"name\": \"Alex\", \"email\": \"alex#branch.io\", \"user_id\": \"12346\", \"$desktop_url\": \"https://file.town/download/odrqliwc94d440jt08wxngceo\",\"$marketing_title\": \"2\"}"}
In the dashboard, the campaign can be seen, the channel can be seen, and the generated URL goes to the desired site. But the generated URL does not show up in the Marketing tab in the dashboard to show the URL's statistics with regards to clicks, downloads and installs.
Is there any code I am missing in it?
To use the Branch HTTP API to create a link that shows up in the Marketing section of the Branch dashboard you need to add the parameter "type":2 at the root level of the request. You will also want to use a $marketing_title that is descriptive.
Here is an updated curl request using the parameters you provided:
curl -X POST -H "Content-Type: application/json" -d '{"type":2, "branch_key":"key_test_lerbZ22zyjfpfFtl2auzukafywi220dN", "campaign":"new_product_annoucement", "channel":"email", "tags":["monday", "test123"], "data":"{\"name\": \"Alex\", \"email\": \"alex#branch.io\", \"user_id\": \"12346\", \"$desktop_url\": \"https://file.town/download/odrqliwc94d440jt08wxngceo\",\"$marketing_title\": \"Super Amazing Branch Link\"}"}' https://api.branch.io/v1/url

Change folder ownership in Box

We have a situation where we have 2 users, UserA and UserB. I want to transfer all the files and folders of UserB to UserA.
We are using collaborations API to perform this task. But getting following error
{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"role","message":"Invalid value 'Owner'. 'role' with value 'Owner' not found"}]},"help_url":"http://developers.box.com/docs/#errors","message":"Not Found","request_id":"304354248562a743910984"}
I get a valid response when I pass anything apart from "owner" as role in request. I don't know what is wrong with "owner" role.
Here is the request
POST https://api.box.com/2.0/collaborations/ HTTP/1.1
As-User: 254598270
Authorization: Bearer UPSUE228kXGuDBGzy07G5fGxIrDL1QDj
Content-Type: text/plain; charset=utf-8
Host: api.box.com
Content-Length: 108
Expect: 100-continue
Accept-Encoding: gzip, deflate
{"item":{"id":"5092905410","type":"folder"},"accessible_by":{"id":"254608030","type":"user"},"role":"owner"}
I think the documentation might be wrong. Specifying an "owner" role in a collaboration doesn't really make sense given how collaborations work.
However, the move user's folder endpoint might be what you're looking for. It allows you to move the entire root folder of one user into another user's account. Here's an example cURL request:
curl https://api.box.com/2.0/users/USER_ID/folders/FOLDER_ID \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"owned_by": {"id": "USER_ID"}}' \
-X PUT
Note that only the root folder is supported right now (which is folder ID 0). Fortunately, it looks like that's the folder you're trying to move.
All that's missing is that you must add them as an editor prior to making them an owner.
If you follow https://developer.box.com/guides/folders/single/change-owner/
You will see that transferring ownership actually doesn't require a folder move. It is a very simple two (or three) step process:
Add the new user as a collaborator of role EDITOR
Immediately update that collaboration to the role of OWNER
That's it. Optionally, you now can remove the collaboration of the original owner, who has been downgraded from owner to editor.
Here is my example using the Python SDK:
bc = box.BoxClient() # This is my own client wrapper
owner = bc.get_user(old_owner.lastname)
user_client = bc.get_user_client(owner.id) # Get a user_client for the owner
src_folder = user_client.folder(FOLDER_ID)
target = bc.get_user('new_owner.lastname')
new_collab = src_folder.collaborate(target, CollaborationRole.EDITOR)
updated_collaboration = new_collab.update_info(CollaborationRole.OWNER)
# Now we can remove the original owner as collaborator:
for collab in src_folder.get_collaborations():
target = collab.accessible_by
if target.id == owner.id:
collab.delete()

Get list of repositories using gitweb for external use

To be used in another external script, we need the list of repositories hosted in a git repository server. We have GitWeb also enabled on the server.
Any one know if GitWeb exposes some API through which we can get the list of repositories ? Like GitBlit RPC (http://gitblit.com/rpc.html like https://your.glitblit.url/rpc?req=LIST_REPOSITORIES) ?
Thanks.
No, from what I can see of the gitweb.cgi (from gitweb/gitweb.perl) implementation, there is no RPC API with JSON return messages.
This is only visible through the web page.
In the bottom right corner there is a small button that reads: TXT
You can get the list of projects there, for example:
For sourceware, the gitweb page: https://sourceware.org/git/
The TXT button links here: https://sourceware.org/git/?a=project_index
It should return a list of projects which are basically
<name of the git repository> <owner>
in plain text, perfectly parseable by script.
But if you want JSON, you'd have to convert it with something like this:
$ wget -q -O- "https://sourceware.org/git/?a=project_index" \
| jq -R -n '[ inputs | split(" ")[0:2] | {"project": .[0], "owner": .[1]} ]'