diff --git a/annotations/knative-annotations/src/main/java/io/dekorate/knative/manifest/KnativeManifestGenerator.java b/annotations/knative-annotations/src/main/java/io/dekorate/knative/manifest/KnativeManifestGenerator.java
index 727b57158..a12afcfdc 100644
--- a/annotations/knative-annotations/src/main/java/io/dekorate/knative/manifest/KnativeManifestGenerator.java
+++ b/annotations/knative-annotations/src/main/java/io/dekorate/knative/manifest/KnativeManifestGenerator.java
@@ -145,7 +145,7 @@ public void generate(KnativeConfig config) {
resourceRegistry.decorate(KNATIVE, new AddCommitIdAnnotationDecorator());
resourceRegistry.decorate(KNATIVE,
- new ApplyPortNameDecorator(null, null,
+ new ApplyPortNameDecorator(config.getName(), null,
config.getHttpTransportVersion() != null ? config.getHttpTransportVersion().name().toLowerCase() : "http1",
Ports.webPortNames().toArray(new String[Ports.webPortNames().size()])));
addDecorators(KNATIVE, config);
diff --git a/tests/issue-knative-existing-deployment-resource/pom.xml b/tests/issue-knative-existing-deployment-resource/pom.xml
new file mode 100644
index 000000000..7a51a6b7c
--- /dev/null
+++ b/tests/issue-knative-existing-deployment-resource/pom.xml
@@ -0,0 +1,82 @@
+
+
+ 4.0.0
+
+
+ dekorate-tests
+ io.dekorate
+ 3.1-SNAPSHOT
+ ../
+
+
+ io.dekorate
+ issue-knative-existing-deployment-resource
+ Dekorate :: Tests :: Annotations :: Knative :: Existing Deployment resource
+
+
+
+ my-secret
+
+
+
+
+ io.dekorate
+ kubernetes-annotations
+ ${project.version}
+
+
+ io.dekorate
+ knative-annotations
+ ${project.version}
+
+
+ io.dekorate
+ dekorate-spring-boot
+ ${project.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ ${version.spring-boot}
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${version.junit-jupiter}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${version.junit-jupiter}
+ test
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ true
+
+ false
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${version.spring-boot}
+
+
+
+
diff --git a/tests/issue-knative-existing-deployment-resource/src/main/java/io/dekorate/annotationless/DemoApplication.java b/tests/issue-knative-existing-deployment-resource/src/main/java/io/dekorate/annotationless/DemoApplication.java
new file mode 100644
index 000000000..8bd220c62
--- /dev/null
+++ b/tests/issue-knative-existing-deployment-resource/src/main/java/io/dekorate/annotationless/DemoApplication.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2018 The original authors.
+ *
+ * Licensed 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.
+ */
+package io.dekorate.annotationless;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(DemoApplication.class, args);
+ }
+
+}
diff --git a/tests/issue-knative-existing-deployment-resource/src/main/java/io/dekorate/annotationless/HelloController.java b/tests/issue-knative-existing-deployment-resource/src/main/java/io/dekorate/annotationless/HelloController.java
new file mode 100644
index 000000000..1d952335a
--- /dev/null
+++ b/tests/issue-knative-existing-deployment-resource/src/main/java/io/dekorate/annotationless/HelloController.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2018 The original authors.
+ *
+ * Licensed 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.
+ *
+**/
+
+package io.dekorate.annotationless;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class HelloController {
+
+ private static final String HELLO = "hello world!";
+
+ @RequestMapping("/")
+ public String hello() {
+ return HELLO;
+ }
+}
diff --git a/tests/issue-knative-existing-deployment-resource/src/main/resources/application.properties b/tests/issue-knative-existing-deployment-resource/src/main/resources/application.properties
new file mode 100644
index 000000000..9f96389cd
--- /dev/null
+++ b/tests/issue-knative-existing-deployment-resource/src/main/resources/application.properties
@@ -0,0 +1 @@
+dekorate.options.input-path=kubernetes
diff --git a/tests/issue-knative-existing-deployment-resource/src/main/resources/kubernetes/knative.yml b/tests/issue-knative-existing-deployment-resource/src/main/resources/kubernetes/knative.yml
new file mode 100644
index 000000000..69f6a56b6
--- /dev/null
+++ b/tests/issue-knative-existing-deployment-resource/src/main/resources/kubernetes/knative.yml
@@ -0,0 +1,49 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: example
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ name: example
+ template:
+ metadata:
+ labels:
+ name: example
+ spec:
+ containers:
+ - image: docker.io/group/app
+ name: example
+ livenessProbe:
+ failureThreshold: 3
+ httpGet:
+ path: /health/live
+ port: 8080
+ scheme: HTTP
+ initialDelaySeconds: 0
+ periodSeconds: 30
+ successThreshold: 1
+ timeoutSeconds: 10
+ readinessProbe:
+ failureThreshold: 3
+ httpGet:
+ path: /health/ready
+ port: 8080
+ scheme: HTTP
+ initialDelaySeconds: 0
+ periodSeconds: 30
+ successThreshold: 1
+ timeoutSeconds: 10
+ ports:
+ - containerPort: 8080
+ name: http
+ protocol: TCP
+ env:
+ - name: REGISTRY_AUTH_ANONYMOUS_READ_ACCESS_ENABLED
+ value: "true"
+ resources:
+ limits:
+ memory: 768Mi
+ requests:
+ memory: 128Mi
diff --git a/tests/issue-knative-existing-deployment-resource/src/test/java/io/dekorate/example/IssueExistingDeploymentResourceTest.java b/tests/issue-knative-existing-deployment-resource/src/test/java/io/dekorate/example/IssueExistingDeploymentResourceTest.java
new file mode 100644
index 000000000..4c99f4904
--- /dev/null
+++ b/tests/issue-knative-existing-deployment-resource/src/test/java/io/dekorate/example/IssueExistingDeploymentResourceTest.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2018 The original authors.
+ *
+ * Licensed 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.
+ *
+**/
+
+package io.dekorate.example;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.Optional;
+
+import org.junit.jupiter.api.Test;
+
+import io.dekorate.utils.Serialization;
+import io.fabric8.kubernetes.api.model.HasMetadata;
+import io.fabric8.kubernetes.api.model.KubernetesList;
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+
+public class IssueExistingDeploymentResourceTest {
+
+ @Test
+ public void shouldContainSecret() {
+ KubernetesList list = Serialization
+ .unmarshalAsList(getClass().getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
+ assertNotNull(list);
+ Deployment deployment = findFirst(list, Deployment.class).orElseThrow(() -> new IllegalStateException());
+ assertEquals("http", deployment.getSpec().getTemplate().getSpec().getContainers()
+ .stream()
+ .flatMap(c -> c.getPorts().stream())
+ .map(p -> p.getName())
+ .findFirst().orElse(null));
+ }
+
+ Optional findFirst(KubernetesList list, Class t) {
+ return (Optional) list.getItems().stream()
+ .filter(i -> t.isInstance(i))
+ .findFirst();
+ }
+}
diff --git a/tests/pom.xml b/tests/pom.xml
index 542bb39d1..8d129c955 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -88,6 +88,7 @@
feat-1083-ingress-rules
issue-existing-route-resource
feat-ingress-class-name
+ issue-knative-existing-deployment-resource