Fix fix metadata retrieval logic
@@ -21,6 +21,8 @@ import org.apache.camel.component.extension.metadata.MetaDataBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.syndesis.connector.support.util.ConnectorOptions;
+
+import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -39,7 +41,9 @@ public class KnativeMetaDataExtension extends AbstractMetaDataExtension {
@Override
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
public Optional<MetaData> meta(Map<String, Object> parameters) {
-
+ String name = ConnectorOptions.extractOption(parameters, "name");
+ if (name == null) {
+ // lookup resources on Kubernetes
String type = ConnectorOptions.extractOption(parameters, "type");
if (type == null) {
type = TYPE_CHANNEL;
@@ -65,5 +69,15 @@ public class KnativeMetaDataExtension extends AbstractMetaDataExtension {
.withPayload(channelNames)
.build()
);
+ } else {
+ // Just return the chosen resource
+ return Optional.of(
+ MetaDataBuilder.on(getCamelContext())
+ .withAttribute(MetaData.CONTENT_TYPE, "text/plain")
+ .withAttribute(MetaData.JAVA_TYPE, String.class)
+ .withPayload(Collections.singleton(name))
+ .build()
+ );
+ }
}
}
