Gitlab Application settings API

Get current application settings

List the current application settings of the GitLab instance.

GET /application/settings
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/application/settings

Example response:

{
   "default_projects_limit" : 100000,
   "signup_enabled" : true,
   "id" : 1,
   "default_branch_protection" : 2,
   "restricted_visibility_levels" : [],
   "password_authentication_enabled_for_web" : true,
   "after_sign_out_path" : null,
   "max_attachment_size" : 10,
   "user_oauth_applications" : true,
   "updated_at" : "2016-01-04T15:44:55.176Z",
   "session_expire_delay" : 10080,
   "home_page_url" : null,
   "default_snippet_visibility" : "private",
   "outbound_local_requests_whitelist": [],
   "domain_whitelist" : [],
   "domain_blacklist_enabled" : false,
   "domain_blacklist" : [],
   "created_at" : "2016-01-04T15:44:55.176Z",
   "default_project_visibility" : "private",
   "default_group_visibility" : "private",
   "gravatar_enabled" : true,
   "sign_in_text" : null,
   "container_registry_token_expire_delay": 5,
   "repository_storages": ["default"],
   "plantuml_enabled": false,
   "plantuml_url": null,
   "terminal_max_session_time": 0,
   "polling_interval_multiplier": 1.0,
   "rsa_key_restriction": 0,
   "dsa_key_restriction": 0,
   "ecdsa_key_restriction": 0,
   "ed25519_key_restriction": 0,
   "first_day_of_week": 0,
   "enforce_terms": true,
   "terms": "Hello world!",
   "performance_bar_allowed_group_id": 42,
   "instance_statistics_visibility_private": false,
   "user_show_add_ssh_key_message": true,
   "local_markdown_version": 0,
   "allow_local_requests_from_hooks_and_services": true,
   "allow_local_requests_from_web_hooks_and_services": true,
   "allow_local_requests_from_system_hooks": false,
   "asset_proxy_enabled": true,
   "asset_proxy_url": "https://assets.example.com",
   "asset_proxy_whitelist": ["example.com", "*.example.com", "your-instance.com"]
}

fatal: unable to access ‘https://github.com/xxx’: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

If you are behind a proxy, try the following:

git config --global --add remote.origin.proxy ""
git config --global http.sslBackend "openssl"

Git: Remove committed file after push

If you want to remove the file from the remote repo, first remove it from your project with –cache option and then push it:

git rm --cache /path/to/file
git commit -am "Remove file"
git push

(This works even if the file was added to the remote repo some commits ago) Remember to add to .gitignore the file extensions that you don’t want to push.

Install homebrew without sudo in MacOS

Homebrew needs /usr/local to be chown-ed to your user, and you need sudo for that. If you can’t you have to install it elsewhere. Some people use ~/.brew or ~/homebrew; you can use anything but avoid paths with spaces.

Let’s say you want to install in ~/.brew; run the following command:

git clone --depth=1 https://github.com/Homebrew/brew ~/.brew

Then ensure the bin and sbin directories are in your PATH. If you’re using Bash add the following in your ~/.bash_profile:

export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"

Run source ~/.bash_profile or restart your shell and run brew doctor to see if it’s installed correctly. It should warn you it’s not installed into /usr/local but that’s expected here.

How to separate serverless code from local server code

I currently have a static web app which is hosted on AWS S3 bucket hosting. The backend APIs are running on Lambda/API Gateway. I have a continuous development pipeline set up which automatically builds (using CodeBuild) and deploys (using CodeDeploy) my code from my GitHub repo onto S3.

The problem I have right now is that the code which is deployed serverlessly is different from the code I need to run on my local environment.

For example I want my local environment to call the API from localhost, but I want my production environment to call the API from a site like api.example.com. Also there is some code which is different in order to deploy to Lambda, which won’t run locally without reverting the change.

Another example: locally the APIs run on an Express server, but on AWS the code needs to be wrapped in
exports.handler = async (event, context, callback) => {...} to run serverlessly on Lambda.

My question is, how do I handle these differences between local and serverless in my Git repository?

Solution:

It would seem to me that using Codepipeline, CodeBuild and Cloudformation for this could be a good option. You didn’t specify what you are already using so I’m offering this as an example.

