aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKanagaraj Manickam <kanagaraj.manickam@huawei.com>2017-09-11 03:53:57 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-11 03:53:57 +0000
commitdf53002120bca73d475c38862586296db3526444 (patch)
tree8bc2ac75e46154e7c2f4648d5d22530bdb795112
parentaed32c570a103c70456371179a410e45d2f42bf3 (diff)
parent7293d08fcfecc5c66310303a8351f9efd219247e (diff)
Merge changes Ic267f3f4,I1347393e
* changes: Add CLI_DEV Base docker image to openjdk:8-jre-slim
-rw-r--r--deployment/docker/pom.xml13
-rw-r--r--deployment/docker/src/main/docker/Dockerfile47
-rw-r--r--deployment/docker/src/main/docker/docker-compose.yaml11
-rw-r--r--framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java11
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/Constants.java4
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java3
-rw-r--r--framework/src/test/resources/short-options.txt1
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java2
-rw-r--r--main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java8
9 files changed, 75 insertions, 25 deletions
diff --git a/deployment/docker/pom.xml b/deployment/docker/pom.xml
index e0056ecb..e18d6244 100644
--- a/deployment/docker/pom.xml
+++ b/deployment/docker/pom.xml
@@ -99,6 +99,19 @@
</configuration>
</execution>
<execution>
+ <id>tag-image-project-version</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <image>${docker.image.name}</image>
+ <newName>${docker.push.registry}/${docker.image.name}:${project.version}</newName>
+ <pushImage>${skip.docker.push}</pushImage>
+ <skipDockerTag>${skip.docker.tag}</skipDockerTag>
+ </configuration>
+ </execution>
+ <execution>
<id>tag-image-latest-version</id>
<phase>deploy</phase>
<goals>
diff --git a/deployment/docker/src/main/docker/Dockerfile b/deployment/docker/src/main/docker/Dockerfile
index 61ecd505..e333370c 100644
--- a/deployment/docker/src/main/docker/Dockerfile
+++ b/deployment/docker/src/main/docker/Dockerfile
@@ -1,15 +1,15 @@
-FROM ubuntu:14.04
-
-#installation
-RUN apt-get update
-RUN apt-get update && apt-get install -y software-properties-common
-RUN sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk && apt-get install -y lighttpd && apt-get install -y git curl && apt-get install -y pandoc
-RUN cd /tmp && curl -O https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz && tar -xvf go1.9.linux-amd64.tar.gz
-RUN mkdir -p /tmp/gotty && \
- GOPATH=/tmp/gotty /tmp/go/bin/go get github.com/yudai/gotty && \
- mv /tmp/gotty/bin/gotty /usr/sbin/ && rm /tmp/go1.9.linux-amd64.tar.gz && rm -rf /tmp/go /tmp/gotty && cd -
-
-ENV JAVA_HOME usr/lib/jvm/java-8-openjdk-amd64
+FROM openjdk:8-jre-slim
+
+#Setup default software
+RUN apt-get update && apt-get install -y lighttpd git curl pandoc vim
+
+#Setup gotty
+RUN cd /tmp && curl -O https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz && \
+ tar -xvf go1.9.linux-amd64.tar.gz && mkdir -p /tmp/gotty && \
+ GOPATH=/tmp/gotty /tmp/go/bin/go get github.com/yudai/gotty && \
+ mv /tmp/gotty/bin/gotty /usr/sbin/
+
+#Environments
ENV ONAP_CLI_HOME /opt/onap/cli
ENV ONAP_CLI_DEBUG false
ENV ONAP_CLI_DEBUG_PORT 5005
@@ -20,31 +20,38 @@ ENV ONAP_HOST_URL http://localhost:8080
ENV ONAP_USERNAME guest
ENV ONAP_PASSWORD guest
+#Copy CLI into docker
ADD ./STAGE $ONAP_CLI_HOME
WORKDIR $ONAP_CLI_HOME
-RUN chmod +x ./bin/onap.sh
-RUN ln ./bin/onap.sh /usr/sbin/onap
-RUN if [ ! -d ./data ]; then mkdir ./data; fi
-RUN if [ ! -d ./onap-cli-schema ]; then mkdir ./onap-cli-schema; fi
+#Setup the run time environment (RTE)
+#RTE: CLI
+RUN chmod +x ./bin/onap.sh && \
+ ln ./bin/onap.sh /usr/sbin/onap && \
+ if [ ! -d ./data ]; then mkdir ./data; fi && \
+ if [ ! -d ./onap-cli-schema ]; then mkdir ./onap-cli-schema; fi
+#Create the readable README
RUN pandoc -t plain $ONAP_CLI_HOME/docs/README.md > $ONAP_CLI_HOME/docs/onap-readme.txt
+#RTE: lighttpd
COPY ./STAGE/http/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf
COPY ./STAGE/http/web /var/www-data/servers/onap-cli/
-
+COPY ./STAGE/http/lighttpd/10-proxy.conf /etc/lighttpd/conf-enabled/
COPY ./STAGE/installer/cli-*.zip /var/www-data/servers/onap-cli/onap-cli.zip
RUN if [ ! -f /var/log/lighttpd/access.log ]; then touch /var/log/lighttpd/access.log; fi
-COPY ./STAGE/http/lighttpd/10-proxy.conf /etc/lighttpd/conf-enabled/
RUN cp /etc/lighttpd/conf-available/10-accesslog.conf /etc/lighttpd/conf-enabled/
-#Lighttpd
EXPOSE 80
-#gotty
+#RTE: gotty
EXPOSE 8080
+#Start
ENTRYPOINT if [ "$CLI_MODE" = "daemon" ]; then service lighttpd start; gotty --permit-write --reconnect onap; else onap -v && /bin/bash; fi
+#Cleanup
+RUN apt-get purge -y pandoc && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/go /tmp/gotty /tmp/* /var/tmp/*
+
RUN echo ONAP CLI docker successfully created !! \ No newline at end of file
diff --git a/deployment/docker/src/main/docker/docker-compose.yaml b/deployment/docker/src/main/docker/docker-compose.yaml
index c486fe9c..c2c32cb9 100644
--- a/deployment/docker/src/main/docker/docker-compose.yaml
+++ b/deployment/docker/src/main/docker/docker-compose.yaml
@@ -1,7 +1,6 @@
version: '2.0'
services:
-
occ:
image: onap/cli
environment:
@@ -19,3 +18,13 @@ services:
image: onap/cli
environment:
CLI_MODE: 'console'
+
+ dev:
+ stdin_open: true
+ tty: true
+ image: onap/cli
+ environment:
+ CLI_DEV: "true"
+ CLI_MODE: 'console'
+ ports:
+ - 5005:5005
diff --git a/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java b/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java
index 019eb824..01d4742e 100644
--- a/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java
+++ b/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java
@@ -58,6 +58,8 @@ public class OnapCommandRegistrar {
private boolean isInteractiveMode = false;
+ private boolean isDevMode = Boolean.getBoolean(System.getenv(Constants.CLI_DEV_MODE));
+
private OnapCommandParameterCache paramCache = new OnapCommandParameterCache();
public boolean isInteractiveMode() {
@@ -80,6 +82,15 @@ public class OnapCommandRegistrar {
paramCache.remove(this.getEnabledProductVersion(), paramName);
}
+ public boolean isDevMode() {
+ return isDevMode;
+ }
+
+ public void setDevMode(boolean isDevMode) {
+ this.isDevMode = isDevMode;
+ }
+
+
private static OnapCommandRegistrar registrar = null;
/**
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
index 23dfbbbe..d7e277c7 100644
--- a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
+++ b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
@@ -195,8 +195,12 @@ public class Constants {
public static final String USE_DIRECTIVE = "use";
public static final String PARAM_CACHE_FILE_NAME = "cli.parameter.cache.file";
+
+ public static final String CLI_DEV_MODE = "CLI_DEV";
+
private Constants() {
}
}
+
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
index b31b75cf..ec735cfb 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
@@ -21,6 +21,7 @@ import com.jayway.jsonpath.JsonPath;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import org.onap.cli.fw.OnapCommand;
+import org.onap.cli.fw.OnapCommandRegistrar;
import org.onap.cli.fw.ad.OnapCredentials;
import org.onap.cli.fw.ad.OnapService;
import org.onap.cli.fw.cmd.OnapHttpCommand;
@@ -1654,7 +1655,7 @@ public class OnapCommandUtils {
*/
public static List<ExternalSchema> loadExternalSchemasFromJson() throws OnapCommandException {
List<ExternalSchema> schemas = new ArrayList<>();
- if (!isJsonFileDiscovered()) {
+ if (OnapCommandRegistrar.getRegistrar().isDevMode() || !isJsonFileDiscovered()) {
schemas = findAllExternalSchemas();
if (!schemas.isEmpty()) {
persist(schemas);
diff --git a/framework/src/test/resources/short-options.txt b/framework/src/test/resources/short-options.txt
new file mode 100644
index 00000000..d5696309
--- /dev/null
+++ b/framework/src/test/resources/short-options.txt
@@ -0,0 +1 @@
+a d f h m p s t u v \ No newline at end of file
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java
index c175f67b..0920f84b 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -19,9 +19,7 @@ package org.onap.cli.main;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.onap.cli.fw.OnapCommand;
diff --git a/main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java b/main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java
index be88aed0..3ab4cceb 100644
--- a/main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java
+++ b/main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java
@@ -261,7 +261,13 @@ public class OnapCliUtils {
private static String readTextStringFromUrl(String input, String argName) throws OnapCliInvalidArgument {
try {
- return FileUtils.readFileToString(new File(input));
+ File file = new File(input);
+ if (file.isFile()) {
+ return FileUtils.readFileToString(file);
+ } else {
+ return input;
+ }
+
} catch (IOException e) {
throw new OnapCliInvalidArgument(argName, e);
}