Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create API ML sample extension #1947

Merged
merged 33 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8b618ce
Create and package sample extension
taban03 Dec 2, 2021
3438736
ADD the path to the jar
taban03 Dec 2, 2021
ad68337
Fix gradle creation of jar
taban03 Dec 2, 2021
6cfc9a1
Add doc
taban03 Dec 2, 2021
1c86098
Remove jib
taban03 Dec 3, 2021
38d00c6
Clean up dependencies
taban03 Dec 3, 2021
1a2c321
skip sonar scan
taban03 Dec 3, 2021
2a10ff4
package controller and dependencies
achmelo Dec 6, 2021
a2a8b0f
Create and package sample extension
taban03 Dec 2, 2021
d1f173d
ADD the path to the jar
taban03 Dec 2, 2021
7c5aa82
Fix gradle creation of jar
taban03 Dec 2, 2021
dd1c4fd
Add doc
taban03 Dec 2, 2021
66078ce
Remove jib
taban03 Dec 3, 2021
afb30b9
Clean up dependencies
taban03 Dec 3, 2021
55d388f
skip sonar scan
taban03 Dec 3, 2021
daac43a
package controller and dependencies
achmelo Dec 6, 2021
dbc6d26
Address requests
taban03 Dec 6, 2021
97fd5a2
Update doc
taban03 Dec 6, 2021
ca9c436
Replace back icon to use material
taban03 Dec 10, 2021
e38557f
Revert change
taban03 Dec 10, 2021
2f88ab0
Fix action
taban03 Dec 14, 2021
9523f0b
attempt
taban03 Dec 14, 2021
52afe66
Attempt 2
taban03 Dec 15, 2021
d31c06d
Attempt 3
taban03 Dec 15, 2021
01b1a86
Fix PR name
taban03 Dec 15, 2021
e26aee1
Fix extension path
taban03 Dec 16, 2021
f2dff31
Fix extension path
taban03 Dec 16, 2021
7ccb86e
Fix extension path
taban03 Dec 16, 2021
a2adda2
Merge remote-tracking branch 'origin/apiml/GH1067/create_sample_ext' …
achmelo Dec 17, 2021
c2619b8
Change extension package to be included in the component scan
taban03 Dec 17, 2021
8535131
Merge remote-tracking branch 'origin/apiml/GH1067/create_sample_ext' …
achmelo Jan 3, 2022
68fb572
debug loader path
achmelo Jan 3, 2022
454f42c
remove debug logs
achmelo Jan 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/pull-request-snapshot-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
name: Release new version for specific pull request (snapshot)

on:
workflow_dispatch:
inputs:
pull_request:
description: 'The pull request snapshot that is going to be released (i.e PR-XXXX)'
required: true
pull_request:
branches: [ master, v2.x.x ]

env:
PR_NUMBER: ${{ github.event.number }}

jobs:
build:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Release with Gradle
run: |
BRANCH_NAME=${{ github.event.inputs.pull_request }}
BRANCH_NAME=PR-${{ env.PR_NUMBER }}
sed -i '/version=/ s/-SNAPSHOT/-'"$BRANCH_NAME"'-SNAPSHOT/' ./gradle.properties
./gradlew build publishAllVersions -Pzowe.deploy.username=$ARTIFACTORY_USERNAME -Pzowe.deploy.password=$ARTIFACTORY_PASSWORD -Partifactory_user=$ARTIFACTORY_USERNAME -Partifactory_password=$ARTIFACTORY_USERNAME -PpullRequest=$BRANCH_NAME
env:
Expand Down
56 changes: 56 additions & 0 deletions apiml-sample-extension-package/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*/

ext {
artifactName = 'apiml-sample-extension-package'
pullNo = project.hasProperty("pullRequest") && project.getProperty("pullRequest") != null ? "-" + project.getProperty("pullRequest") : ""
}

configurations {
sampleExtensionJar
zip
}

dependencies {
sampleExtensionJar(project(path: ":apiml-sample-extension"))
}

task packageSampleExtension(type: Zip) {
archiveName = artifactName + pullNo + ".zip"
includeEmptyDirs = true
def resourceDir = 'src/main/resources/'

into('/') {
from "$resourceDir/manifest.yaml"
}

into('bin/') {
from configurations.sampleExtensionJar
}
}

jar.dependsOn(packageSampleExtension)
build.dependsOn(packageSampleExtension)

artifacts {
zip packageSampleExtension
}

publishing {
publications {
mavenJava(MavenPublication) {
artifact("$buildDir/distributions/$artifactName" + pullNo + ".zip")
}
}
}

jar {
enabled false
}
23 changes: 23 additions & 0 deletions apiml-sample-extension-package/src/main/resources/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: apiml-sample-extension
# Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/.
id: org.zowe.apiml.sdk.apiml-sample-extension-package
# Component version is defined in gradle.properties for Gradle project
# Human readable component name
title: A sample extension for API ML
# Human readable component description
description: JAR that contains a simple controller.
license: EPL-2.0
repository:
type: git
url: https://github.com/zowe/api-layer.git
build:
branch: "{{build.branch}}"
number: "{{build.number}}"
commitHash: "{{build.commitHash}}"
timestamp: "{{build.timestamp}}"
# The following block contains all the extensions directory path
# (or file path) that will be included in the API ML
gatewaySharedLibs:
- bin/apiml-sample-extension.jar

15 changes: 15 additions & 0 deletions apiml-sample-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# API ML sample extension

This is an API ML sample extension. It only contains a simple controller for testing.
The extension is added to the API Gateway class path. Therefore, as a result, the controller is added in the context
of the API Gateway without starting a new service.

## Usage

If the extension is correctly added to the API Gateway classpath, it will be possible to
call the REST endpoint defined in the controller via Gateway.
The extension is scanned and added to the classpath during the Zowe instance preparation, therefore
once the Gateway is started, you can:

1. Call the `https://<hostname>:<gatewayPort>/api/v1/greeting` endpoint though Gateway
2. Verify that you get the message `Hello, I'm a sample extension!` as response
44 changes: 44 additions & 0 deletions apiml-sample-extension/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
buildscript {
repositories mavenRepositories
dependencies {
classpath("gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:${gradleGitPropertiesVersion}")
classpath ("org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r") {
force = true
}
}
}

normalization {
runtimeClasspath {
ignore("**/*git.properties*")
ignore("**/*build-info.properties*")
}
}

apply plugin: 'com.gorylenko.gradle-git-properties'

gitProperties {
gitPropertiesDir = new File("${project.rootDir}/${name}/build/resources/main/META-INF")
}

dependencies {

implementation libraries.springFox
implementation libraries.spring_webmvc

}

jar {
enabled true
baseName = "apiml-sample-extension"
archiveName = "${baseName}.jar"
}

publishing {
publications {
mavenJavaLib(MavenPublication) {
artifact jar
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*/
package org.zowe.apiml.gateway.api;

import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

/**
* Controller that returns greetings.
*/
@RestController
@Api(tags = {"Other Operations"})
@RequestMapping("/api/v1")
public class GreetingController {
private static final String GREETING = "Hello, I'm a sample extension!";

/**
* Gets a greeting for anyone.
*/
@GetMapping(value = "/greeting")
public String greeting() {
return GREETING;
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ subprojects {
}

task buildCore(dependsOn: [':gateway-service:build', ':discovery-service:build', ':api-catalog-services:build', ':api-catalog-ui:build',
taban03 marked this conversation as resolved.
Show resolved Hide resolved
':discoverable-client:build', ':zaas-client:build']) {
':discoverable-client:build', ':zaas-client:build', ':apiml-sample-extension:build']) {
description "Build core components"
group "build"
}
Expand Down
3 changes: 2 additions & 1 deletion gradle/license.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ ext.projectsNeedLicense = [
'onboarding-enabler-nodejs',
'zaas-client',
'mock-services',
'apiml-tomcat-common'
'apiml-tomcat-common',
'apiml-sample-extension'
]

configure(subprojects.findAll { it.name in projectsNeedLicense }) {
Expand Down
5 changes: 3 additions & 2 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ ext.javaLibraries = [
'zaas-client',
'discoverable-client',
'certificate-analyser',
'apiml-tomcat-common'
'apiml-tomcat-common',
'apiml-sample-extension'
]

ext.serviceJars = ['api-catalog-package', 'discovery-package', 'gateway-package', 'caching-service-package', 'metrics-service-package', 'apiml-common-lib-package']
ext.serviceJars = ['api-catalog-package', 'discovery-package', 'gateway-package', 'caching-service-package', 'metrics-service-package', 'apiml-common-lib-package', 'apiml-sample-extension-package']

ext.enablers = [ext.javaEnabler, ext.springBootEnabler, ext.micronautEnabler]
ext.projectsToPublish = ext.serviceJars + ext.javaLibraries + ext.enablers
Expand Down
14 changes: 14 additions & 0 deletions gradle/sonar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ project(":apiml-common-lib-package") {
}
}

// Packaging project; sonar does not apply
balhar-jakub marked this conversation as resolved.
Show resolved Hide resolved
project(":apiml-sample-extension-package") {
sonarqube {
skipProject = true
}
}

// Packaging project; sonar does not apply
project(":apiml-sample-extension") {
sonarqube {
skipProject = true
}
}

// Packaging project; sonar does not apply
project(":mock-services") {
sonarqube {
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ include 'metrics-service-ui'
include 'metrics-service-package'
include 'apiml-tomcat-common'
include 'onboarding-enabler-java-sample-app-plain-java'
include 'apiml-sample-extension'
include 'apiml-sample-extension-package'