Internal architecture
The Project is based on Spring Boot, using several technologies which can be seen in the build.gradle.
The provision app is merely an orchestrator that does HTTP REST calls to Atlassian Crowd, Jira, Confluence, Bitbucket and Rundeck (for openshift interaction).
The APIs exposed for direct usage, and also for the UI are in the controller package. The connectors to the various tools to create resources are in the services package
How to develop locally
-
Make sure that you have installed GIT and JAVA ( >= 8 ).
-
Clone the project out of Github
$ git clone https://github.com/opendevstack/ods-provisioning-app.git
-
Change directory into ods-provisioning-app
$ cd ods-provisioning-app
-
If you want to build / run locally - create
gradle.properties
in the project’s root to configure connectivity to OpenDevStack NEXUS
nexus_url=<NEXUS HOST>
nexus_user=<NEXUS USER>
nexus_pw=<NEXUS_PW>
If you want to build / run locally without NEXUS, you can disable NEXUS by adding the following property to gradle.properties
:
no_nexus=true
Alternatively, you can also configure the build using environment variables:
Gradle property | Environment variable |
---|---|
nexus_url |
NEXUS_HOST |
nexus_user |
NEXUS_USERNAME |
nexus_pw |
NEXUS_PASSWORD |
no_nexus |
NO_NEXUS |
-
You can start the application with the following command:
# to run the server execute
./gradlew bootRun
To overwrite the provided application.properties a configmap is created out of them and injected into /config/application.properties within the container. The base configuration map as well as the deployment yamls can be found in ocp-config, and overwrite parameters from application.
-
After started the server it can be reached in the browser under
http://localhost:8080
Frontend Code
The frontend is based on jquery and thymeleaf. All posting to the API happens out of java script (client.js)
Backend Code
The backend is based on Spring Boot, authenticates against Atlassian Crowd (Using property provision.auth.provider=crowd
) or OAUTH2/OpenID Connect provider (Using property provision.auth.provider=oauth2
) and exposes consumable APIs (api/v2/project
).
Storage of created projects happens on the filesystem thru the StorageAdapter.
Both frontend (html) and backend are tested thru Junit & Mockito
Authentication Implementation
By using the property provision.auth.provider=crowd
or provision.auth.provider=oauth2
, the application uses eigher CROWD or OAUTH2 authentication. Dependent of the property used, different spring beans are used for configuration.
The switch between the two options is implemented via Spring’s ConditionalOnProperty annotation.
CROWD - specific configuration classes are located in the java package org.opendevstack.provision.authentication.crowd.
Example:
@Configuration
@EnableWebSecurity
@EnableCaching
@EnableEncryptableProperties
@ConditionalOnProperty(name = "provision.auth.provider", havingValue = "crowd")
public class CrowdSecurityConfiguration extends WebSecurityConfigurerAdapter {
//...
}
OAUTH2 - specific configuration classes are located in the java package org.opendevstack.provision.authentication.oauth2.
Example:
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnProperty(name = "provision.auth.provider", havingValue = "oauth2")
@EnableWebSecurity
@EnableOAuth2Client
public class Oauth2SecurityConfiguration extends WebSecurityConfigurerAdapter {
//...
}
Consuming REST APIs in Java
Generally this is a pain. To ease development, a few tools are in use:
-
Jackson (see link below)
-
OKTTP3 Client (see link below)
-
jsonschema2pojo generator (see link below)
The process for new operations to be called is:
-
Look up the API call that you intend to make
-
see if there is a JSON Schema available
-
Generate (a) Pojo('s) for the Endpoint
-
Use the pojo to build your request, convert it to JSON with Jackson and send it via OKHTTP3, and the Provision Application’s RestClient
Link collection
-
Generating POJOs from JSON Schemas very helpful for the Atlassian API Docs
Atlassian API’s