Skip to content

Commit

Permalink
Initial version copied from ivy-cloud repo
Browse files Browse the repository at this point in the history
  • Loading branch information
weissreto committed Sep 1, 2023
1 parent c165663 commit 565540b
Show file tree
Hide file tree
Showing 33 changed files with 465 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MY-PRODUCT-NAME
# Docker Connector

[![CI Build](https://github.com/axonivy-market/REPO-NAME/actions/workflows/ci.yml/badge.svg)](https://github.com/axonivy-market/REPO-NAME/actions/workflows/ci.yml)
[![CI Build](https://github.com/axonivy-market/docker-connector/actions/workflows/ci.yml/badge.svg)](https://github.com/axonivy-market/docker-connector/actions/workflows/ci.yml)

"YOUR SHORT DESCRIPTION GOES HERE"
Connector to create/start/stop/delete Docker containers

Read our [documentation](MY-PRODUCT-NAME-product/README.md).
Read our [documentation](docker-connector-product/README.md).
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MY-PRODUCT-NAME
# Docker Connector

YOUR DESCRIPTION GOES HERE

Expand All @@ -12,4 +12,4 @@ YOUR SETUP DESCRIPTION GOES HERE

```
@variables.yaml@
```
```
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.axonivy.market</groupId>
<artifactId>MY-PRODUCT-NAME-product</artifactId>
<artifactId>docker-connector-product</artifactId>
<version>10.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<variables.yaml.file>../MY-PRODUCT-NAME/config/variables.yaml</variables.yaml.file>
<variables.yaml.file>../docker-connector/config/variables.yaml</variables.yaml.file>
</properties>

<build>
Expand Down
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions docker-connector/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**/*.ivyClass|**/*.p.json|**/*.rddescriptor|**/*.xhtml" kind="src" path="src_hd">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src_wsproc">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src_dataClasses">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="con" path="IVY_CONTAINER"/>
<classpathentry kind="con" path="WEBAPP_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
19 changes: 19 additions & 0 deletions docker-connector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# general
Thumbs.db
.DS_Store
*~
*.log

# java
*.class
hs_err_pid*

# maven
target/
lib/mvn-deps/

# ivy
classes/
src_dataClasses/
src_wsproc/
logs/
49 changes: 49 additions & 0 deletions docker-connector/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>docker-connector</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>ch.ivyteam.ivy.designer.dataClasses.ui.ivyDataClassBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>ch.ivyteam.ivy.designer.process.ui.ivyWebServiceProcessClassBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>ch.ivyteam.ivy.designer.ide.ivyModelValidationBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>ch.ivyteam.ivy.project.IvyProjectNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions docker-connector/.settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="webContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
5 changes: 5 additions & 0 deletions docker-connector/.settings/ch.ivyteam.ivy.designer.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=docker.connector.Data
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=docker.connector
ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000
eclipse.preferences.version=1
10 changes: 10 additions & 0 deletions docker-connector/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
11 changes: 11 additions & 0 deletions docker-connector/.settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="docker-connector">
<wb-resource deploy-path="/" source-path="/webContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src_hd"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src_wsproc"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src_dataClasses"/>
<property name="context-root" value="docker-connector"/>
<property name="java-output-path" value="/docker-connector/target/classes"/>
</wb-module>
</project-modules>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<root>
<facet id="jst.jsf">
<node name="libprov">
<attribute name="provider-id" value="jsf-user-library-provider"/>
</node>
</facet>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="17"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.jsf" version="2.1"/>
</faceted-project>
2 changes: 2 additions & 0 deletions docker-connector/.settings/org.eclipse.wst.css.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
css-profile/<project>=org.eclipse.wst.css.core.cssprofile.css3
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Window
20 changes: 20 additions & 0 deletions docker-connector/config/custom-fields.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# == Custom Fields Information ==
#
# You can define here your project custom fields.
# Have a look at our documentation for more information.
#
CustomFields:
# Tasks:
# MyTaskCustomField:
# Label: My task custom field
# Description: This new task custom field can be used to ...
# Type: STRING
# Cases:
# MyCaseCustomField:
# Label: My case custom field
# Description: This new case custom field can be used to ...
# Type: STRING
# Starts:
# MyStartCustomField:
# Label: My start custom field
# Description: This new start custom field can be used to ...
1 change: 1 addition & 0 deletions docker-connector/config/databases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Databases:
1 change: 1 addition & 0 deletions docker-connector/config/overrides.any
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
2 changes: 2 additions & 0 deletions docker-connector/config/persistence.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.2" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"/>
1 change: 1 addition & 0 deletions docker-connector/config/rest-clients.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RestClients:
4 changes: 4 additions & 0 deletions docker-connector/config/roles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<role>
<identifier>Everybody</identifier>
</role>
2 changes: 2 additions & 0 deletions docker-connector/config/users.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<userConfig/>
20 changes: 20 additions & 0 deletions docker-connector/config/variables.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# == Variables ==
#
# You can define here your project Variables.
# If you want to define/override a Variable for a specific Environment,
# add an additional ‘variables.yaml’ file in a subdirectory in the ‘Config’ folder:
# '<project>/Config/_<environment>/variables.yaml
#
Variables:
# myVariable: value
Docker:
# URL to communicate with the docker daemon
# Windows Pipe:
# npipe:////./pipe/dockerDesktopLinuxEngine
# Linux:
# unix:///var/run/docker.sock
# TCP (Outside container):
# tcp://localhost:2375
# TCP (Inside a container):
# tcp://host.docker.internal:2375
URL: "tcp://localhost:2375/"
1 change: 1 addition & 0 deletions docker-connector/config/webservice-clients.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WebServiceClients:
2 changes: 2 additions & 0 deletions docker-connector/dataclasses/docker/connector/Data.ivyClass
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Data #class
docker.connector #namespace
31 changes: 31 additions & 0 deletions docker-connector/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.axonivy.market</groupId>
<artifactId>docker-connector</artifactId>
<version>10.0.0-SNAPSHOT</version>
<packaging>iar</packaging>
<build>
<plugins>
<plugin>
<groupId>com.axonivy.ivy.ci</groupId>
<artifactId>project-build-plugin</artifactId>
<version>10.0.6</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
<version>3.3.3</version>
</dependency>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-transport-httpclient5</artifactId>
<version>3.3.3</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.axonivy.connector.docker;

import java.io.Closeable;
import java.io.IOException;

import com.github.dockerjava.api.async.ResultCallback;

abstract class AbstractResultCallback<T> implements ResultCallback<T> {

enum State {
CREATED,
RUNNING,
ERROR,
COMPLETE,

}
private AbstractResultCallback.State state = State.CREATED;
private Closeable closeable;
protected StringBuilder builder = new StringBuilder();
private Throwable error = null;

@Override
public synchronized void close() {
try {
this.closeable.close();
} catch (IOException ex) {
error = ex;
}
}

@Override
public synchronized void onStart(Closeable c) {
this.closeable = c;
this.state = State.RUNNING;
}

@Override
public synchronized void onError(Throwable e) {
this.state = State.ERROR;
this.error = e;
close();
notifyAll();
}

@Override
public synchronized void onComplete() {
this.state = State.COMPLETE;
close();
notifyAll();
}

public synchronized String await() {
while (state == State.RUNNING || state == State.CREATED) {
try {
wait();
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
}
if (error != null) {
if (error instanceof RuntimeException re) {
throw re;
}
throw new RuntimeException(error);
}
return builder.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.axonivy.connector.docker;

import java.nio.charset.StandardCharsets;

import com.github.dockerjava.api.model.Frame;

class ExecuteResultCallback extends AbstractResultCallback<Frame> {

@Override
public synchronized void onNext(Frame frame) {
builder.append(new String(frame.getPayload(), StandardCharsets.UTF_8));
}
}
Loading

0 comments on commit 565540b

Please sign in to comment.