forked from eclipse-jkube/jkube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (jkube-kit) : Initial draft for JKube Actions Summary (eclipse-j…
…kube#1033) Signed-off-by: Rohan Kumar <rohaan@redhat.com>
- Loading branch information
1 parent
65d37bf
commit f250a98
Showing
18 changed files
with
342 additions
and
4 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
217 changes: 217 additions & 0 deletions
217
jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/Summary.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,217 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* 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: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.common; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Summary { | ||
private static Summary summaryInstance; | ||
private String buildStrategy; | ||
private String packagedFileLocation; | ||
private String generatorName; | ||
private String dockerFileUsed; | ||
private String targetImageName; | ||
private boolean successful; | ||
private String failureCause; | ||
private List<String> generatedResourceFiles; | ||
private String aggregateResourceFile; | ||
private String targetClusterUrl; | ||
private List<String> createdKubernetesResources; | ||
private List<String> updatedKubernetesResources; | ||
|
||
private List<String> deletedKubernetesResources; | ||
|
||
private String pushRegistry; | ||
private String pushRegistryUser; | ||
private String pushedImage; | ||
|
||
private Summary() { } | ||
|
||
public static Summary getInstance() { | ||
if (summaryInstance == null) { | ||
summaryInstance = new Summary(); | ||
} | ||
return summaryInstance; | ||
} | ||
|
||
public void setBuildStrategy(String buildStrategy) { | ||
this.buildStrategy = buildStrategy; | ||
} | ||
|
||
public void setPackagedFileLocation(String packagedFileLocation) { | ||
this.packagedFileLocation = packagedFileLocation; | ||
} | ||
|
||
public void setGeneratorName(String generatorName) { | ||
this.generatorName = generatorName; | ||
} | ||
|
||
public void setDockerFileUsed(String dockerFileUsed) { | ||
this.dockerFileUsed = dockerFileUsed; | ||
} | ||
|
||
public void setTargetImageName(String targetImageName) { | ||
this.targetImageName = targetImageName; | ||
} | ||
|
||
public void setSuccessful(boolean successful) { | ||
this.successful = successful; | ||
} | ||
|
||
public void setFailureCause(String failureCause) { | ||
this.failureCause = failureCause; | ||
} | ||
|
||
public void setAggregateResourceFile(String aggregateResourceFile) { | ||
this.aggregateResourceFile = aggregateResourceFile; | ||
} | ||
|
||
public void addGeneratedResourceFile(String resourceFilePath) { | ||
if (this.generatedResourceFiles == null) { | ||
this.generatedResourceFiles = new ArrayList<>(); | ||
} | ||
this.generatedResourceFiles.add(resourceFilePath); | ||
} | ||
|
||
public void addCreatedKubernetesResource(String kubernetesResource) { | ||
if (this.createdKubernetesResources == null) { | ||
this.createdKubernetesResources = new ArrayList<>(); | ||
} | ||
this.createdKubernetesResources.add(kubernetesResource); | ||
} | ||
|
||
public void addDeletedKubernetesResource(String kubernetesResource) { | ||
if (this.deletedKubernetesResources == null) { | ||
this.deletedKubernetesResources = new ArrayList<>(); | ||
} | ||
this.deletedKubernetesResources.add(kubernetesResource); | ||
} | ||
|
||
public void setTargetClusterUrl(String clusterUrl) { | ||
this.targetClusterUrl = clusterUrl; | ||
} | ||
|
||
public void addUpdatedKubernetesResource(String kubernetesResource) { | ||
if (this.updatedKubernetesResources == null) { | ||
this.updatedKubernetesResources = new ArrayList<>(); | ||
} | ||
this.updatedKubernetesResources.add(kubernetesResource); | ||
} | ||
|
||
public void setPushRegistry(String pushRegistry) { | ||
this.pushRegistry = pushRegistry; | ||
} | ||
|
||
public void setPushRegistryUser(String pushRegistryUser) { | ||
this.pushRegistryUser = pushRegistryUser; | ||
} | ||
|
||
public void setPushedImage(String pushedImage) { | ||
this.pushedImage = pushedImage; | ||
} | ||
|
||
|
||
public void printSummary(KitLogger logger) { | ||
if (summaryInstance != null) { | ||
logSummary(logger, "------------------------------"); | ||
logSummary(logger, " SUMMARY"); | ||
logSummary(logger, "-------------------------------"); | ||
logSummary(logger, " __ / / //_/ / / / _ )/ __/"); | ||
logSummary(logger, "/ // / ,< / /_/ / _ / _/ "); | ||
logSummary(logger, "\\___/_/|_|\\____/____/___/ \n"); | ||
printBuildSummary(logger); | ||
printResourceSummary(logger); | ||
printApplySummary(logger); | ||
printUndeploySummary(logger); | ||
printPushSummary(logger); | ||
if (successful) { | ||
logSummary(logger, "SUCCESS"); | ||
} else { | ||
logSummary(logger, "FAILURE"); | ||
logSummary(logger, "Failure cause " + failureCause); | ||
} | ||
logSummary(logger, "-------------------------------"); | ||
} | ||
} | ||
|
||
private void printBuildSummary(KitLogger logger) { | ||
if (buildStrategy != null) { | ||
logSummary(logger, "Build Strategy : " + buildStrategy); | ||
} | ||
if (packagedFileLocation != null) { | ||
logSummary(logger, "Packaged File Location : " + packagedFileLocation); | ||
} | ||
if (generatorName != null) { | ||
logSummary(logger, "Generator Name : " + generatorName); | ||
} | ||
if (dockerFileUsed != null) { | ||
logSummary(logger, "Dockerfile used : " + dockerFileUsed); | ||
} | ||
if (targetImageName != null) { | ||
logSummary(logger, "Target Image Name : " + targetImageName); | ||
} | ||
} | ||
|
||
private void printResourceSummary(KitLogger logger) { | ||
if (generatedResourceFiles != null && !generatedResourceFiles.isEmpty()) { | ||
logSummary(logger, "Generated Resource Files:"); | ||
logList(logger, "Individual \n", generatedResourceFiles); | ||
logSummary(logger, "\n"); | ||
logSummary(logger, "Aggregate : " + aggregateResourceFile); | ||
} | ||
} | ||
|
||
private void printApplySummary(KitLogger logger) { | ||
if (targetClusterUrl != null) { | ||
logSummary(logger, "Cluster URL : " + targetClusterUrl); | ||
} | ||
if (createdKubernetesResources != null && !createdKubernetesResources.isEmpty()) { | ||
logList(logger, "Created Resources: \n", createdKubernetesResources); | ||
} | ||
if (updatedKubernetesResources != null && !updatedKubernetesResources.isEmpty()) { | ||
logList(logger, "Updated Resources: \n", updatedKubernetesResources); | ||
} | ||
} | ||
|
||
private void printUndeploySummary(KitLogger logger) { | ||
if (deletedKubernetesResources != null && !deletedKubernetesResources.isEmpty()) { | ||
logList(logger, "Deleted Resources: \n", deletedKubernetesResources); | ||
} | ||
} | ||
|
||
|
||
private void printPushSummary(KitLogger logger) { | ||
if (pushRegistry!= null) { | ||
logSummary(logger, "Pushed to Image Registry: " + pushRegistry); | ||
} | ||
if (pushRegistryUser != null) { | ||
logSummary(logger, "Username : " + pushRegistryUser); | ||
} | ||
if (pushedImage != null) { | ||
logSummary(logger, "Pushed Image URL : " + pushedImage); | ||
} | ||
} | ||
|
||
private void logList(KitLogger logger, String title, List<String> list) { | ||
logSummary(logger, title); | ||
for (String item : list) { | ||
logSummary(logger, " - " + item); | ||
} | ||
} | ||
|
||
private void logSummary(KitLogger logger, String message) { | ||
logger.info("[[C]] " + message + " [[C]]"); | ||
} | ||
} |
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
Oops, something went wrong.