Skip to content

Commit

Permalink
Ability to change name the route something other than sonarqube
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanoy committed Oct 14, 2019
1 parent dd90950 commit a96a166
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ kubernetes.service=https://${env:KUBERNETES_SERVICE_HOST}:${env:KUBERNETES_SERVI

See the example set up using the [OpenShift Applier](https://github.com/redhat-cop/openshift-applier) [here](example/README.md)

### Configuration Table

| Config | Purpose |
| ------------- |-------------|
| sonar.auth.openshift.sar.groups | A map converting OpenShift groups to Sonarqube roles |
| sonar.auth.openshift.route.name | The name of the route. Must also be defined in the service account (See example template) |
| oauth.cert | File system location of the certificate |
| ignore.certs | Option to ignore certificates. Not recommended for production |
| kubernetes.service | The url of the api server with port if necessary |
| sonar.auth.openshift.isEnabled | Ability to control whether to user this plugin |
| sonar.auth.openshift.button.color | The hex color of the login button (#666666) |

### License

Licensed under the [Apache License](http://www.apache.org/licenses/LICENSE-2.0.txt)
1 change: 1 addition & 0 deletions example/sonar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ sonar.auth.openshift.sar.groups=sonarqube_admin=sonar-administrators,sonarqube_u
ignore.certs=false
#oauth.cert=/opt/sonarqube/conf/oauth.crt
sonar.search.javaAdditionalOpts=-Dnode.store.allow_mmapfs=false
#sonar.auth.openshift.route.name=customname
12 changes: 6 additions & 6 deletions example/templates/sonarqube-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ objects:
kind: ServiceAccount
metadata:
annotations:
serviceaccounts.openshift.io/oauth-redirectreference.sonarqube: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"sonarqube"}}'
serviceaccounts.openshift.io/oauth-redirectreference.sonarqube: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"${ROUTE_NAME}"}}'
name: sonarqube
- apiVersion: v1
kind: RoleBinding
Expand Down Expand Up @@ -145,7 +145,7 @@ objects:
metadata:
labels:
app: sonarqube
name: sonarqube
name: "${ROUTE_NAME}"
spec:
port:
targetPort: 9000-tcp
Expand Down Expand Up @@ -183,10 +183,10 @@ parameters:
displayName: SonarQube Storage Space Size
required: true
value: 5Gi
- name: SONAR_AUTH_REALM
value: ''
description: The type of authentication that SonarQube should be using (None or LDAP) (Ref - https://docs.sonarqube.org/display/PLUG/LDAP+Plugin)
displayName: SonarQube Authentication Realm
- name: ROUTE_NAME
value: sonarqube
description: The name of the route for sonarqube
displayName: SonarQube Route Name
- name: SONAR_AUTOCREATE_USERS
value: 'false'
description: When using an external authentication system, should SonarQube automatically create accounts for users?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class OpenShiftConfiguration {
private static final String SUBCATEGORY = "Authentication";

private static final String OPENSHIFT_GROUP_MAPPING = "sonar.auth.openshift.sar.groups";
private static final String ROUTE_NAME = "sonar.auth.openshift.route.name";
private static final String OAUTH_CERT = "oauth.cert";
private static final String IGNORE_CERTS = "ignore.certs";
private static final String WEB_URL = "sonar.auth.openshift.webUrl";
Expand Down Expand Up @@ -130,7 +131,7 @@ public String getButtonColor() {
}

public String getRouteURL(String namespace) {
return String.format(ROUTE_URI, getApiURL(), namespace, "sonarqube");
return String.format(ROUTE_URI, getApiURL(), namespace, config.get(ROUTE_NAME).orElse("sonarqube"));
}

public static List<PropertyDefinition> definitions() {
Expand Down

0 comments on commit a96a166

Please sign in to comment.