How to set the name of a ConfigMapListBuilder

7 views
Skip to first unread message

cmou...@redhat.com

unread,
May 2, 2017, 1:28:03 PM5/2/17
to fabric8
Hi,

I try to figure out in a test case how to set the name of a configMap using the ConfigBuilder but I don't see the method withName(). Is my syntax correct ?

new ConfigMapListBuilder().withNewMetadata().withName("reload-example").endMetadata()
.addNewItem().addToData("KEY","123").and()
.addNewItem().and().build())
.once();

Regards

Charles


cmou...@redhat.com

unread,
May 2, 2017, 2:45:26 PM5/2/17
to fabric8
Find my mistake

server.expect().withPath("/api/v1/namespaces/ns/configmaps").andReturn(200, new ConfigMapBuilder()
.withNewMetadata().withName("reload-example").endMetadata()
.addToData(data)
.build())
.once();

Is there a trick to load such config ?

apiVersion: v1
kind: ConfigMap
metadata:
  name: reload-example
data:
  application.properties: |-
    bean.message=Hello World!
    another.property=value

James Strachan

unread,
May 2, 2017, 3:02:13 PM5/2/17
to Charles Moulliard, fabric8
On 2 May 2017 at 19:45, <cmou...@redhat.com> wrote:
Find my mistake

server.expect().withPath("/api/v1/namespaces/ns/configmaps").andReturn(200, new ConfigMapBuilder()
.withNewMetadata().withName("reload-example").endMetadata()
.addToData(data)
.build())
.once();

Is there a trick to load such config ?

isn't the code you just provided enough? Just need newlines in the value in the data map
 

apiVersion: v1
kind: ConfigMap
metadata:
  name: reload-example
data:
  application.properties: |-
    bean.message=Hello World!
    another.property=value

On Tuesday, May 2, 2017 at 7:28:03 PM UTC+2, cmou...@redhat.com wrote:
Hi,

I try to figure out in a test case how to set the name of a configMap using the ConfigBuilder but I don't see the method withName(). Is my syntax correct ?

new ConfigMapListBuilder().withNewMetadata().withName("reload-example").endMetadata()
.addNewItem().addToData("KEY","123").and()
.addNewItem().and().build())
.once();

Regards

Charles


--
You received this message because you are subscribed to the Google Groups "fabric8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabric8+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
James
-------
Red Hat

Twitter: @jstrachan
Email: james.s...@gmail.com
Blog: https://medium.com/@jstrachan/

open source development platform

open source event based lambda programming

cmou...@redhat.com

unread,
May 2, 2017, 3:14:50 PM5/2/17
to fabric8
How do you include newlines ?

Here is the code that I'm trying

HashMap<String,String> data = new HashMap<>();
data.put("application.properties", "bean.message=Hello Charles !");

server.expect().withPath("/api/v1/namespaces/ns/configmaps").andReturn(200, new ConfigMapBuilder()
.withNewMetadata().withName("reload-example").endMetadata()
.addToData(data)
.build())
.once();

On Tuesday, May 2, 2017 at 7:28:03 PM UTC+2, cmou...@redhat.com wrote:

James Strachan

unread,
May 2, 2017, 3:25:11 PM5/2/17
to cmou...@redhat.com, fabric8
Use "foo\nbar" in Java to add new lines 

--
You received this message because you are subscribed to the Google Groups "fabric8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabric8+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

cmou...@redhat.com

unread,
May 3, 2017, 2:44:18 AM5/3/17
to fabric8
The format of the string is 

application.properties: |-
    bean.message=Hello World!
    another.property=value

As the "addToData()" method accepts 2 different parameters which are either (String key, String val) or (Map<String,String> map), I don't see how we could define such a structure even if we use foo\nbar ?

On Tuesday, May 2, 2017 at 7:28:03 PM UTC+2, cmou...@redhat.com wrote:

Roland Huss

unread,
May 3, 2017, 3:12:36 AM5/3/17
to cmou...@redhat.com, fabric8
What about 

.addData("application.properties","bean.message=Hello World!\nanother.property=value") 

???

--
You received this message because you are subscribed to the Google Groups "fabric8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabric8+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
... roland

Jimmi Dyson

unread,
May 3, 2017, 3:13:48 AM5/3/17
to cmou...@redhat.com, fabric8

Don't worry about how it's getting serialised, you just need to add using addData with the key (application.properties in this case) and the value (the multiline string something like  bean.message=Hello World\nanother.property=value).

Hope that helps...


James Strachan

unread,
May 3, 2017, 6:14:39 AM5/3/17
to Charles Moulliard, fabric8
Map<String,String> map = new HashMap<>();
map.put("application.properties", "bean.message=Hello World!\nanother.property=value");
...
server.expect().withPath("/api/v1/namespaces/ns/configmaps").andReturn(200, new ConfigMapBuilder()
.withNewMetadata().withName("reload-example").endMetadata()
.addToData(data)
.build())
.once();

--
You received this message because you are subscribed to the Google Groups "fabric8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabric8+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages