1. Rename mgmt api client
2. Split the spring boot application and the client api resources to 2 projects Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
3
examples/hawkbit-example-mgmt-spring-client/.gitignore
vendored
Normal file
3
examples/hawkbit-example-mgmt-spring-client/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/target/
|
||||
/bin/
|
||||
/.apt_generated/
|
||||
38
examples/hawkbit-example-mgmt-spring-client/README.md
Normal file
38
examples/hawkbit-example-mgmt-spring-client/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# hawkBit Management API example client
|
||||
|
||||
Example client that shows how to efficiently use the hawkBit management API.
|
||||
|
||||
Powered by [Feign](https://github.com/Netflix/feign).
|
||||
|
||||
## How to run the example client
|
||||
|
||||
Run getting started example
|
||||
|
||||
|
||||
|
||||
$ java -jar hawkbit-mgmt-api-client-#version#.jar
|
||||
|
||||
|
||||
Run create and start rollout example
|
||||
|
||||
|
||||
$ java -jar hawkbit-mgmt-api-client-#version#.jar --createrollout
|
||||
|
||||
|
||||
## This example shows
|
||||
|
||||
In getting started example:
|
||||
* creating software modules type
|
||||
* creating distribution set type
|
||||
* creating distribution sets
|
||||
* creating software modules
|
||||
* assigning software modules to distribution sets
|
||||
|
||||
In rollout mode:
|
||||
* creating software modules type
|
||||
* creating distribution set type
|
||||
* creating distribution sets
|
||||
* creating software modules
|
||||
* assigning software modules to distribution sets
|
||||
* creating a rollout
|
||||
* starting a rollout
|
||||
101
examples/hawkbit-example-mgmt-spring-client/pom.xml
Normal file
101
examples/hawkbit-example-mgmt-spring-client/pom.xml
Normal file
@@ -0,0 +1,101 @@
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<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>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>hawkbit-example-mgmt-spring-client</artifactId>
|
||||
<name>hawkBit Management API example client</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${baseDir}</outputDirectory>
|
||||
<addResources>false</addResources>
|
||||
<mainClass>org.eclipse.hawkbit.mgmt.client.Application</mainClass>
|
||||
<layout>JAR</layout>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>1.0.7.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-example-mgmt-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<!-- need to overwrite for the interface inheritance feature of feign-core -->
|
||||
<version>8.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
<version>8.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.5.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<groupId>org.hibernate</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-feign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client;
|
||||
|
||||
import org.eclipse.hawkbit.feign.core.client.FeignClientConfiguration;
|
||||
import org.eclipse.hawkbit.mgmt.client.scenarios.CreateStartedRolloutExample;
|
||||
import org.eclipse.hawkbit.mgmt.client.scenarios.GettingStartedDefaultScenario;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
@EnableConfigurationProperties(ClientConfigurationProperties.class)
|
||||
@Configuration
|
||||
@AutoConfigureAfter(FeignClientConfiguration.class)
|
||||
@Import(FeignClientConfiguration.class)
|
||||
public class Application implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private ClientConfigurationProperties configuration;
|
||||
|
||||
@Autowired
|
||||
private GettingStartedDefaultScenario gettingStarted;
|
||||
|
||||
@Autowired
|
||||
private CreateStartedRolloutExample gettingStartedRolloutScenario;
|
||||
|
||||
public static void main(final String[] args) {
|
||||
new SpringApplicationBuilder().showBanner(false).sources(Application.class).run(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final String... args) throws Exception {
|
||||
if (containsArg("--createrollout", args)) {
|
||||
// run the create and start rollout example
|
||||
gettingStartedRolloutScenario.run();
|
||||
} else {
|
||||
// run the getting started scenario which creates a setup of
|
||||
// distribution set and software modules to be used
|
||||
gettingStarted.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
|
||||
return new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GettingStartedDefaultScenario gettingStartedDefaultScenario() {
|
||||
return new GettingStartedDefaultScenario();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CreateStartedRolloutExample createStartedRolloutExample() {
|
||||
return new CreateStartedRolloutExample();
|
||||
}
|
||||
|
||||
private boolean containsArg(final String containsArg, final String... args) {
|
||||
for (final String arg : args) {
|
||||
if (arg.equalsIgnoreCase(containsArg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Configuration bean which holds the configuration of the client e.g. the base
|
||||
* URL of the hawkbit-server and the credentials to use the RESTful Management
|
||||
* API.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "hawkbit")
|
||||
public class ClientConfigurationProperties {
|
||||
|
||||
/**
|
||||
* Update server URI.
|
||||
*/
|
||||
private String url = "localhost:8080";
|
||||
|
||||
/**
|
||||
* Update server user name.
|
||||
*/
|
||||
private String username = "admin";
|
||||
|
||||
/**
|
||||
* Update server password.
|
||||
*/
|
||||
private String password = "admin"; // NOSONAR this password is only used for
|
||||
// examples
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(final String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(final String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
|
||||
hawkbit.url=localhost:8080
|
||||
hawkbit.username=admin
|
||||
hawkbit.password=admin
|
||||
|
||||
spring.main.show-banner=false
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- Log message format -->
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="org.eclipse.hawkbit" level="info" />
|
||||
|
||||
<root level="error">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user