TreeGateway / tree-gateway

This is a full featured and free API Gateway
http://treegateway.com
MIT License
189 stars 42 forks source link

Generated Configuration Incorrect #168

Closed Proteles closed 5 years ago

Proteles commented 5 years ago

The configuration generated when starting treeGateway does not work. Documentation does not address issues.

Step 1: start treeGateway

$ treeGateway -r
reseting database
No configuration for gateway was found. Using default configuration and saving it on database.
info: Gateway listenning HTTP on port 8000
info: Gateway Admin Server listenning HTTP on port 8001

Step 2: Get configuration just used to start treeGateway $ treeGatewayConfig config --get > default.yaml

Step 3: Try updating treeGateway with the configuration it just gave me.

$ treeGatewayConfig gateway --update default.yaml 
Unexpected Fields: apis, gateway, middlewares

the generated default file

apis: []
gateway:
    underProxy: false
    protocol:
        http:
            listenPort: 8000
    admin:
        protocol:
            http:
                listenPort: 8001
        accessLogger:
            msg: 'HTTP {{req.method}} - {{res.statusCode}} - {{req.url}} ({{res.responseTime}}ms)'
            console:
                timestamp: true
                colorize: true
            file:
                timestamp: true
                json: false
                prettyPrint: true
                outputDir: ./logs
        userService:
            jwtSecret: 0806f3ab-8368-49cf-9fb6-4da84bf65d7b
        apiDocs:
            path: api-docs
    logger:
        level: info
        console:
            colorize: true
        file:
            timestamp: true
            outputDir: ./logs
            json: false
            prettyPrint: true
    accessLogger:
        msg: 'HTTP {{req.method}} - {{res.statusCode}} - {{req.url}} ({{res.responseTime}}ms)'
        console:
            timestamp: true
            colorize: true
        file:
            timestamp: true
            json: false
            prettyPrint: true
            outputDir: ./logs
    healthcheck: /healthcheck
middlewares: []

even after removing empty arrays for middlewares, and apis, it complains of the 'gateway' field. Unexpected Fields: gateway

thiagobustamante commented 5 years ago

Hi,

When you call:

treeGatewayConfig config --get > default.yaml

You are exporting not only the gateway configuration.... but the configuration for all TreeGateway components (the gateway itself, the list of installed middlewares, all APIs)

The command:

treeGatewayConfig gateway --update default.yaml 

would be used if you were configuring only the gateway component. If you want to import all configurations (contained in the default.yaml exported by the previous command), you should run:

treeGatewayConfig config --update default.yaml 

If you want to export only the gateway configuration, you can run:

treeGatewayConfig gateway --get > default.yaml
Proteles commented 5 years ago

Ahh! Ok. I was conflating "gateway" and "config" in the treeGatewayConfig command. I appreciate the explanation. /solved