Permalink
Browse files

Change environment variables

  • Loading branch information...
making committed Dec 3, 2017
1 parent 301692b commit 018aa95e21e666c2b469fb5eb827cc142d0a0cb9
Showing with 14 additions and 8 deletions.
  1. +2 −2 k8s/blog-updater.yml
  2. +12 −6 src/main/java/am/ik/blog/entry/EntryGithubClient.java
View
@@ -57,12 +57,12 @@ spec:
configMapKeyRef:
name: blog-config
key: ops-password
- name: blog-updater.github-token.making/blog.ik.am
- name: BLOG_UPDATER_GITHUB_TOKEN_MAKING_BLOG_IK_AM
valueFrom:
configMapKeyRef:
name: blog-updater-config
key: blog-updater-github-token
- name: blog-updater.github-token.utmaki/blog.ik.am
- name: BLOG_UPDATER_GITHUB_TOKEN_UTMAKI_BLOG_IK_AM
valueFrom:
configMapKeyRef:
name: blog-updater-config
@@ -44,12 +44,18 @@
Consumer<HttpHeaders> headers(String repository) {
return headers -> {
String token = Optional.ofNullable(props.getGithubToken())
.map(m -> m.get(repository)).orElseGet(() -> {
String key = "blog-updater.github-token." + repository;
log.warn("fallback to get from environment variable({})", key);
return System.getenv(key);
});
String token = Optional
.ofNullable(props.getGithubToken())
.map(m -> m.get(repository))
.orElseGet(
() -> {
String key = "BLOG_UPDATER_GITHUB_TOKEN_"
+ (repository.toUpperCase().replace("/", "_")
.replace(".", "_"));
log.warn("fallback to get from environment variable({})",
key);
return System.getenv(key);
});
if (!StringUtils.isEmpty(token)) {
log.info("Set Github Token for {}", repository);
headers.add(HttpHeaders.AUTHORIZATION, "token " + token);

0 comments on commit 018aa95

Please sign in to comment.