diff --git a/CHANGELOG.md b/CHANGELOG.md index 4351a52fc7..4d840eb886 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) @@ -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 diff --git a/core/src/main/java/io/fabric8/maven/core/util/AsciiDocParser.java b/core/src/main/java/io/fabric8/maven/core/util/AsciiDocParser.java index 21520b3b80..88b6c7f832 100644 --- a/core/src/main/java/io/fabric8/maven/core/util/AsciiDocParser.java +++ b/core/src/main/java/io/fabric8/maven/core/util/AsciiDocParser.java @@ -39,8 +39,8 @@ public class AsciiDocParser { *
* [cols=2*,options="header"] * |=== - * |Filename * |Kind + * |File type * * a|ConfigMap * a|`cm` diff --git a/core/src/main/java/io/fabric8/maven/core/util/kubernetes/KindFilenameMapperUtil.java b/core/src/main/java/io/fabric8/maven/core/util/kubernetes/KindFilenameMapperUtil.java index ee3f7be07f..b365589349 100644 --- a/core/src/main/java/io/fabric8/maven/core/util/kubernetes/KindFilenameMapperUtil.java +++ b/core/src/main/java/io/fabric8/maven/core/util/kubernetes/KindFilenameMapperUtil.java @@ -26,7 +26,7 @@ public class KindFilenameMapperUtil { public static Map> 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(); diff --git a/core/src/main/resources/META-INF/fabric8/kind-fileindicator-mapping-default.adoc b/core/src/main/resources/META-INF/fabric8/kind-fileindicator-mapping-default.adoc deleted file mode 100644 index 86429e8699..0000000000 --- a/core/src/main/resources/META-INF/fabric8/kind-fileindicator-mapping-default.adoc +++ /dev/null @@ -1,104 +0,0 @@ -// There should be a new line between rows -// 1 Kind can be mapped to N Filename types -// Columns might be ordered alphabetical by type (for better reading) -// OpenShift elements go last ones -// Last filename type must be the canonical one ( full kind in all lowercase) -|=== -|Kind |Filename Type - -|ClusterRole -a|`cr`, `crole`, `clusterrole` - -|ConfigMap -a|`cm`, `configmap` - -|ClusterRoleBinding -a|`crb`, `clusterrb`, `clusterrolebinding` - -|CronJob -a|`cj`, `cronjob` - -|CustomResourceDefinition -a|`crd`, customerresourcedefinition - -|DaemonSet -a|`ds`, `daemonset` - -|Deployment -a|`deployment` - -|ImageStream -a|`is`, `imagestream` - -|ImageStreamTag -a|`istag`, `imagestreamtag` - -|Job -a|`job` - -|LimitRange -a|`lr`, `limitrange` - -|Namespace -a|`ns`, `namespace` - -|OAuthClient -a|`oauthclient` - -|PolicyBinding -a|`pb`, `policybinding` - -|PersistentVolume -a|`pv`, `persistentvolume` - -|PersistentVolumeClaim -a|`pvc`, `persistemtvolumeclaim` - -|Project -a|`project` - -|ProjectRequest -a|`pr`, `projectrequest` - -|ReplicationController -a|`rc` - -|ReplicaSet -a|`rs`, `replicaset` - -|ResourceQuota -a|`rq`, `resourcequota` - -|Role -a|`role` - -|RoleBinding -a|`rb`, `rolebinding` - -|RoleBindingRestriction -a|`rbr`, `rolebindingrestriction` - -|Secret -a|`secret` - -|Service -a|`svc`, `service` - -|ServiceAccount -a|`sa`, `serviceaccount` - -|StatefulSet -a|`statefulset` - -|BuildConfig -a|`bc`, `buildconfig` - -|DeploymentConfig -a|`dc`, `deploymentconfig` - -|Route -a|`route` - -|Template -a|`template` -|=== \ No newline at end of file diff --git a/core/src/main/resources/META-INF/fabric8/kind-filename-type-mapping-default.adoc b/core/src/main/resources/META-INF/fabric8/kind-filename-type-mapping-default.adoc new file mode 100644 index 0000000000..f82e532bb0 --- /dev/null +++ b/core/src/main/resources/META-INF/fabric8/kind-filename-type-mapping-default.adoc @@ -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` +|=== diff --git a/core/src/test/java/io/fabric8/maven/core/util/AsciiDocParserTest.java b/core/src/test/java/io/fabric8/maven/core/util/AsciiDocParserTest.java index 6fce77a704..35b61b7dab 100644 --- a/core/src/test/java/io/fabric8/maven/core/util/AsciiDocParserTest.java +++ b/core/src/test/java/io/fabric8/maven/core/util/AsciiDocParserTest.java @@ -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() @@ -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() @@ -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() diff --git a/doc/src/main/asciidoc/inc/_appendix.adoc b/doc/src/main/asciidoc/inc/_appendix.adoc index 86b612e00c..d1aaa9195b 100644 --- a/doc/src/main/asciidoc/inc/_appendix.adoc +++ b/doc/src/main/asciidoc/inc/_appendix.adoc @@ -3,4 +3,5 @@ == Kind/Filename Type Mapping -include::classpath:/META-INF/fabric8/kind-fileindicator-mapping-default.adoc[] \ No newline at end of file +[[appendix-kind-mapping]] +include::classpath:/META-INF/fabric8/kind-filename-type-mapping-default.adoc[] \ No newline at end of file diff --git a/doc/src/main/asciidoc/inc/_introduction.adoc b/doc/src/main/asciidoc/inc/_introduction.adoc index 629d0c4af1..f34c9f1215 100644 --- a/doc/src/main/asciidoc/inc/_introduction.adoc +++ b/doc/src/main/asciidoc/inc/_introduction.adoc @@ -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 < >. 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). diff --git a/enricher/standard/src/main/java/io/fabric8/maven/enricher/standard/ProjectEnricher.java b/enricher/standard/src/main/java/io/fabric8/maven/enricher/standard/ProjectEnricher.java index e1ee6a1dc1..17ba1af7d0 100644 --- a/enricher/standard/src/main/java/io/fabric8/maven/enricher/standard/ProjectEnricher.java +++ b/enricher/standard/src/main/java/io/fabric8/maven/enricher/standard/ProjectEnricher.java @@ -96,7 +96,7 @@ private Map 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()); } diff --git a/plugin/src/test/java/io/fabric8/maven/plugin/enricher/EnricherManagerTest.java b/plugin/src/test/java/io/fabric8/maven/plugin/enricher/EnricherManagerTest.java index ad2c0f462b..10181b41fa 100644 --- a/plugin/src/test/java/io/fabric8/maven/plugin/enricher/EnricherManagerTest.java +++ b/plugin/src/test/java/io/fabric8/maven/plugin/enricher/EnricherManagerTest.java @@ -94,6 +94,6 @@ public void enrichSimple() { assertNotNull(metadata); Map labels = metadata.getLabels(); assertNotNull(labels); - assertEquals("META-INF/fabric8", labels.get("provider")); + assertEquals("fabric8", labels.get("provider")); } }