Skip to content

Commit

Permalink
feat: set user-agent on kube api-server requests (#168)
Browse files Browse the repository at this point in the history
* feat: set user-agent on kube api-server requests

* feat: allow publish rc versions

* Update KubeApiConfig.js

* Update KubeApiConfig.js

* Update KubeApiConfig.js

* Update KubeApiConfig.js

* Update KubeApiConfig.js

* Update lib/KubeApiConfig.js

Co-authored-by: Adam King <rak@linux.vnet.ibm.com>

* Update KubeApiConfig.js

Co-authored-by: Adam King <rak@linux.vnet.ibm.com>
  • Loading branch information
alewitt2 and adamkingit authored Mar 18, 2021
1 parent 9b10943 commit 89959c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ script:
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then npm audit; else npm audit || true; fi
- npm run lint
- npm test
- if [ -n "${TRAVIS_TAG}" ]; then npm version --no-git-tag-version "${TRAVIS_TAG}"; fi
- if [[ "${TRAVIS_TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then npm version --no-git-tag-version "${TRAVIS_TAG}"; fi

deploy:
# Publish npm package with tag "next" on release candidates
- provider: npm
email: "${NPMJS_EMAIL}"
api_key: "${NPMJS_API_KEY}"
tag: next
skip_cleanup: true
on:
tags: true
condition: ${TRAVIS_TAG} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)$
# Publish npm package as "latest" on release
- provider: npm
email: "${NPMJS_EMAIL}"
api_key: "${NPMJS_API_KEY}"
Expand Down
4 changes: 4 additions & 0 deletions lib/KubeApiConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const packagejson = require('../package.json');
const fs = require('fs-extra');
const objectPath = require('object-path');
const k8s = require('@kubernetes/client-node');
Expand Down Expand Up @@ -74,7 +75,10 @@ module.exports = function kubeApiConfig(options = {}) {
}
result.baseUrl = cluster.server;

const userAgentName = process.env.USER_AGENT_NAME || 'razee-io/kubernetes-util';
const userAgentVersion = process.env.USER_AGENT_VERSION || packagejson.version;

objectPath.set(result, 'headers.User-Agent', `${userAgentName}/${userAgentVersion}`);
_kubeApiConfig.kubeConfig = result;
return result;
};
Expand Down

0 comments on commit 89959c6

Please sign in to comment.