Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor source code inspectors to avoid using redgexp for markup languages #1334

Merged
merged 2 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/RestWithUndertow.java → examples/RestDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
//
// To run this integrations use:
//
// kamel run --name=rest-with-undertow --dependency=camel-rest --dependency=camel-undertow examples/RestWithUndertow.java
// kamel run examples/RestDSL.java
//
import org.apache.camel.Exchange;

public class RestWithUndertow extends org.apache.camel.builder.RouteBuilder {
public class RestDSL extends org.apache.camel.builder.RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration()
.component("undertow")
.host("0.0.0.0")
.port("8080");

Expand Down
102 changes: 0 additions & 102 deletions pkg/metadata/http.go

This file was deleted.

37 changes: 19 additions & 18 deletions pkg/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ import (
// ExtractAll returns metadata information from all listed source codes
func ExtractAll(catalog *camel.RuntimeCatalog, sources []v1.SourceSpec) IntegrationMetadata {
// neutral metadata
meta := NewIntegrationMetadata()
meta := src.NewMetadata()
meta.PassiveEndpoints = true
meta.RequiresHTTPService = false
meta.ExposesHTTPServices = false

for _, source := range sources {
meta = merge(meta, Extract(catalog, source))
meta = merge(meta, Extract(catalog, source).Metadata)
}
return IntegrationMetadata{
Metadata: meta,
}
return meta
}

func merge(m1 IntegrationMetadata, m2 IntegrationMetadata) IntegrationMetadata {
func merge(m1 src.Metadata, m2 src.Metadata) src.Metadata {
d := strset.Union(m1.Dependencies, m2.Dependencies)

f := make([]string, 0, len(m1.FromURIs)+len(m2.FromURIs))
Expand All @@ -52,13 +54,11 @@ func merge(m1 IntegrationMetadata, m2 IntegrationMetadata) IntegrationMetadata {
t = append(t, m1.ToURIs...)
t = append(t, m2.ToURIs...)

return IntegrationMetadata{
Metadata: src.Metadata{
FromURIs: f,
ToURIs: t,
Dependencies: d,
},
RequiresHTTPService: m1.RequiresHTTPService || m2.RequiresHTTPService,
return src.Metadata{
FromURIs: f,
ToURIs: t,
Dependencies: d,
ExposesHTTPServices: m1.ExposesHTTPServices || m2.ExposesHTTPServices,
PassiveEndpoints: m1.PassiveEndpoints && m2.PassiveEndpoints,
}
}
Expand All @@ -73,15 +73,16 @@ func Extract(catalog *camel.RuntimeCatalog, source v1.SourceSpec) IntegrationMet

language := source.InferLanguage()

m := NewIntegrationMetadata()
meta := src.NewMetadata()
meta.PassiveEndpoints = true
meta.ExposesHTTPServices = false

// TODO: handle error
_ = src.InspectorForLanguage(catalog, language).Extract(source, &m.Metadata)
_ = src.InspectorForLanguage(catalog, language).Extract(source, &meta)

m.RequiresHTTPService = requiresHTTPService(catalog, source, m.FromURIs)
m.PassiveEndpoints = hasOnlyPassiveEndpoints(catalog, source, m.FromURIs)

return m
return IntegrationMetadata{
Metadata: meta,
}
}

// Each --
Expand Down
Loading