Skip to content

Commit

Permalink
feat(fabric8io#1382): Adds it test, changelog and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lordofthejars authored and rhuss committed Oct 2, 2018
1 parent b50d3bd commit a792117
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ After this we will switch probably to real [Semantic Versioning 2.0.0](http://se
* Fix 1021: Avoids empty deployment selector value in generated yaml resource
* Fix 1383: Check if instanceof Openshift before casting and handle failures.
* Fix 1390: Provides better exception message in case of invalid `application.yml` in Spring Boot
* Fix 1382: Allow to provide additional fragment filename mappings

###3.5.41 (2018-08-01)
* Feature 1032: Improvements of the Vert.x Generator and enrichers
Expand Down
28 changes: 27 additions & 1 deletion doc/src/main/asciidoc/inc/_appendix.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,30 @@
== Kind/Filename Type Mapping

[[appendix-kind-mapping]]
include::classpath:/META-INF/fabric8/kind-filename-type-mapping-default.adoc[]
include::classpath:/META-INF/fabric8/kind-filename-type-mapping-default.adoc[]

== Custom Kind/Filename Mapping

You can add your custom `Kind/Filename` mappings.
To do it you have two approaches:

* Setting an environment variable or system property called `fabric8.mapping` pointing out to a `.properties` files with pairs `<kind>=>filename1>, <filename2>`
By default if no environment variable nor system property is set, scan for a file located at classpath `/META-INF/fabric8/kind-filename-type-mapping-default.properties`.

* By embedding in MOJO configuration the mapping:

[source, xml]
----
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<configuration>
<mappings>
<mapping>
<kind>Var</kind>
<filenames>foo, bar</filenames>
</mapping>
</mappings>
</configuration>
</plugin>
----
20 changes: 20 additions & 0 deletions it/src/it/custom-raw-resources/expected/kubernetes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
name: sample-svc
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 8080
selector:
app: project
provider: provider
group: group
type: NodePort
# strict checking: no other attributes will be added
20 changes: 20 additions & 0 deletions it/src/it/custom-raw-resources/expected/openshift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
name: sample-svc
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 8080
selector:
app: project
provider: provider
group: group
type: NodePort
# strict checking: no other attributes will be added
19 changes: 19 additions & 0 deletions it/src/it/custom-raw-resources/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright 2016 Red Hat, Inc.
#
# Red Hat licenses this file to you 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.
#

invoker.goals.1=clean fabric8:resource
invoker.mavenOpts=-Dfabric8.verbose -Dfabric8.mode=kubernetes
invoker.debug=false
53 changes: 53 additions & 0 deletions it/src/it/custom-raw-resources/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2016 Red Hat, Inc.
~
~ Red Hat licenses this file to you 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.
-->
<project>

<modelVersion>4.0.0</modelVersion>

<artifactId>fabric8-maven-sample-custom-raw-resources</artifactId>
<groupId>io.fabric8</groupId>
<version>3.5-SNAPSHOT</version>
<packaging>jar</packaging>

<build>
<plugins>

<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>@fmp.version@</version>
<configuration>
<mappings>
<mapping>
<kind>Service</kind>
<filenames>foo</filenames>
</mapping>
</mappings>
</configuration>
<executions>
<execution>
<goals>
<goal>resource</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
16 changes: 16 additions & 0 deletions it/src/it/custom-raw-resources/src/main/fabric8/raw/sample-foo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v1
kind: Service
metadata:
name: sample-svc
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 8080
selector:
app: project
provider: provider
group: group
type: NodePort
26 changes: 26 additions & 0 deletions it/src/it/custom-raw-resources/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import io.fabric8.maven.it.Verify

/*
* Copyright 2016 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.
*/


[ "kubernetes", "openshift" ].each {
Verify.verifyResourceDescriptors(
new File(basedir, sprintf("/target/classes/META-INF/fabric8/%s.yml",it)),
new File(basedir, sprintf("/expected/%s.yml",it)), true) // strict checking
}

true
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public class ResourceMojo extends AbstractFabric8Mojo {
private List<ImageConfiguration> resolvedImages;

// Mapping for kind filenames
@Parameter
private List<MappingConfig> mappings;

// Services
Expand Down

0 comments on commit a792117

Please sign in to comment.