Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Moved KubernetesClient implementation of
kubectl run
to separa…
…te package
- Loading branch information
Showing
13 changed files
with
138 additions
and
137 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
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
93 changes: 93 additions & 0 deletions
93
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperations.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,93 @@ | ||
/** | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* 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 io.fabric8.kubernetes.client.extended.run; | ||
|
||
import io.fabric8.kubernetes.api.model.Pod; | ||
import io.fabric8.kubernetes.api.model.PodBuilder; | ||
import io.fabric8.kubernetes.client.Config; | ||
import io.fabric8.kubernetes.client.dsl.internal.core.v1.PodOperationsImpl; | ||
import okhttp3.OkHttpClient; | ||
|
||
public class RunOperations { | ||
private final OkHttpClient client; | ||
private final Config config; | ||
private final String namespace; | ||
private final RunConfigBuilder runConfigBuilder; | ||
|
||
public RunOperations(OkHttpClient client, Config config, String namespace, RunConfigBuilder runConfigBuilder) { | ||
this.client = client; | ||
this.config = config; | ||
this.namespace = namespace; | ||
this.runConfigBuilder = runConfigBuilder; | ||
} | ||
|
||
/** | ||
* Specify namespace for the operation | ||
* | ||
* @param namespace namespace in which resource needs to be created | ||
* @return {@link RunOperations} with injected namespace | ||
*/ | ||
public RunOperations inNamespace(String namespace) { | ||
return new RunOperations(client, config, namespace, runConfigBuilder); | ||
} | ||
|
||
/** | ||
* Specify image for the Pod | ||
* | ||
* @param image image as a string | ||
* @return {@link RunOperations} with image injected into {@link RunConfig} | ||
*/ | ||
public RunOperations withImage(String image) { | ||
return new RunOperations(client, config, namespace, runConfigBuilder.withImage(image)); | ||
} | ||
|
||
/** | ||
* Specify name for the Pod | ||
* | ||
* @param name name of the pod to be created | ||
* @return {@link RunOperations} with name injected into {@link RunConfig} | ||
*/ | ||
public RunOperations withName(String name) { | ||
return new RunOperations(client, config, namespace, runConfigBuilder.withName(name)); | ||
} | ||
|
||
/** | ||
* Specify complex configuration for Pod creating using {@link RunConfig} | ||
* | ||
* @param generatorRunConfig {@link RunConfig} which allows to provide configuring environment variables, labels, resources, ports etc | ||
* @return {@link RunOperations} with specified configuration | ||
*/ | ||
public RunOperations withRunConfig(RunConfig generatorRunConfig) { | ||
return new RunOperations(client, config, namespace, new RunConfigBuilder(generatorRunConfig)); | ||
} | ||
|
||
/** | ||
* Apply the {@link RunConfig} onto the cluster and create Pod | ||
* | ||
* @return Pod which got created from the operation | ||
*/ | ||
public Pod done() { | ||
return new PodOperationsImpl(client, config, namespace).create(convertRunConfigIntoPod()); | ||
} | ||
|
||
Pod convertRunConfigIntoPod() { | ||
RunConfig finalGeneratorConfig = runConfigBuilder.build(); | ||
return new PodBuilder() | ||
.withMetadata(RunConfigUtil.getObjectMetadataFromRunConfig(finalGeneratorConfig)) | ||
.withSpec(RunConfigUtil.getPodSpecFromRunConfig(finalGeneratorConfig)) | ||
.build(); | ||
} | ||
} |
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
94 changes: 0 additions & 94 deletions
94
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/PodGeneratorImpl.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.