-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Oh
committed
Sep 15, 2019
1 parent
b2f7c70
commit 59785f5
Showing
5,241 changed files
with
1,422,949 additions
and
5 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Intro | ||
|
||
This is a Spring Boot microservice that represents catalog information in a retail store. It uses the Fabric8 Maven Plugin to deploy to OpenShift. | ||
|
||
# Running on OpenShift | ||
|
||
You'll need to have access to an OpenShift cluster and the `oc` command line interface. | ||
|
||
1. Login to OpenShift and create a new project | ||
|
||
``` | ||
oc login | ||
oc new-project demo | ||
``` | ||
|
||
1. This demo requires a PostgreSQL database. Create one by using the following command: | ||
|
||
``` | ||
oc new-app -e POSTGRESQL_USER=catalog \ | ||
-e POSTGRESQL_PASSWORD=mysecretpassword \ | ||
-e POSTGRESQL_DATABASE=catalog \ | ||
openshift/postgresql:9.4 \ | ||
--name=catalog-database | ||
``` | ||
> **NOTE:** If you change the username and password you also need to update `src/main/fabric8/credential-secret.yml`. | ||
> **NOTE:** If you change the database or application name app you also need update `src/main/resources/application.properties` as well. | ||
2. Use the Fabric8 Maven Plugin to launch the S2I process on the OpenShift Online machine & start the pod. | ||
|
||
``` | ||
mvn clean fabric8:deploy -Popenshift -DskipTests | ||
``` | ||
|
||
This will build and deploy the microservice along with a Postgres database. | ||
|
||
3. To test the service using curl: | ||
|
||
``` | ||
curl http://catalog-<project>.<domain>/api/catalog | ||
``` | ||
For example: | ||
|
||
``` | ||
% curl http://catalog-lab5.apps.127.0.0.1.nip.io/api/catalog | ||
[{"itemId":"329299","name":"Red Fedora","desc":"Official Red Hat Fedora","price":34.99},{"itemId":"329199","name":"Forge Laptop Sticker","desc":"JBoss Community Forge Project Sticker","price":8.5},{"itemId":"165613","name":"Solid Performance Polo","desc":"Moisture-wicking, antimicrobial 100% polyester design wicks for life of garment. No-curl, rib-knit collar; special collar band maintains crisp fold; three-button placket with dyed-to-match buttons; hemmed sleeves; even bottom with side vents; Import. Embroidery. Red Pepper.","price":17.8},{"itemId":"165614","name":"Ogio Caliber Polo","desc":"Moisture-wicking 100% polyester. Rib-knit collar and cuffs; Ogio jacquard tape inside neck; bar-tacked three-button placket with Ogio dyed-to-match buttons; side vents; tagless; Ogio badge on left sleeve. Import. Embroidery. Black.","price":28.75},{"itemId":"165954","name":"16 oz. Vortex Tumbler","desc":"Double-wall insulated, BPA-free, acrylic cup. Push-on lid with thumb-slide closure; for hot and cold beverages. Holds 16 oz. Hand wash only. Imprint. Clear.","price":6.0},{"itemId":"444434","name":"Pebble Smart Watch","desc":"Smart glasses and smart watches are perhaps two of the most exciting developments in recent years.","price":24.0},{"itemId":"444435","name":"Oculus Rift","desc":"The world of gaming has also undergone some very unique and compelling tech advances in recent years. Virtual reality, the concept of complete immersion into a digital universe through a special headset, has been the white whale of gaming and digital technology ever since Geekstakes Oculus Rift GiveawayNintendo marketed its Virtual Boy gaming system in 1995.Lytro","price":106.0},{"itemId":"444436","name":"Lytro Camera","desc":"Consumers who want to up their photography game are looking at newfangled cameras like the Lytro Field camera, designed to take photos with infinite focus, so you can decide later exactly where you want the focus of each image to be.","price":44.3}] | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.redhat.coolstore</groupId> | ||
<artifactId>catalog</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>catalog</name> | ||
<description>Rest JDBC SpringBoot Coolstore Catalog App</description> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
<fabric8-maven-plugin.version>3.5.41</fabric8-maven-plugin.version> | ||
<spring-boot.bom.version>1.5.8.Final</spring-boot.bom.version> | ||
<postgresql.version>10</postgresql.version> | ||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version> | ||
<netflix.feign.version>8.15.1</netflix.feign.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>me.snowdrop</groupId> | ||
<artifactId>spring-boot-bom</artifactId> | ||
<version>${spring-boot.bom.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.xml.bind</groupId> | ||
<artifactId>jaxb-api</artifactId> | ||
<version>2.2.11</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sun.xml.bind</groupId> | ||
<artifactId>jaxb-core</artifactId> | ||
<version>2.2.11</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sun.xml.bind</groupId> | ||
<artifactId>jaxb-impl</artifactId> | ||
<version>2.2.11</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.activation</groupId> | ||
<artifactId>activation</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.json</groupId> | ||
<artifactId>json</artifactId> | ||
<version>20180813</version> | ||
</dependency> | ||
|
||
<!-- TODO: Add web (tomcat) dependency here --> | ||
|
||
<!-- TODO: Add data jpa dependency here --> | ||
|
||
<!-- TODO: Add actuator, feign and hystrix dependency here --> | ||
|
||
<!-- Testing --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.specto</groupId> | ||
<artifactId>hoverfly-java</artifactId> | ||
<version>0.9.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>3.8.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>fabric8-maven-plugin</artifactId> | ||
<version>${fabric8-maven-plugin.version}</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<resources> | ||
<resource> | ||
<directory>src/main/fabric8</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>local</id> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> |
14 changes: 14 additions & 0 deletions
14
m1/catalog/src/main/java/com/redhat/coolstore/RestApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.redhat.coolstore; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.netflix.feign.EnableFeignClients; | ||
|
||
@SpringBootApplication | ||
@EnableFeignClients | ||
public class RestApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(RestApplication.class, args); | ||
} | ||
} |
Empty file.
Empty file.
70 changes: 70 additions & 0 deletions
70
m1/catalog/src/main/java/com/redhat/coolstore/model/Inventory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.redhat.coolstore.model; | ||
|
||
import java.io.Serializable; | ||
|
||
public class Inventory implements Serializable { | ||
|
||
private static final long serialVersionUID = 7131670354907280071L; | ||
|
||
private String itemId; | ||
private String location; | ||
private int quantity; | ||
private String link; | ||
|
||
public Inventory() { | ||
} | ||
|
||
public Inventory(String itemId, String location, int quantity, String link) { | ||
this.itemId = itemId; | ||
this.location = location; | ||
this.quantity = quantity; | ||
this.link = link; | ||
} | ||
|
||
public Inventory(String itemId, int quantity) { | ||
this.itemId = itemId; | ||
this.quantity = quantity; | ||
} | ||
|
||
public String getItemId() { | ||
return itemId; | ||
} | ||
|
||
public void setItemId(String itemId) { | ||
this.itemId = itemId; | ||
} | ||
|
||
public String getLocation() { | ||
return location; | ||
} | ||
|
||
public void setLocation(String location) { | ||
this.location = location; | ||
} | ||
|
||
public int getQuantity() { | ||
return quantity; | ||
} | ||
|
||
public void setQuantity(int quantity) { | ||
this.quantity = quantity; | ||
} | ||
|
||
public String getLink() { | ||
return link; | ||
} | ||
|
||
public void setLink(String link) { | ||
this.link = link; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Inventory{" + | ||
"itemId='" + itemId + '\'' + | ||
", location='" + location + '\'' + | ||
", quantity=" + quantity + | ||
", link='" + link + '\'' + | ||
'}'; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
m1/catalog/src/main/java/com/redhat/coolstore/model/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.redhat.coolstore.model; | ||
|
||
import java.io.Serializable; | ||
|
||
public class Product implements Serializable { | ||
|
||
private static final long serialVersionUID = -7304814269819778382L; | ||
private String itemId; | ||
private String name; | ||
private String desc; | ||
private double price; | ||
private int quantity; | ||
|
||
public Product() { | ||
|
||
} | ||
|
||
public Product(String itemId, String name, String desc, double price) { | ||
super(); | ||
this.itemId = itemId; | ||
this.name = name; | ||
this.desc = desc; | ||
this.price = price; | ||
} | ||
public String getItemId() { | ||
return itemId; | ||
} | ||
public void setItemId(String itemId) { | ||
this.itemId = itemId; | ||
} | ||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public String getDesc() { | ||
return desc; | ||
} | ||
public void setDesc(String desc) { | ||
this.desc = desc; | ||
} | ||
public double getPrice() { | ||
return price; | ||
} | ||
public void setPrice(double price) { | ||
this.price = price; | ||
} | ||
public int getQuantity() { | ||
return quantity; | ||
} | ||
public void setQuantity(int quantity) { | ||
this.quantity = quantity; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Product [itemId=" + itemId + ", name=" + name + ", desc=" | ||
+ desc + ", price=" + price + ", quantity=" + quantity + "]"; | ||
} | ||
|
||
|
||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Tomcat port - To avoid port conflict we set this to 8081 in the local environment | ||
server.port=8081 | ||
|
||
#TODO: Add database properties | ||
#TODO: Configure netflix libraries | ||
#TODO: Set timeout to for inventory to 500ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
DROP TABLE IF EXISTS catalog; | ||
|
||
CREATE TABLE catalog ( | ||
itemId VARCHAR(256) NOT NULL PRIMARY KEY, | ||
name VARCHAR(256), | ||
description VARCHAR(2560), | ||
price DOUBLE PRECISION | ||
); | ||
|
||
|
||
insert into catalog (itemId, name, description, price) values ('329299', 'Red Fedora', 'Official Red Hat Fedora', 34.99); | ||
insert into catalog (itemId, name, description, price) values ('329199', 'Forge Laptop Sticker', 'JBoss Community Forge Project Sticker', 8.50); | ||
insert into catalog (itemId, name, description, price) values ('165613', 'Solid Performance Polo', 'Moisture-wicking, antimicrobial 100% polyester design wicks for life of garment. No-curl, rib-knit collar; special collar band maintains crisp fold; three-button placket with dyed-to-match buttons; hemmed sleeves; even bottom with side vents; Import. Embroidery. Red Pepper.',17.80); | ||
insert into catalog (itemId, name, description, price) values ('165614', 'Ogio Caliber Polo', 'Moisture-wicking 100% polyester. Rib-knit collar and cuffs; Ogio jacquard tape inside neck; bar-tacked three-button placket with Ogio dyed-to-match buttons; side vents; tagless; Ogio badge on left sleeve. Import. Embroidery. Black.', 28.75); | ||
insert into catalog (itemId, name, description, price) values ('165954', '16 oz. Vortex Tumbler', 'Double-wall insulated, BPA-free, acrylic cup. Push-on lid with thumb-slide closure; for hot and cold beverages. Holds 16 oz. Hand wash only. Imprint. Clear.', 6.00); | ||
insert into catalog (itemId, name, description, price) values ('444434', 'Pebble Smart Watch', 'Smart glasses and smart watches are perhaps two of the most exciting developments in recent years.', 24.00); | ||
insert into catalog (itemId, name, description, price) values ('444435', 'Oculus Rift', 'The world of gaming has also undergone some very unique and compelling tech advances in recent years. Virtual reality, the concept of complete immersion into a digital universe through a special headset, has been the white whale of gaming and digital technology ever since Geekstakes Oculus Rift GiveawayNintendo marketed its Virtual Boy gaming system in 1995.Lytro',106.00 ); | ||
insert into catalog (itemId, name, description, price) values ('444436', 'Lytro Camera', 'Consumers who want to up their photography game are looking at newfangled cameras like the Lytro Field camera, designed to take photos with infinite focus, so you can decide later exactly where you want the focus of each image to be.', 44.30); | ||
|
Oops, something went wrong.