It will require some up-tooling to work. To get started you could have a look at CodeStar, which can get you set-up with a sample of this – that you could edit for your own purposes – in minutes. It can poll a github repo for changes on a particular branch to kick off builds.

In the pipeline you could have say 4 stages: Source (pull source from git), Build (CodeBuild to create the build artifacts), Dev/Test environment and finally Production.

The non-sensitive configuration you could keep in the git repo in different parameter files (for the cloudformation app stacks) for each different development and production configuration. You inject a different (json) parameter file for development and production (e.g. from the github repo) into the cloudformation stack as part of the deployment stage. Some of it you can also inject via parameter overrides (the come in handy where for instance you want to use “build tags” like commit id or whatever).

Consider using Secrets Manager for the sensitive bits like username/password pairs etc (or maybe all config – that’s an option too). Use a Secrets Manager key per environment. Send the Secrets Manager key (dev or prod) to the given app stack as an input parameter (cloudformation). Pull the Secrets Manager key/values from the app code (use an IAM role to grant privileges to for the Lambda’s to specific Secrets Manager keys) and use secret caching.

Also, as an aside – consider using AWS SAM (local) if you are not already.

The purpose of this is to:

  • Separate configuration from code
  • Automate your builds and deployments
  • Minimise scope for human error
  • Help reduce or outright eliminate downtime during deployments
  • Easy way to rollback (git revert for instance)

binding.gyp not found while trying to load binding.gyp mac

Check the error you get while executing: node-gyp rebuild

If it is a permission denied then retry the command with sudo.
If the error is still persistent execute the following:

xcode-select –install

Updates were rejected because the tip of your current branch is behind

If you want to avoid having to use -f, then you can use just

git pull

instead of

git pull --rebase

The non-rebase will fetch the changes from origin/dev and merge them into your FixForBugbranch. Then, you will be able to run

git push origin FixForBug

without using -f.

Git refusing to merge unrelated histories on rebase

During git rebase origin/development the following error message is shown from git:

fatal: refusing to merge unrelated histories
Error redoing merge 1234deadbeef1234deadbeef

The default behavior has changed since git 2.9:

“git merge” used to allow merging two branches that have no common base by default, which led to a brand new history of an existing project created and then get pulled by an unsuspecting maintainer, which allowed an unnecessary parallel history merged into the existing project. The command has been taught not to allow this by default, with an escape hatch --allow-unrelated-histories option to be used in a rare event that merges histories of two projects that started their lives independently.

GIT push: permission denied (public key)

GIT: I’m trying to push a file to a repo of a friend but errors on the public key.

git push origin testbranch
Permission denied (publickey).
fatal: Could not read from remote repository.

Where and how do we define public/private keys?

git remote -v returns:

origin  git@github.com:Sesamzaad/NET.git (fetch)
origin  git@github.com:Sesamzaad/NET.git (push)

Use ssh instead of HTTP. Remove origin if its HTTP.

git remote rm origin

Add ssh URL

git remote add origin git@github.com:<username>/<repo>.git

Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.

cd ~/.ssh
ssh-keygen

Copy the key. You can view your key using. If you hadn’t specified a different path then this is the default one.

cat ~/.ssh/id_rsa.pub

Add this key to your GitHub account. Next, do

ssh -T git@github.com

You will get a welcome message in your console.

cd into your project folder. git push -u origin master now works!

fatal: protocol ''https' is not supported in Git

I tried to push the repo to my azure remote by runnng git push azure master. The remote URL is 'https://<myid>@ndas.scm.azurewebsites.net/<myapp>.git'.

The problem is, it says protocol ‘https’ is not supported

Please see the following screenshot:

Solution:

The problem is, it says protocol ‘https’ is not supported

It actually doesn’t say that. Here’s what it actually says:

fatal: protocol ”https’ is not supported

Note the two single quotes at the beginning and one at the end. The first and last are quoting the protocol for the error message, but the second quote is part of the protocol being rejected: 'https.

Note also the full output you see from git remote -v. Your azure remote URLs include literal leading and trailing single quotes while your origin remote URLs (which are presumably working) don’t.

Try running

git remote set-url azure https://poomani98@ndas.scm.azurewebsites.net/ndas.git

to set the remote URL to https://poomani98@ndas.scm.azurewebsites.net/ndas.git instead of 'https://poomani98@ndas.scm.azurewebsites.net/ndas.git', then pushing again.