Skip to content

Commit

Permalink
chore(framents): Some doc and tests update (fabric8io#1385)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss authored Sep 17, 2018
1 parent 71fca8b commit bf5332c
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 118 deletions.
7 changes: 2 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ We use semantic versioning in some slight variation until our feature set has st

After this we will switch probably to real [Semantic Versioning 2.0.0](http://semver.org/)

###4.0.0

* Fix 1372: Filename to type mappings should be more flexible than a string array

###3.5.42
###3.5-SNAPSHOT
* Fix 1021: Avoids empty deployment selector value in generated yaml resource

###3.5.41 (2018-08-01)
Expand Down Expand Up @@ -42,6 +38,7 @@ After this we will switch probably to real [Semantic Versioning 2.0.0](http://se
* Refactor 1370: Removed Jenkinsshift support
* Feature 1363: Added a Thorntail V2 sample for checking Jolokia/Prometheus issues
* Fix 894: Keep Service parameters stable after redeployment
* Fix 1372: Filename to type mappings should be more flexible than a string array


###3.5.40
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class AsciiDocParser {
* <pre>
* [cols=2*,options="header"]
* |===
* |Filename
* |Kind
* |File type
*
* a|ConfigMap
* a|`cm`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class KindFilenameMapperUtil {

public static Map<String, List<String>> loadMappings() {

final String location = "/META-INF/fabric8/kind-fileindicator-mapping-default.adoc";
final String location = "/META-INF/fabric8/kind-filename-type-mapping-default.adoc";

try (final InputStream mappingFile = loadContent(location)) {
final AsciiDocParser asciiDocParser = new AsciiDocParser();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// =========================================================
// Mapping file for K8s/OpenShift reource kind to filename extension.
//
// I.e for fragments the resource kind is inferred from the filename type"
// myapp-deployment.yml maps to a Kubernetes Deployment
//
// Some hints for the format of this file which is used for documentation
// and during runtime:
// * There should be a exactly new line between rows
// * 1 Kind can be mapped to N Filename types, given as comma separated list
// * Columns should be ordered alphabetical by type (for better reading)
// * Last filename type in the csv list must be the canonical one (full kind in all lowercase)
|===
|Kind |Filename Type

|BuildConfig
|`bc`, `buildconfig`

|ClusterRole
|`cr`, `crole`, `clusterrole`

|ConfigMap
|`cm`, `configmap`

|ClusterRoleBinding
|`crb`, `clusterrb`, `clusterrolebinding`

|CronJob
|`cj`, `cronjob`

|CustomResourceDefinition
|`crd`, `customerresourcedefinition`

|DaemonSet
|`ds`, `daemonset`

|Deployment
|`deployment`

|DeploymentConfig
|`dc`, `deploymentconfig`

|ImageStream
|`is`, `imagestream`

|ImageStreamTag
|`istag`, `imagestreamtag`

|Job
|`job`

|LimitRange
|`lr`, `limitrange`

|Namespace
|`ns`, `namespace`

|OAuthClient
|`oauthclient`

|PolicyBinding
|`pb`, `policybinding`

|PersistentVolume
|`pv`, `persistentvolume`

|PersistentVolumeClaim
|`pvc`, `persistemtvolumeclaim`

|Project
|`project`

|ProjectRequest
|`pr`, `projectrequest`

|ReplicaSet
|`rs`, `replicaset`

|ReplicationController
|`rc`, `replicationcontroller`

|ResourceQuota
|`rq`, `resourcequota`

|Role
|`role`

|RoleBinding
|`rb`, `rolebinding`

|RoleBindingRestriction
|`rbr`, `rolebindingrestriction`

|Route
|`route`

|Secret
|`secret`

|Service
|`svc`, `service`

|ServiceAccount
|`sa`, `serviceaccount`

|StatefulSet
|`statefulset`

|Template
|`template`
|===
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class AsciiDocParserTest {

private static final String VALID_TABLE = "cols=2*,options=\"header\"]" + System.lineSeparator()
+ "|===" + System.lineSeparator()
+ "|Filename" + System.lineSeparator()
+ "|Kind" + System.lineSeparator()
+ "|Filename Type" + System.lineSeparator()
+ System.lineSeparator()
+ "|ConfigMap" + System.lineSeparator()
+ "a|`cm`, `configmap`" + System.lineSeparator()
Expand All @@ -42,8 +42,8 @@ public class AsciiDocParserTest {

private static final String NONE_END_VALID_TABLE = "cols=2*,options=\"header\"]" + System.lineSeparator()
+ "|===" + System.lineSeparator()
+ "|Filename" + System.lineSeparator()
+ "|Kind" + System.lineSeparator()
+ "|Filename Type" + System.lineSeparator()
+ System.lineSeparator()
+ "|cm" + System.lineSeparator()
+ "a|ConfigMap" + System.lineSeparator()
Expand All @@ -53,8 +53,8 @@ public class AsciiDocParserTest {

private static final String INVALID_TABLE_WITH_THREE_COLUMNS = "cols=2*,options=\"header\"]" + System.lineSeparator()
+ "|===" + System.lineSeparator()
+ "|Filename" + System.lineSeparator()
+ "|Kind" + System.lineSeparator()
+ "|Filename Type" + System.lineSeparator()
+ System.lineSeparator()
+ "|cm" + System.lineSeparator()
+ "a|ConfigMap" + System.lineSeparator()
Expand Down
3 changes: 2 additions & 1 deletion doc/src/main/asciidoc/inc/_appendix.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

== Kind/Filename Type Mapping

include::classpath:/META-INF/fabric8/kind-fileindicator-mapping-default.adoc[]
[[appendix-kind-mapping]]
include::classpath:/META-INF/fabric8/kind-filename-type-mapping-default.adoc[]
2 changes: 1 addition & 1 deletion doc/src/main/asciidoc/inc/_introduction.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ Let's have a look at an example from https://github.com/rhuss/fabric8-maven-plug

As you can see, there is no `metadata` section as would be expected for Kubernetes resources because it will be automatically added by the `fabric8-maven-plugin`. The object's `Kind`, if not given, is automatically derived from the
filename. In this case, the `fabric8-maven-plugin` will create a `Deployment` because the file is called `deployment.yml`. Similar mappings between file names and resource type exist for each supported resource kind, the
complete list of which (along with associated abbreviations) can be found at https://github.com/fabric8io/fabric8-maven-plugin/blob/master/core/src/main/java/io/fabric8/maven/core/util/kubernetes/KubernetesResourceUtil.java#L198-L244.
complete list of which (along with associated abbreviations) can be found in the <<appendix-kind-mapping, Appendix>>.

Additionally, if you name your fragment using a name prefix followed by a dash and the mapped file name, the plugin will automatically use that name for your resource. So, for example, if you name your deployment fragment
`myapp-deployment.yml`, the plugin will name your resource `myapp`. In the absence of such provided name for your resource, a name will be automatically derived from your project's metadata (in particular, its `artifactId` as specified in your POM).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private Map<String, String> createLabels(boolean withoutVersion) {
}

ret.put("group", project.getGroupId());
ret.put("provider", "META-INF/fabric8");
ret.put("provider", "fabric8");
if (!withoutVersion) {
ret.put("version", project.getVersion());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ public void enrichSimple() {
assertNotNull(metadata);
Map<String, String> labels = metadata.getLabels();
assertNotNull(labels);
assertEquals("META-INF/fabric8", labels.get("provider"));
assertEquals("fabric8", labels.get("provider"));
}
}

0 comments on commit bf5332c

Please sign in to comment.