From 5c6ba2540372345fa593e44731f18fe909c8d810 Mon Sep 17 00:00:00 2001 From: Decat-SimonA Date: Mon, 17 Aug 2020 21:00:10 +0200 Subject: [PATCH] doc: add YAML serialization example in the cheatsheet --- CHANGELOG.md | 1 + doc/CHEATSHEET.md | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b881596fec..bab2073332 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ #### Improvements * Fix #2331: Fixed documentation for namespaced informer for all custom types implementing `Namespaced` interface +* Fix #2406: Add documentation for serializing resources to YAML #### Dependency Upgrade * Fix #2360: bump mockito-core from 3.4.0 to 3.4.2 diff --git a/doc/CHEATSHEET.md b/doc/CHEATSHEET.md index 76b6d79e6a..43f98ef15d 100644 --- a/doc/CHEATSHEET.md +++ b/doc/CHEATSHEET.md @@ -34,6 +34,7 @@ This document contains common usages of different resources using Fabric8 Kubern * [List Options](#list-options) * [Delete Options](#delete-options) * [Watch Options](#watch-options) + * [Serializing to yaml](#serializing-to-yaml) * [OpenShift Client DSL Usage](#openshift-client-dsl-usage) * [Initializing OpenShift Client](#initializing-openshift-client) @@ -2173,6 +2174,16 @@ client.pods().watch(new ListOptionsBuilder().withTimeoutSeconds(30L).build(), ne }); ``` +#### Serializing to yaml +Resources can be exported to a yaml String via the `SerializationUtils` class: +``` +Pod myPod; + +String myPodAsYaml = SerializationUtils.dumpAsYaml(myPod); +// Your pod might have some state that you don't really care about, to remove it: +String myPodAsYamlWithoutRuntimeState = dumpWithoutRuntimeStateAsYaml(myPod); +``` + ### OpenShift Client DSL Usage Fabric8 Kubernetes Client also has an extension for OpenShift. It is pretty much the same as Kubernetes Client but has support for some additional OpenShift resources.