All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bmuschko.gradle.docker.utils.ThreadContextClassLoader.groovy Maven / Gradle / Ivy

There is a newer version: 6.7.0
Show newest version
/*
 * Copyright 2014 the original author or authors.
 *
 * Licensed 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 com.bmuschko.gradle.docker.utils

import com.bmuschko.gradle.docker.DockerRegistryCredentials
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
import org.gradle.api.Action

interface ThreadContextClassLoader {

    /**
     * Loads class with given name from thread context classloader.
     *
     * @param className Class name
     * @return Class
     */
    Class loadClass(String className)

    /**
     * Creates instance of AuthConfig
     * from the thread context classloader.
     *
     * @param registryCredentials Registry credentials
     * @return Instance
     */
    def createAuthConfig(DockerRegistryCredentials registryCredentials)

    /**
     * Creates instance of AuthConfigurations
     * from the thread context classloader.
     *
     * @param authConfigs Authentication configs
     * @return Instance
     */
    def createAuthConfigurations(List authConfigs)

    /**
     * Creates instance of Volume
     * from thread context classloader.
     *
     * @param path Path to volume
     * @return Instance
     */
    def createVolume(String path)

    /**
     * Creates instance of Volumes
     * from thread context classloader.
     *
     * @param volumes List of Volumes
     * @return Instance
     */
    def createVolumes(List volumes)

    /**
     * Creates an array of instances of VolumesFrom
     * from thread context classloader.
     *
     * @param volume Container name
     * @return Array of Instances
     */
    def createVolumesFrom(String[] volumes)

    /**
     * Creates instance of Link
     * from thread context classloader.
     *
     * @param link a container link
     * @return Instance
     */
    def createLink(String link)

    /**
     * Creates instance of Links
     * from thread context classloader.
     *
     * @param volumes List of Links
     * @return Instance
     */
    def createLinks(List links)

    /**
     * Creates instance of Links
     * from thread context classloader.
     *
     * @param hostConfigProperties a map containing all HostConfig properties to be set. The map entry key is the property name while the map entry value is the property value.
     * @return Instance
     */
    def createHostConfig(Map hostConfigProperties)

    /**
     * Creates instance of InternetProtocol
     * from thread context classloader.
     *
     * @param scheme Scheme
     * @return Instance
     */
    def createInternetProtocol(String scheme)

    /**
     * Creates instance of ExposedPort
     * from thread context classloader.
     *
     * @param scheme Scheme
     * @param port Port
     * @return Instance
     */
    def createExposedPort(String scheme, Integer port)

    /**
     * Creates instance of ExposedPorts
     * from thread context classloader.
     *
     * @param exposedPorts Exposed ports
     * @return Instance
     */
    def createExposedPorts(List exposedPorts)

    /**
     * Creates an array of instances of ExposedPorts
     * from thread context classloader.
     *
     * @param exposedPorts Exposed ports
     * @return An array of instances
     */
    def createExposedPortsArray(List exposedPorts)

    /**
     * Creates instance of PortBinding
     * from thread context classloader.
     *
     * @param portBinding Port binding
     * @return Instance
     */
    def createPortBinding(String portBinding)

    /**
     * Creates instance of Ports
     * from thread context classloader.
     *
     * @param portBindings List of PortBindings
     * @return Instance
     */
    def createPorts(List portBindings)

    /**
     * Creates instance of Bind
     * from thread context classloader.
     *
     * @param path The path on the local host to bind to the given volume.
     * @param volume The path to the volume of the container to bind to.
     * @return Instance
     */
    def createBind(String path, String volume)

    /**
     * Creates an array of instances of Bind
     * from thread context classloader.
     *
     * @param binds A map of the binds to create. The keys are the path on the local host to bind
     * to the given volume. The values are the path to the volume of the container to bind to.
     * @return Array of Instance
     */
    def createBinds(Map binds)

    /**
     * Creates instance of LogConfig
     * from thread context classloader.
     *
     * @param type The type of log-driver to use (e.g. json-file, syslog, journald, none).
     * @param parameters Optional parameters for log-driver
     * @return Instance
     */
    def createLogConfig(String type, Map parameters)

    /**
     * Creates instance of RestartPolicy
     * @param restartPolicy a string with serialized value which can be parsed RestartPolicy.parse method
     * @return Instance of RestartPolicy
     */
    def createRestartPolicy(String restartPolicy)

    /**
     * Creates instance of Device
     * @param  a string with serialized value which can be parsed by the Device.parse method
     * @return Instance of Device
     */
    def createDevice(String device)

    /**
     * Creates the callback instance of BuildImageResultCallback
     * from thread context classloader.
     *
     * @return Callback instance
     */
    def createBuildImageResultCallback()

    def createBuildImageResultCallback(Action nextHandler)

    /**
     * Creates the callback instance of PushImageResultCallback
     * from thread context classloader.
     *
     * @return Callback instance
     */
    def createPushImageResultCallback(Action nextHandler)

    /**
     * Creates the callback instance of PullImageResultCallback
     * from thread context classloader.
     *
     * @return Callback instance
     */
    def createPullImageResultCallback(Action nextHandler)

    /**
     * Creates the callback instance of LogContainerResultCallback
     * from thread context classloader. The callback is modified to send log lines to standard out and error.
     *
     * @return Callback instance
     */
    def createLoggingCallback()

    def createLoggingCallback(Action nextHandler)

    /**
     * Creates the callback instance of ExecStartResultCallback
     * from thread context classloader.
     *
     * @param out The output stream instance which docker will print the standard output to
     * @param err The output stream instance which docker will print the standard error to
     * @return Callback instance
     */
    def createExecCallback(OutputStream out, OutputStream err)

    def createExecCallback(Action nextHandler)

    /**
     * Creates the callback instance of LogContainerResultCallback
     * from thread context classloader. The callback is modified to send log lines to standard out and error.
     *
     * @param sink The Writer instance which docker stream items will be written to
     * @return Callback instance
     */
    def createLoggingCallback(Writer sink)

    /**
     * Creates the callback instance of WaitContainerResultCallback from thread context classloader.
     * @return Callback instance
     */
    def createWaitContainerResultCallback(Action nextHandler)
}