http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/BuildWatcher.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/BuildWatcher.java b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/BuildWatcher.java new file mode 100644 index 0000000..5fb1cf4 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/BuildWatcher.java @@ -0,0 +1,121 @@ +/** + * + * 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. + */ +package io.fabric8.kubernetes.api.builds; + +import io.fabric8.kubernetes.api.KubernetesClient; +import io.fabric8.openshift.api.model.Build; +import io.fabric8.openshift.api.model.BuildList; +import io.fabric8.utils.Strings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; + +/** + */ +public class BuildWatcher { + private static final transient Logger LOG = LoggerFactory.getLogger(BuildWatcher.class); + + private final KubernetesClient kubernetes; + private final BuildListener buildListener; + private final String namespace; + private final String fabric8ConsoleLink; + private boolean loading = true; + private Set<String> seenBuildIds = Collections.<String>synchronizedSet(new HashSet<String>()); + + public BuildWatcher(KubernetesClient kubernetes, BuildListener buildListener, String namespace, String fabric8ConsoleLink) { + this.kubernetes = kubernetes; + this.buildListener = buildListener; + this.namespace = namespace; + this.fabric8ConsoleLink = fabric8ConsoleLink; + } + + + public TimerTask schedule(long delay) { + Timer timer = new Timer(); + return schedule(timer, delay); + } + + public TimerTask schedule(Timer timer, long delay) { + TimerTask task = new TimerTask() { + @Override + public void run() { + poll(); + } + }; + timer.schedule(task, delay, delay); + return task; + } + + public void poll() { + boolean foundBuild = false; + BuildList buildList = kubernetes.getBuilds(namespace); + if (buildList != null) { + List<Build> items = buildList.getItems(); + if (items != null) { + for (Build build : items) { + buildPolled(build); + foundBuild = true; + } + } + } + if (foundBuild) { + loading = false; + } + } + + protected void buildPolled(Build build) { + String status = build.getStatus().getPhase(); + if (status != null) { + if (Builds.isFinished(status)) { + String uid = Builds.getUid(build); + if (Strings.isNullOrBlank(uid)) { + LOG.warn("Ignoring bad build which has no UID: " + build); + } else { + if (seenBuildIds.add(uid)) { + String name = Builds.getName(build); + String buildLink = Builds.createConsoleBuildLink(this.fabric8ConsoleLink, name); + BuildFinishedEvent event = new BuildFinishedEvent(uid, build, loading, buildLink); + buildListener.onBuildFinished(event); + } + } + } + } + } + + /** + * Waits until this watcher is finished (which by default is forever) + */ + public void join() { + Object lock = new Object(); + while (true) { + synchronized(lock) { + try { + lock.wait(); + } catch (InterruptedException e) { + // ignore + } + } + } + } +}
http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/Builds.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/Builds.java b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/Builds.java new file mode 100644 index 0000000..61f7330 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/Builds.java @@ -0,0 +1,199 @@ +/** + * + * 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. + */ +package io.fabric8.kubernetes.api.builds; + +import io.fabric8.kubernetes.api.KubernetesHelper; +import io.fabric8.openshift.api.model.Build; +import io.fabric8.openshift.api.model.BuildConfig; +import io.fabric8.utils.Objects; +import io.fabric8.utils.Strings; +import io.fabric8.utils.URLUtils; + +import java.util.Collections; +import java.util.Date; +import java.util.Map; + +/** + */ +public class Builds { + + public static class Status { + public static final String COMPLETE = "Complete"; + public static final String FAIL = "Fail"; + public static final String ERROR = "Error"; + public static final String CANCELLED = "Cancelled"; + } + + public static boolean isCompleted(String status) { + return Objects.equal(Status.COMPLETE, status); + } + + public static boolean isCancelled(String status) { + return Objects.equal(Status.CANCELLED, status); + } + + public static boolean isFailed(String status) { + if (status != null) { + return status.startsWith(Status.FAIL) || status.startsWith(Status.ERROR); + } + return false; + } + + public static boolean isFinished(String status) { + return isCompleted(status) || isFailed(status) || isCancelled(status); + } + + /** + * Returns a unique UUID for a build + */ + public static String getUid(Build build) { + String answer = null; + if (build != null) { + answer = build.getMetadata().getUid(); + if (Strings.isNullOrBlank(answer)) { + Map<String, Object> metadata = getMetadata(build); + answer = getString(metadata, "uid"); + if (Strings.isNullOrBlank(answer)) { + answer = getString(metadata, "id"); + } + if (Strings.isNullOrBlank(answer)) { + answer = getString(metadata, "name"); + } + } + if (Strings.isNullOrBlank(answer)) { + answer = build.getMetadata().getName(); + } + } + return answer; + } + + protected static String getString(Map<String, Object> metadata, String name) { + Object answer = metadata.get(name); + if (answer != null) { + return answer.toString(); + } + return null; + } + + public static Map<String, Object> getMetadata(Build build) { + if (build != null) { + Map<String, Object> additionalProperties = build.getAdditionalProperties(); + if (additionalProperties != null) { + Object metadata = additionalProperties.get("metadata"); + if (metadata instanceof Map) { + return (Map<String, Object>) metadata; + } + } + } + return Collections.EMPTY_MAP; + + } + + public static Map<String, Object> getMetadata(BuildConfig build) { + if (build != null) { + Map<String, Object> additionalProperties = build.getAdditionalProperties(); + if (additionalProperties != null) { + Object metadata = additionalProperties.get("metadata"); + if (metadata instanceof Map) { + return (Map<String, Object>) metadata; + } + } + } + return Collections.EMPTY_MAP; + + } + + public static String getName(BuildConfig build) { + String answer = null; + if (build != null) { + Map<String, Object> metadata = getMetadata(build); + answer = getString(metadata, "name"); + if (Strings.isNullOrBlank(answer)) { + answer = build.getMetadata().getName(); + } + } + return answer; + } + + public static String getName(Build build) { + String answer = null; + if (build != null) { + Map<String, Object> metadata = getMetadata(build); + answer = getString(metadata, "name"); + if (Strings.isNullOrBlank(answer)) { + answer = build.getMetadata().getName(); + } + } + return answer; + } + + public static String getNamespace(Build build) { + String answer = null; + if (build != null) { + Map<String, Object> metadata = getMetadata(build); + answer = getString(metadata, "namespace"); + if (Strings.isNullOrBlank(answer)) { + answer = build.getMetadata().getNamespace(); + } + } + return answer; + } + + + public static String getCreationTimestamp(Build build) { + String answer = null; + if (build != null) { + Map<String, Object> metadata = getMetadata(build); + answer = getString(metadata, "creationTimestamp"); + if (Strings.isNullOrBlank(answer)) { + answer = build.getMetadata().getCreationTimestamp(); + } + } + return answer; + } + + public static Date getCreationTimestampDate(Build build) { + String text = getCreationTimestamp(build); + if (Strings.isNullOrBlank(text)) { + return null; + } else { + return KubernetesHelper.parseDate(text); + } + } + + + public static String getBuildConfigName(Build build) { + if (build != null) { + Map<String, Object> metadata = getMetadata(build); + Object labels = metadata.get("labels"); + if (labels instanceof Map) { + Map<String,Object> labelMap = (Map<String,Object>) labels; + return getString(labelMap, "buildconfig"); + } + } + return null; + } + + /** + * Returns the link to the build page in the console for the given build UUID + */ + public static String createConsoleBuildLink(String fabricConsoleExternalUrl, String buildName) { + return URLUtils.pathJoin(fabricConsoleExternalUrl, "kubernetes/builds", buildName); + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/Links.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/Links.java b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/Links.java new file mode 100644 index 0000000..b7b544d --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/builds/Links.java @@ -0,0 +1,35 @@ +/** + * + * 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. + */ +package io.fabric8.kubernetes.api.builds; + +import io.fabric8.utils.Strings; + +/** + */ +public class Links { + + private static final String DEFAULT_FABRIC8_CONSOLE = "http://fabric8.local/"; + + public static String getFabric8ConsoleLink() { + String answer = System.getenv("FABRIC8_CONSOLE"); + if (Strings.isNullOrBlank(answer)) { + answer = DEFAULT_FABRIC8_CONSOLE; + } + return answer; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/extensions/Configs.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/extensions/Configs.java b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/extensions/Configs.java new file mode 100644 index 0000000..11ce41c --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/extensions/Configs.java @@ -0,0 +1,117 @@ +/** + * 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 + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * 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. + */ +package io.fabric8.kubernetes.api.extensions; + +import io.fabric8.kubernetes.api.model.config.AuthInfo; +import io.fabric8.kubernetes.api.model.config.Config; +import io.fabric8.kubernetes.api.KubernetesHelper; +import io.fabric8.kubernetes.api.model.config.Context; +import io.fabric8.kubernetes.api.model.config.NamedAuthInfo; +import io.fabric8.kubernetes.api.model.config.NamedContext; +import io.fabric8.utils.Objects; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +/** + * Helper class for working with the YAML config file thats located in + * <code>~/.config/openshift/config</code> which is updated when you use commands + * like <code>osc login</code> and <code>osc project myproject</code> + */ +public class Configs { + public static final String OPENSHIFT_CONFIG_FILE_PROPERTY = "openshift.config.file"; + public static final String OPENSHIFT_CONFIG_FILE_ENV_VAR = "OPENSHIFTCONFIG"; + private static final transient Logger LOG = LoggerFactory.getLogger(Configs.class); + + public static Config parseConfigs() { + File file = getOpenShiftConfigFile(); + if (file.exists() && file.isFile()) { + try { + return KubernetesHelper.loadYaml(file, Config.class); + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } + + /** + * Returns the current context in the given config + */ + public static Context getCurrentContext(Config config) { + String contextName = config.getCurrentContext(); + if (contextName != null) { + List<NamedContext> contexts = config.getContexts(); + if (contexts != null) { + for (NamedContext context : contexts) { + if (Objects.equal(contextName, context.getName())) { + return context.getContext(); + } + } + } + } + return null; + } + + /** + * Returns the current user token for the config and current context + */ + public static String getUserToken(Config config, Context context) { + AuthInfo authInfo = getUserAuthInfo(config, context); + if (authInfo != null) { + return authInfo.getToken(); + } + return null; + } + + /** + * Returns the current {@link AuthInfo} for the current context and user + */ + public static AuthInfo getUserAuthInfo(Config config, Context context) { + AuthInfo authInfo = null; + if (config != null && context != null) { + String user = context.getUser(); + if (user != null) { + List<NamedAuthInfo> users = config.getUsers(); + if (users != null) { + for (NamedAuthInfo namedAuthInfo : users) { + if (Objects.equal(user, namedAuthInfo.getName())) { + authInfo = namedAuthInfo.getUser(); + } + } + } + } + } + return authInfo; + } + + public static File getOpenShiftConfigFile() { + String file = System.getProperty(OPENSHIFT_CONFIG_FILE_PROPERTY); + if (file != null) { + return new File(file); + } + file = System.getenv(OPENSHIFT_CONFIG_FILE_ENV_VAR); + if (file != null) { + return new File(file); + } + String homeDir = System.getProperty("user.home", "."); + return new File(homeDir, ".config/openshift/config"); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/extensions/Templates.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/extensions/Templates.java b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/extensions/Templates.java new file mode 100644 index 0000000..7ecce66 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/extensions/Templates.java @@ -0,0 +1,225 @@ +/** + * 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 + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * 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. + */ +package io.fabric8.kubernetes.api.extensions; + +import io.fabric8.kubernetes.api.KubernetesHelper; +import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.KubernetesList; +import io.fabric8.openshift.api.model.template.Parameter; +import io.fabric8.openshift.api.model.template.Template; +import io.fabric8.utils.Strings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import static io.fabric8.kubernetes.api.KubernetesFactory.createObjectMapper; + +/** + * Helper class for working with OpenShift Templates + */ +public class Templates { + private static final transient Logger LOG = LoggerFactory.getLogger(Templates.class); + + /** + * Allows a list of resources to be combined into a single Template if one or more templates are contained inside the list + * or just return the unchanged list if no templates are present. + */ + public static Object combineTemplates(KubernetesList kubernetesList) { + Template firstTemplate = null; + List<HasMetadata> items = kubernetesList.getItems(); + for (HasMetadata item : items) { + if (item instanceof Template) { + Template template = (Template) item; + if (firstTemplate == null) { + firstTemplate = template; + } else { + firstTemplate = combineTemplates(firstTemplate, template); + } + } + } + if (firstTemplate != null) { + for (HasMetadata object : items) { + if (!(object instanceof Template)) { + addTemplateObject(firstTemplate, object); + } + } + } + return firstTemplate != null ? firstTemplate : kubernetesList; + } + + public static Template combineTemplates(Template firstTemplate, Template template) { + List<HasMetadata> objects = template.getObjects(); + if (objects != null) { + for (HasMetadata object : objects) { + addTemplateObject(firstTemplate, object); + } + } + List<Parameter> parameters = firstTemplate.getParameters(); + if (parameters == null) { + parameters = new ArrayList<>(); + firstTemplate.setParameters(parameters); + } + combineParameters(parameters, template.getParameters()); + String name = KubernetesHelper.getName(template); + if (Strings.isNotBlank(name)) { + // lets merge all the fabric8 annotations using the template id qualifier as a postfix + Map<String, String> annotations = KubernetesHelper.getOrCreateAnnotations(firstTemplate); + Map<String, String> otherAnnotations = KubernetesHelper.getOrCreateAnnotations(template); + Set<Map.Entry<String, String>> entries = otherAnnotations.entrySet(); + for (Map.Entry<String, String> entry : entries) { + String key = entry.getKey(); + String value = entry.getValue(); + if (!annotations.containsKey(key)) { + annotations.put(key, value); + } + } + } + return firstTemplate; + } + + protected static void combineParameters(List<Parameter> parameters, List<Parameter> otherParameters) { + if (otherParameters != null && otherParameters.size() > 0) { + Map<String, Parameter> map = new HashMap<>(); + for (Parameter parameter : parameters) { + map.put(parameter.getName(), parameter); + } + for (Parameter otherParameter : otherParameters) { + String name = otherParameter.getName(); + Parameter original = map.get(name); + if (original == null) { + parameters.add(otherParameter); + } else { + if (Strings.isNotBlank(original.getValue())) { + original.setValue(otherParameter.getValue()); + } + } + } + } + } + + public static void addTemplateObject(Template template, HasMetadata object) { + List<HasMetadata> objects = template.getObjects(); + objects.add(object); + template.setObjects(objects); + } + + + /** + * If we have any templates inside the items then lets unpack them and combine any parameters + * @param kubernetesList + * @param items + */ + public static Object combineTemplates(KubernetesList kubernetesList, List<HasMetadata> items) { + Template template = null; + for (HasMetadata item : items) { + if (item instanceof Template) { + Template aTemplate = (Template) item; + if (template == null) { + template = aTemplate; + } else { + template = combineTemplates(template, aTemplate); + } + } + } + if (template != null) { + // lets move all the content into the template + for (HasMetadata item : items) { + if (!(item instanceof Template)) { + addTemplateObject(template, item); + } + } + List<HasMetadata> objects = template.getObjects(); + return template; + } else { + return kubernetesList; + } + } + + + /** + * Lets allow template parameters to be overridden with a Properties object + */ + public static void overrideTemplateParameters(Template template, Map<String, String> properties, String propertyNamePrefix) { + List<io.fabric8.openshift.api.model.template.Parameter> parameters = template.getParameters(); + if (parameters != null && properties != null) { + boolean missingProperty = false; + for (io.fabric8.openshift.api.model.template.Parameter parameter : parameters) { + String parameterName = parameter.getName(); + String name = propertyNamePrefix + parameterName; + String propertyValue = properties.get(name); + if (Strings.isNotBlank(propertyValue)) { + LOG.info("Overriding template parameter " + name + " with value: " + propertyValue); + parameter.setValue(propertyValue); + } else { + missingProperty = true; + LOG.info("No property defined for template parameter: " + name); + } + } + if (missingProperty) { + LOG.debug("current properties " + new TreeSet<>(properties.keySet())); + } + } + } + + /** + * Lets locally process the templates so that we can process templates on any kubernetes environment + */ + public static KubernetesList processTemplatesLocally(Template entity) throws IOException { + List<HasMetadata> objects = null; + if (entity != null) { + objects = entity.getObjects(); + if (objects == null || objects.isEmpty()) { + return null; + } + } + List<Parameter> parameters = entity.getParameters(); + if (parameters != null && !parameters.isEmpty()) { + String json = "{\"kind\": \"List\", \"apiVersion\": \"" + + KubernetesHelper.defaultApiVersion + "\",\n" + + " \"items\": " + + KubernetesHelper.toJson(objects) + + " }"; + + // lets make a few passes in case there's expressions in values + for (int i = 0; i < 5; i++) { + for (Parameter parameter : parameters) { + String name = parameter.getName(); + String regex = "\\$\\{" + name + "\\}"; + String value = parameter.getValue(); + + // TODO generate random strings for passwords etc! + if (Strings.isNullOrBlank(value)) { + throw new IllegalArgumentException("No value available for parameter name: " + name); + } + json = Strings.replaceAllWithoutRegex(json, regex, value); + } + } + return createObjectMapper().reader(KubernetesList.class).readValue(json); + } else { + KubernetesList answer = new KubernetesList(); + answer.setItems(objects); + return answer; + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/support/KindToClassMapping.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/support/KindToClassMapping.java b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/support/KindToClassMapping.java new file mode 100644 index 0000000..f729942 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/support/KindToClassMapping.java @@ -0,0 +1,264 @@ +/** + * 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 + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * 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. + */ +package io.fabric8.kubernetes.api.support; + + +import io.fabric8.kubernetes.api.model.*; +import io.fabric8.kubernetes.api.model.base.ListMeta; +import io.fabric8.kubernetes.api.model.base.Status; +import io.fabric8.kubernetes.api.model.base.StatusCause; +import io.fabric8.kubernetes.api.model.base.StatusDetails; +import io.fabric8.kubernetes.api.model.config.AuthInfo; +import io.fabric8.kubernetes.api.model.config.Cluster; +import io.fabric8.kubernetes.api.model.config.Config; +import io.fabric8.kubernetes.api.model.config.Context; +import io.fabric8.kubernetes.api.model.config.NamedAuthInfo; +import io.fabric8.kubernetes.api.model.config.NamedCluster; +import io.fabric8.kubernetes.api.model.config.NamedContext; +import io.fabric8.kubernetes.api.model.config.NamedExtension; +import io.fabric8.kubernetes.api.model.config.Preferences; +import io.fabric8.kubernetes.api.model.errors.StatusError; +import io.fabric8.kubernetes.api.model.resource.Quantity; +import io.fabric8.kubernetes.api.model.util.IntOrString; +import io.fabric8.openshift.api.model.Build; +import io.fabric8.openshift.api.model.BuildConfig; +import io.fabric8.openshift.api.model.BuildConfigList; +import io.fabric8.openshift.api.model.BuildConfigSpec; +import io.fabric8.openshift.api.model.BuildConfigStatus; +import io.fabric8.openshift.api.model.BuildList; +import io.fabric8.openshift.api.model.BuildOutput; +import io.fabric8.openshift.api.model.BuildSource; +import io.fabric8.openshift.api.model.BuildSpec; +import io.fabric8.openshift.api.model.BuildStatus; +import io.fabric8.openshift.api.model.BuildStrategy; +import io.fabric8.openshift.api.model.BuildTriggerPolicy; +import io.fabric8.openshift.api.model.CustomBuildStrategy; +import io.fabric8.openshift.api.model.CustomDeploymentStrategyParams; +import io.fabric8.openshift.api.model.DeploymentCause; +import io.fabric8.openshift.api.model.DeploymentCauseImageTrigger; +import io.fabric8.openshift.api.model.DeploymentConfig; +import io.fabric8.openshift.api.model.DeploymentConfigList; +import io.fabric8.openshift.api.model.DeploymentConfigSpec; +import io.fabric8.openshift.api.model.DeploymentConfigStatus; +import io.fabric8.openshift.api.model.DeploymentDetails; +import io.fabric8.openshift.api.model.DeploymentStrategy; +import io.fabric8.openshift.api.model.DeploymentTriggerImageChangeParams; +import io.fabric8.openshift.api.model.DeploymentTriggerPolicy; +import io.fabric8.openshift.api.model.DockerBuildStrategy; +import io.fabric8.openshift.api.model.ExecNewPodHook; +import io.fabric8.openshift.api.model.GitBuildSource; +import io.fabric8.openshift.api.model.GitSourceRevision; +import io.fabric8.openshift.api.model.Image; +import io.fabric8.openshift.api.model.ImageChangeTrigger; +import io.fabric8.openshift.api.model.ImageList; +import io.fabric8.openshift.api.model.ImageStream; +import io.fabric8.openshift.api.model.ImageStreamList; +import io.fabric8.openshift.api.model.ImageStreamSpec; +import io.fabric8.openshift.api.model.ImageStreamStatus; +import io.fabric8.openshift.api.model.LifecycleHook; +import io.fabric8.openshift.api.model.NamedTagEventList; +import io.fabric8.openshift.api.model.NamedTagReference; +import io.fabric8.openshift.api.model.OAuthAccessToken; +import io.fabric8.openshift.api.model.OAuthAccessTokenList; +import io.fabric8.openshift.api.model.OAuthAuthorizeToken; +import io.fabric8.openshift.api.model.OAuthAuthorizeTokenList; +import io.fabric8.openshift.api.model.OAuthClient; +import io.fabric8.openshift.api.model.OAuthClientAuthorization; +import io.fabric8.openshift.api.model.OAuthClientAuthorizationList; +import io.fabric8.openshift.api.model.OAuthClientList; +import io.fabric8.openshift.api.model.RecreateDeploymentStrategyParams; +import io.fabric8.openshift.api.model.RollingDeploymentStrategyParams; +import io.fabric8.openshift.api.model.Route; +import io.fabric8.openshift.api.model.RouteList; +import io.fabric8.openshift.api.model.RouteSpec; +import io.fabric8.openshift.api.model.RouteStatus; +import io.fabric8.openshift.api.model.SourceBuildStrategy; +import io.fabric8.openshift.api.model.SourceControlUser; +import io.fabric8.openshift.api.model.SourceRevision; +import io.fabric8.openshift.api.model.TLSConfig; +import io.fabric8.openshift.api.model.TagEvent; +import io.fabric8.openshift.api.model.WebHookTrigger; +import io.fabric8.openshift.api.model.template.Parameter; +import io.fabric8.openshift.api.model.template.Template; + +import java.util.HashMap; +import java.util.Map; + +/** + * Maps the Kubernetes kinds to the Jackson DTO classes + */ +public class KindToClassMapping { + private static Map<String,Class<?>> map = new HashMap<>(); + + static { + map.put("AWSElasticBlockStoreVolumeSource", AWSElasticBlockStoreVolumeSource.class); + map.put("AuthInfo", AuthInfo.class); + map.put("BaseKubernetesList", BaseKubernetesList.class); + map.put("Build", Build.class); + map.put("BuildConfig", BuildConfig.class); + map.put("BuildConfigList", BuildConfigList.class); + map.put("BuildConfigSpec", BuildConfigSpec.class); + map.put("BuildConfigStatus", BuildConfigStatus.class); + map.put("BuildList", BuildList.class); + map.put("BuildOutput", BuildOutput.class); + map.put("BuildSource", BuildSource.class); + map.put("BuildSpec", BuildSpec.class); + map.put("BuildStatus", BuildStatus.class); + map.put("BuildStrategy", BuildStrategy.class); + map.put("BuildTriggerPolicy", BuildTriggerPolicy.class); + map.put("Capabilities", Capabilities.class); + map.put("Cluster", Cluster.class); + map.put("Config", Config.class); + map.put("Container", Container.class); + map.put("ContainerPort", ContainerPort.class); + map.put("ContainerState", ContainerState.class); + map.put("ContainerStateRunning", ContainerStateRunning.class); + map.put("ContainerStateTerminated", ContainerStateTerminated.class); + map.put("ContainerStateWaiting", ContainerStateWaiting.class); + map.put("ContainerStatus", ContainerStatus.class); + map.put("Context", Context.class); + map.put("CustomBuildStrategy", CustomBuildStrategy.class); + map.put("CustomDeploymentStrategyParams", CustomDeploymentStrategyParams.class); + map.put("DeploymentCause", DeploymentCause.class); + map.put("DeploymentCauseImageTrigger", DeploymentCauseImageTrigger.class); + map.put("DeploymentConfig", DeploymentConfig.class); + map.put("DeploymentConfigList", DeploymentConfigList.class); + map.put("DeploymentConfigSpec", DeploymentConfigSpec.class); + map.put("DeploymentConfigStatus", DeploymentConfigStatus.class); + map.put("DeploymentDetails", DeploymentDetails.class); + map.put("DeploymentStrategy", DeploymentStrategy.class); + map.put("DeploymentTriggerImageChangeParams", DeploymentTriggerImageChangeParams.class); + map.put("DeploymentTriggerPolicy", DeploymentTriggerPolicy.class); + map.put("DockerBuildStrategy", DockerBuildStrategy.class); + map.put("EmptyDirVolumeSource", EmptyDirVolumeSource.class); + map.put("EndpointAddress", EndpointAddress.class); + map.put("EndpointPort", EndpointPort.class); + map.put("EndpointSubset", EndpointSubset.class); + map.put("Endpoints", Endpoints.class); + map.put("EndpointsList", EndpointsList.class); + map.put("EnvVar", EnvVar.class); + map.put("EnvVarSource", EnvVarSource.class); + map.put("ExecAction", ExecAction.class); + map.put("ExecNewPodHook", ExecNewPodHook.class); + map.put("GCEPersistentDiskVolumeSource", GCEPersistentDiskVolumeSource.class); + map.put("GitBuildSource", GitBuildSource.class); + map.put("GitRepoVolumeSource", GitRepoVolumeSource.class); + map.put("GitSourceRevision", GitSourceRevision.class); + map.put("GlusterfsVolumeSource", GlusterfsVolumeSource.class); + map.put("HTTPGetAction", HTTPGetAction.class); + map.put("Handler", Handler.class); + map.put("HasMetadata", HasMetadata.class); + map.put("HostPathVolumeSource", HostPathVolumeSource.class); + map.put("ISCSIVolumeSource", ISCSIVolumeSource.class); + map.put("Image", Image.class); + map.put("ImageChangeTrigger", ImageChangeTrigger.class); + map.put("ImageList", ImageList.class); + map.put("ImageStream", ImageStream.class); + map.put("ImageStreamList", ImageStreamList.class); + map.put("ImageStreamSpec", ImageStreamSpec.class); + map.put("ImageStreamStatus", ImageStreamStatus.class); + map.put("IntOrString", IntOrString.class); + map.put("KubeSchema", KubeSchema.class); + map.put("KubernetesList", KubernetesList.class); + map.put("Lifecycle", Lifecycle.class); + map.put("LifecycleHook", LifecycleHook.class); + map.put("ListMeta", ListMeta.class); + map.put("NFSVolumeSource", NFSVolumeSource.class); + map.put("NamedAuthInfo", NamedAuthInfo.class); + map.put("NamedCluster", NamedCluster.class); + map.put("NamedContext", NamedContext.class); + map.put("NamedExtension", NamedExtension.class); + map.put("NamedTagEventList", NamedTagEventList.class); + map.put("NamedTagReference", NamedTagReference.class); + map.put("Namespace", Namespace.class); + map.put("NamespaceList", NamespaceList.class); + map.put("NamespaceSpec", NamespaceSpec.class); + map.put("NamespaceStatus", NamespaceStatus.class); + map.put("Node", Node.class); + map.put("NodeAddress", NodeAddress.class); + map.put("NodeCondition", NodeCondition.class); + map.put("NodeList", NodeList.class); + map.put("NodeSpec", NodeSpec.class); + map.put("NodeStatus", NodeStatus.class); + map.put("NodeSystemInfo", NodeSystemInfo.class); + map.put("OAuthAccessToken", OAuthAccessToken.class); + map.put("OAuthAccessTokenList", OAuthAccessTokenList.class); + map.put("OAuthAuthorizeToken", OAuthAuthorizeToken.class); + map.put("OAuthAuthorizeTokenList", OAuthAuthorizeTokenList.class); + map.put("OAuthClient", OAuthClient.class); + map.put("OAuthClientAuthorization", OAuthClientAuthorization.class); + map.put("OAuthClientAuthorizationList", OAuthClientAuthorizationList.class); + map.put("OAuthClientList", OAuthClientList.class); + map.put("ObjectFieldSelector", ObjectFieldSelector.class); + map.put("ObjectMeta", ObjectMeta.class); + map.put("ObjectReference", ObjectReference.class); + map.put("Parameter", Parameter.class); + map.put("PersistentVolumeClaimVolumeSource", PersistentVolumeClaimVolumeSource.class); + map.put("Pod", Pod.class); + map.put("PodCondition", PodCondition.class); + map.put("PodList", PodList.class); + map.put("PodSpec", PodSpec.class); + map.put("PodStatus", PodStatus.class); + map.put("PodTemplateSpec", PodTemplateSpec.class); + map.put("Preferences", Preferences.class); + map.put("Probe", Probe.class); + map.put("Quantity", Quantity.class); + map.put("RecreateDeploymentStrategyParams", RecreateDeploymentStrategyParams.class); + map.put("ReplicationController", ReplicationController.class); + map.put("ReplicationControllerList", ReplicationControllerList.class); + map.put("ReplicationControllerSpec", ReplicationControllerSpec.class); + map.put("ReplicationControllerStatus", ReplicationControllerStatus.class); + map.put("ResourceRequirements", ResourceRequirements.class); + map.put("RollingDeploymentStrategyParams", RollingDeploymentStrategyParams.class); + map.put("Route", Route.class); + map.put("RouteList", RouteList.class); + map.put("SourceBuildStrategy", SourceBuildStrategy.class); + map.put("RouteSpec", RouteSpec.class); + map.put("RouteStatus", RouteStatus.class); + map.put("SELinuxOptions", SELinuxOptions.class); + map.put("Secret", Secret.class); + map.put("SecretList", SecretList.class); + map.put("SecretVolumeSource", SecretVolumeSource.class); + map.put("SecurityContext", SecurityContext.class); + map.put("Service", Service.class); + map.put("ServiceAccount", ServiceAccount.class); + map.put("ServiceAccountList", ServiceAccountList.class); + map.put("ServiceList", ServiceList.class); + map.put("ServicePort", ServicePort.class); + map.put("ServiceSpec", ServiceSpec.class); + map.put("ServiceStatus", ServiceStatus.class); + map.put("SourceBuildStrategy", SourceBuildStrategy.class); + map.put("SourceControlUser", SourceControlUser.class); + map.put("SourceRevision", SourceRevision.class); + map.put("Status", Status.class); + map.put("StatusCause", StatusCause.class); + map.put("StatusDetails", StatusDetails.class); + map.put("StatusError", StatusError.class); + map.put("TCPSocketAction", TCPSocketAction.class); + map.put("TLSConfig", TLSConfig.class); + map.put("TagEvent", TagEvent.class); + map.put("Template", Template.class); + map.put("Volume", Volume.class); + map.put("VolumeMount", VolumeMount.class); + map.put("WebHookTrigger", WebHookTrigger.class); + } + + public static Map<String,Class<?>> getKindToClassMap() { + return map; + } +} + http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/Dockerfile ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/Dockerfile b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/Dockerfile new file mode 100644 index 0000000..78444b3 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/Dockerfile @@ -0,0 +1,5 @@ +FROM google/nodejs +RUN npm i -g raml2html +ADD . /data +CMD ["-i", "/data/kubernetes.raml", "-o", "/data/kubernetes.html"] +ENTRYPOINT ["raml2html"] http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/controller-list.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/controller-list.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/controller-list.json new file mode 100644 index 0000000..2977476 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/controller-list.json @@ -0,0 +1,35 @@ +{ + "kind": "ReplicationControllerList", + "apiVersion": "v1beta1", + "items": [ + { + "id": "testRun", + "desiredState": { + "replicas": 2, + "replicaSelector": { + "name": "testRun" + }, + "podTemplate": { + "desiredState": { + "manifest": { + "version": "v1beta1", + "image": "dockerfile/nginx", + "networkPorts": [ + { + "hostPort": 8080, + "containerPort": 80 + } + ] + } + }, + "labels": { + "name": "testRun" + } + } + }, + "labels": { + "name": "testRun" + } + } + ] +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/controller.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/controller.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/controller.json new file mode 100644 index 0000000..6697ce1 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/controller.json @@ -0,0 +1,24 @@ +{ + "kind": "ReplicationController", + "apiVersion": "v1beta3", + "metadata": { + "name": "nginx-controller", + "labels": {"name": "nginx"} + }, + "spec": { + "replicas": 2, + "selector": {"name": "nginx"}, + "template": { + "metadata": { + "labels": {"name": "nginx"} + }, + "spec": { + "containers": [{ + "name": "nginx", + "image": "dockerfile/nginx", + "ports": [{"containerPort": 80}] + }] + } + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/external-service.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/external-service.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/external-service.json new file mode 100644 index 0000000..00dfa13 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/external-service.json @@ -0,0 +1,13 @@ +{ + "id": "example", + "kind": "Service", + "apiVersion": "v1beta1", + "port": 8000, + "labels": { + "name": "nginx" + }, + "selector": { + "name": "nginx" + }, + "createExternalLoadBalancer": true +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/list.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/list.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/list.json new file mode 100644 index 0000000..3c2566f --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/list.json @@ -0,0 +1,98 @@ +{ + "kind" : "List", + "apiVersion" : "v1beta3", + "items" : [ { + "kind": "Service", + "apiVersion": "v1beta3", + "metadata": { + "name": "fabric8-console-service", + "namespace": "default", + "selfLink": "/api/v1beta1/services/fabric8-console-service?namespace=default", + "uid": "a2dac9a2-f22a-11e4-b882-fa163ee36154", + "resourceVersion": "61428", + "creationTimestamp": "2015-05-04T06:56:06Z", + "labels": { + "component": "console", + "provider": "fabric8" + } + }, + "spec": { + "ports": [ + { + "name": "", + "protocol": "TCP", + "port": 80, + "targetPort": 9090 + } + ], + "selector": { + "component": "console", + "provider": "fabric8" + }, + "portalIP": "172.30.129.192", + "sessionAffinity": "None" + }, + "status": {} + }, { + "kind": "ReplicationController", + "apiVersion": "v1beta3", + "metadata": { + "name": "fabric8-console-controller", + "namespace": "default", + "selfLink": "/api/v1beta1/replicationControllers/fabric8-console-controller?namespace=default", + "uid": "d4253743-f22a-11e4-b882-fa163ee36154", + "resourceVersion": "61718", + "creationTimestamp": "2015-05-04T06:57:28Z", + "labels": { + "component": "console", + "provider": "fabric8" + } + }, + "spec": { + "replicas": 1, + "selector": { + "component": "console", + "provider": "fabric8" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "component": "console", + "provider": "fabric8" + } + }, + "spec": { + "volumes": [], + "containers": [ + { + "name": "fabric8-console-container", + "image": "fabric8/hawtio-kubernetes", + "ports": [ + { + "name": "http", + "containerPort": 9090, + "protocol": "TCP" + }, + { + "name": "jolokia", + "containerPort": 8778, + "protocol": "TCP" + } + ], + "resources": {}, + "terminationMessagePath": "/dev/termination-log", + "imagePullPolicy": "Always", + "capabilities": {} + } + ], + "restartPolicy": "Always", + "dnsPolicy": "ClusterFirst" + } + } + }, + "status": { + "replicas": 1 + } + }] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod-list-empty-results.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod-list-empty-results.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod-list-empty-results.json new file mode 100644 index 0000000..2793f49 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod-list-empty-results.json @@ -0,0 +1,19 @@ +{ + "kind": "PodList", + "selfLink": "/api/v1beta1/pods", + "resourceVersion": 56138, + "apiVersion": "v1beta3", + "items": [ + { + "kind": "Pod", + "apiVersion": "v1beta3", + "metadata": { + }, + "status": { + "phase": "Running", + "hostIP": "127.0.0.1", + "podIP": "172.17.0.180" + } + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod-list.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod-list.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod-list.json new file mode 100644 index 0000000..261a052 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod-list.json @@ -0,0 +1,93 @@ +{ + "kind": "List", + "apiVersion": "v1beta3", + "items": [ + { + "kind": "Pod", + "apiVersion": "v1beta3", + "metadata": { + "name": "my-pod-1", + "generateName": "nexus-controller-", + "namespace": "default", + "selfLink": "/api/v1beta1/pods/nexus-controller-qq4p9?namespace=default", + "uid": "2cf18435-f310-11e4-b882-fa163ee36154", + "resourceVersion": "89638", + "creationTimestamp": "2015-05-05T10:19:12Z", + "labels": { + "component": "nexus", + "provider": "fabric8" + } + }, + "spec": { + "volumes": [ + { + "name": "nexus-storage", + "hostPath": null, + "emptyDir": { + "medium": "" + }, + "gcePersistentDisk": null, + "gitRepo": null, + "secret": null, + "nfs": null, + "iscsi": null, + "glusterfs": null + } + ], + "containers": [ + { + "name": "nginx", + "image": "dockerfile/nginx", + "ports": [ + { + "name": "http", + "containerPort": 8081, + "protocol": "TCP" + } + ], + "resources": {}, + "volumeMounts": [ + { + "name": "nexus-storage", + "mountPath": "/sonatype-work/storage" + } + ], + "terminationMessagePath": "/dev/termination-log", + "imagePullPolicy": "IfNotPresent", + "capabilities": {} + } + ], + "restartPolicy": "Always", + "dnsPolicy": "ClusterFirst", + "host": "jimmi-docker-2.osop.rhcloud.com" + }, + "status": { + "phase": "Running", + "Condition": [ + { + "type": "Ready", + "status": "True" + } + ], + "hostIP": "fe80::f816:3eff:fee3:6154", + "podIP": "172.17.0.180", + "containerStatuses": [ + { + "name": "nexus-container", + "state": { + "running": { + "startedAt": "2015-05-05T10:19:51Z" + } + }, + "lastState": {}, + "ready": true, + "restartCount": 0, + "image": "fabric8/nexus", + "imageID": "docker://0723d5f32ce06d8a72b6c2c3b3df84e4f8369e4ca6b836e312899118f2fe6575", + "containerID": "docker://65dce1c091f9fac1679ed0c555df58b2f60a17cc5f85922358b28a1fd6b3f1f4" + } + ] + } + } + ] +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod.json new file mode 100644 index 0000000..72d2f40 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/pod.json @@ -0,0 +1,34 @@ +{ + "kind": "Pod", + "apiVersion": "v1beta3", + "metadata": { + "name": "php", + "labels": { + "name": "foo" + } + }, + "spec": { + "containers": [ + { + "name": "nginx", + "image": "dockerfile/nginx", + "ports": [ + { + "hostPort": 8080, + "containerPort": 80, + "protocol": "TCP" + } + ], + "livenessProbe": { + "httpGet": { + "path": "/index.html", + "port": 8080 + }, + "initialDelaySeconds": 30, + "timeoutSeconds": 1 + }, + "imagePullPolicy": "IfNotPresent" + } + ] + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/service-list.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/service-list.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/service-list.json new file mode 100644 index 0000000..9f95f67 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/service-list.json @@ -0,0 +1,28 @@ +{ + "kind": "ServiceList", + "apiVersion": "v1beta1", + "items": [ + { + "id": "example1", + "port": 8000, + "labels": { + "name": "nginx" + }, + "selector": { + "name": "nginx" + } + }, + { + "id": "example2", + "port": 8080, + "labels": { + "env": "prod", + "name": "jetty" + }, + "selector": { + "env": "prod", + "name": "jetty" + } + } + ] +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/service.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/service.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/service.json new file mode 100644 index 0000000..42388e7 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/service.json @@ -0,0 +1,33 @@ +{ + "kind": "Service", + "apiVersion": "v1beta3", + "metadata": { + "name": "fabric8-console-service", + "namespace": "default", + "selfLink": "/api/v1beta1/services/fabric8-console-service?namespace=default", + "uid": "a2dac9a2-f22a-11e4-b882-fa163ee36154", + "resourceVersion": "61428", + "creationTimestamp": "2015-05-04T06:56:06Z", + "labels": { + "component": "console", + "provider": "fabric8" + } + }, + "spec": { + "ports": [ + { + "name": "", + "protocol": "TCP", + "port": 80, + "targetPort": 9090 + } + ], + "selector": { + "component": "console", + "provider": "fabric8" + }, + "portalIP": "172.30.129.192", + "sessionAffinity": "None" + }, + "status": {} +} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/template.json ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/template.json b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/template.json new file mode 100644 index 0000000..5e40e67 --- /dev/null +++ b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/examples/template.json @@ -0,0 +1,146 @@ +{ + "kind": "Template", + "apiVersion": "v1beta3", + "metadata": { + "name": "jenkins", + "namespace": "default", + "selfLink": "/osapi/v1beta1/templates/jenkins?namespace=default", + "uid": "420dc894-f24f-11e4-b882-fa163ee36154", + "resourceVersion": "66310", + "creationTimestamp": "2015-05-04T11:18:15Z" + }, + "objects": [ + { + "kind": "Service", + "apiVersion": "v1beta3", + "metadata": { + "name": "jenkins", + "creationTimestamp": null, + "labels": { + "component": "jenkins", + "provider": "fabric8" + } + }, + "spec": { + "ports": [ + { + "name": "", + "protocol": "TCP", + "port": 80, + "targetPort": 8080 + } + ], + "selector": { + "component": "jenkins", + "provider": "fabric8" + }, + "portalIP": "", + "sessionAffinity": "None" + }, + "status": {} + }, + { + "kind": "ReplicationController", + "apiVersion": "v1beta3", + "metadata": { + "name": "jenkins-controller", + "creationTimestamp": null, + "labels": { + "component": "jenkins", + "provider": "fabric8" + } + }, + "spec": { + "replicas": 1, + "selector": { + "component": "jenkins", + "provider": "fabric8" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "component": "jenkins", + "provider": "fabric8" + } + }, + "spec": { + "volumes": [ + { + "name": "docker-socket", + "hostPath": { + "path": "/var/run/docker.sock" + }, + "emptyDir": null, + "gcePersistentDisk": null, + "gitRepo": null, + "secret": null, + "nfs": null, + "iscsi": null, + "glusterfs": null + }, + { + "name": "jenkins-workspace", + "hostPath": null, + "emptyDir": { + "medium": "" + }, + "gcePersistentDisk": null, + "gitRepo": null, + "secret": null, + "nfs": null, + "iscsi": null, + "glusterfs": null + } + ], + "containers": [ + { + "name": "jenkins-container", + "image": "fabric8/jenkins", + "ports": [ + { + "name": "http", + "containerPort": 8080, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SEED_GIT_URL", + "value": "${SEED_GIT_URL}" + } + ], + "resources": {}, + "volumeMounts": [ + { + "name": "jenkins-workspace", + "mountPath": "/var/jenkins_home/workspace" + }, + { + "name": "docker-socket", + "mountPath": "/var/run/docker.sock" + } + ], + "terminationMessagePath": "/dev/termination-log", + "imagePullPolicy": "IfNotPresent", + "capabilities": {} + } + ], + "restartPolicy": "Always", + "dnsPolicy": "ClusterFirst" + } + } + }, + "status": { + "replicas": 0 + } + } + ], + "parameters": [ + { + "name": "SEED_GIT_URL", + "description": "The git URL of the seed build used to generate builds", + "value": "https://github.com/fabric8io/jenkins-pipeline-dsl.git" + } + ] +}
