Skip to content

Commit

Permalink
Merge pull request #10 from mcanoy/route-name
Browse files Browse the repository at this point in the history
Ability to customize route name, update build to 7.9.1
  • Loading branch information
mcanoy authored Oct 25, 2019
2 parents 8b2c98f + a98a2d1 commit e3d04ff
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 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)
2 changes: 1 addition & 1 deletion example/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN cp -a /opt/sonarqube/data /opt/sonarqube/data-init && \
chown root:root /opt/sonarqube && chmod -R gu+rwX /opt/sonarqube
ADD plugins.sh /opt/sonarqube/bin/plugins.sh
RUN /opt/sonarqube/bin/plugins.sh $sonar_plugins
ADD sonar-auth-openshift-plugin-1.1.0.jar /opt/sonarqube/extensions-init/plugins/sonar-auth-openshift-plugin-1.1.0.jar
ADD https://github.com/rht-labs/sonar-auth-openshift/releases/latest/download/sonar-auth-openshift-plugin.jar /opt/sonarqube/extensions-init/plugins/
RUN chown root:root /opt/sonarqube -R; \
chmod 6775 /opt/sonarqube -R
USER 1001
2 changes: 1 addition & 1 deletion example/inventory/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sonarqube:
SOURCE_REPOSITORY_REF: "master"
SOURCE_CONTEXT_DIR: example
FROM_DOCKER_IMAGE: sonarqube
FROM_DOCKER_TAG: "7.7-community"
FROM_DOCKER_TAG: "7.9.1-community"
FROM_DOCKER_IMAGE_REGISTRY_URL: "docker.io/sonarqube"
postgresql:
POSTGRESQL_DATABASE: sonar
Expand Down
3 changes: 2 additions & 1 deletion example/sonar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ sonar.auth.openshift.button.color=#000000
sonar.auth.openshift.sar.groups=sonarqube_admin=sonar-administrators,sonarqube_user=sonar-users
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 e3d04ff

Please sign in to comment.