-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Container network configuration support (#3983)
* feat: add network config support to kura api's * feat: add network config support to container orch impl * fix: added lint fixes - and minor implimentation changes * fix: removed requirement on container ports. Ports can now be left empty * test: added test coverage for the new class * fix: api versioning to match api package * fix: turned networkMode into a optional string * fix: changed .get .getOptional * fix: networkMode javaDoc refractor
- Loading branch information
1 parent
c2662bf
commit 972cfd8
Showing
8 changed files
with
174 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...src/main/java/org/eclipse/kura/container/orchestration/ContainerNetworkConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.kura.container.orchestration; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import org.osgi.annotation.versioning.ProviderType; | ||
|
||
/** | ||
* Object which represents a container network configuration used to when | ||
* requesting the generation of a new container instance. | ||
* | ||
* @noimplement This interface is not intended to be implemented by clients. | ||
* @since 2.4 | ||
* | ||
*/ | ||
@ProviderType | ||
public class ContainerNetworkConfiguration { | ||
|
||
private Optional<String> networkMode; | ||
|
||
private ContainerNetworkConfiguration() { | ||
} | ||
|
||
/** | ||
* | ||
* Returns the network mode a container will be created with (e.g. 'bridge', | ||
* 'none', 'container:', 'host'). | ||
* | ||
* @return | ||
*/ | ||
public Optional<String> getNetworkMode() { | ||
return this.networkMode; | ||
} | ||
|
||
/** | ||
* Creates a builder for creating a new {@link ContainerNetworkConfiguration} | ||
* instance. | ||
* | ||
* @return the builder. | ||
*/ | ||
public static ContainerNetworkConfigurationBuilder builder() { | ||
return new ContainerNetworkConfigurationBuilder(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(this.networkMode); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof ContainerNetworkConfiguration)) { | ||
return false; | ||
} | ||
ContainerNetworkConfiguration other = (ContainerNetworkConfiguration) obj; | ||
return Objects.equals(this.networkMode, other.networkMode); | ||
} | ||
|
||
public static final class ContainerNetworkConfigurationBuilder { | ||
|
||
private Optional<String> networkMode = Optional.empty(); | ||
|
||
public ContainerNetworkConfigurationBuilder setNetworkMode(Optional<String> networkMode) { | ||
this.networkMode = networkMode; | ||
return this; | ||
} | ||
|
||
public ContainerNetworkConfiguration build() { | ||
ContainerNetworkConfiguration result = new ContainerNetworkConfiguration(); | ||
|
||
result.networkMode = requireNonNull(this.networkMode, | ||
"Requested Container Network Mode Name cannot be null"); | ||
|
||
return result; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters