Skip to content

Commit 4818c30

Browse files
Update Gateway Builder to use single Gateway Runtime
1 parent 3348363 commit 4818c30

20 files changed

Lines changed: 278 additions & 481 deletions

File tree

.vscode/launch.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
"${workspaceFolder}/gateway/configs/config.toml",
2424
],
2525
"env": {
26-
"APIP_GW_GATEWAY__CONTROLLER_STORAGE_SQLITE_PATH": "${workspaceFolder}/gateway/gateway-controller/data/gateway.db",
26+
"APIP_GW_CONTROLLER_STORAGE_SQLITE_PATH": "${workspaceFolder}/gateway/gateway-controller/data/gateway.db",
2727
"APIP_GW_CONTROLLER_CONTROLPLANE_HOST": "localhost:9243",
2828
"APIP_GW_REGISTRATION_TOKEN": "",
29-
"APIP_GW_GATEWAY__CONTROLLER_ROUTER_DOWNSTREAM__TLS_CERT__PATH": "${workspaceFolder}/gateway/gateway-controller/listener-certs/default-listener.crt",
30-
"APIP_GW_GATEWAY__CONTROLLER_ROUTER_DOWNSTREAM__TLS_KEY__PATH": "${workspaceFolder}/gateway/gateway-controller/listener-certs/default-listener.key",
31-
"APIP_GW_GATEWAY__CONTROLLER_ROUTER_POLICY__ENGINE_HOST": "host.docker.internal",
32-
"APIP_GW_GATEWAY__CONTROLLER_POLICIES_DEFINITIONS__PATH": "${workspaceFolder}/gateway/gateway-controller/default-policies",
33-
"APIP_GW_GATEWAY__CONTROLLER_ROUTER_LUA_REQUEST__TRANSFORMATION_SCRIPT__PATH": "${workspaceFolder}/gateway/gateway-controller/lua/request_transformation.lua",
29+
"APIP_GW_CONTROLLER_ROUTER_DOWNSTREAM__TLS_CERT__PATH": "${workspaceFolder}/gateway/gateway-controller/listener-certs/default-listener.crt",
30+
"APIP_GW_CONTROLLER_ROUTER_DOWNSTREAM__TLS_KEY__PATH": "${workspaceFolder}/gateway/gateway-controller/listener-certs/default-listener.key",
31+
"APIP_GW_CONTROLLER_ROUTER_POLICY__ENGINE_HOST": "host.docker.internal",
32+
"APIP_GW_CONTROLLER_POLICIES_DEFINITIONS__PATH": "${workspaceFolder}/gateway/gateway-controller/default-policies",
33+
"APIP_GW_CONTROLLER_ROUTER_LUA_REQUEST__TRANSFORMATION_SCRIPT__PATH": "${workspaceFolder}/gateway/gateway-controller/lua/request_transformation.lua",
3434
}
3535
},
3636
{

cli/src/cmd/gateway/image/build.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const (
3434
BuildCmdExample = `# Build gateway image with policies (uses current directory)
3535
ap gateway image build
3636
37-
# Build with custom name and version
38-
ap gateway image build --name my-gateway --version 1.0.0
37+
# Build with custom name
38+
ap gateway image build --name my-gateway
3939
4040
# Build with custom path containing manifest files
4141
ap gateway image build --name my-gateway --path ./my-policies --repository myregistry
@@ -52,7 +52,7 @@ var (
5252
imageRepository string
5353
gatewayBuilder string
5454
gatewayControllerBaseImg string
55-
routerBaseImg string
55+
gatewayRuntimeBaseImg string
5656
push bool
5757
noCache bool
5858
platform string
@@ -116,10 +116,10 @@ func initializeDefaults(manifest *policy.PolicyManifest) error {
116116
gatewayControllerBaseImg = fmt.Sprintf(utils.DefaultGatewayController, gatewayVersion)
117117
}
118118

119-
if manifest.Gateway.Images.Router != "" {
120-
routerBaseImg = manifest.Gateway.Images.Router
119+
if manifest.Gateway.Images.Runtime != "" {
120+
gatewayRuntimeBaseImg = manifest.Gateway.Images.Runtime
121121
} else {
122-
routerBaseImg = fmt.Sprintf(utils.DefaultGatewayRouter, gatewayVersion)
122+
gatewayRuntimeBaseImg = fmt.Sprintf(utils.DefaultGatewayRuntime, gatewayVersion)
123123
}
124124

125125
// Construct the full image tag: repository/name:version
@@ -203,7 +203,7 @@ func runUnifiedBuild() error {
203203
fmt.Println(" Resolved images:")
204204
fmt.Printf(" • Builder: %s\n", gatewayBuilder)
205205
fmt.Printf(" • Gateway Controller: %s\n", gatewayControllerBaseImg)
206-
fmt.Printf(" • Router: %s\n\n", routerBaseImg)
206+
fmt.Printf(" • Gateway Runtime: %s\n\n", gatewayRuntimeBaseImg)
207207

208208
// Step 3: Validate Manifest and Separate Policies
209209
fmt.Println("[3/6] Validating manifest")
@@ -259,9 +259,8 @@ func displayBuildSummary(manifest *policy.PolicyManifest, manifestFilePath strin
259259

260260
// Images built
261261
fmt.Printf("✓ Built gateway images with %d policies:\n", len(processed))
262-
fmt.Printf(" • %s/%s-policy-engine:%s\n", imageRepository, gatewayName, gatewayVersion)
262+
fmt.Printf(" • %s/%s-gateway-runtime:%s\n", imageRepository, gatewayName, gatewayVersion)
263263
fmt.Printf(" • %s/%s-gateway-controller:%s\n", imageRepository, gatewayName, gatewayVersion)
264-
fmt.Printf(" • %s/%s-router:%s\n", imageRepository, gatewayName, gatewayVersion)
265264
fmt.Println()
266265

267266
// Where images are
@@ -310,7 +309,7 @@ func runDockerBuild() error {
310309
TempDir: tempGatewayImageBuildDir,
311310
GatewayBuilder: gatewayBuilder,
312311
GatewayControllerBaseImage: gatewayControllerBaseImg,
313-
RouterBaseImage: routerBaseImg,
312+
GatewayRuntimeBaseImage: gatewayRuntimeBaseImg,
314313
ImageRepository: imageRepository,
315314
GatewayName: gatewayName,
316315
GatewayVersion: gatewayVersion,

cli/src/cmd/gateway/image/build.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ gateway:
5252
images: # Optional: Custom image paths
5353
builder: "internal-registry.company.com/wso2/gateway-builder:1.0.4"
5454
controller: "internal-registry.company.com/wso2/gateway-controller:1.0.4"
55-
router: "internal-registry.company.com/wso2/gateway-router:1.0.4"
55+
runtime: "internal-registry.company.com/wso2/gateway-runtime:1.0.4"
5656
policies:
5757
- name: api-key-auth
5858
filePath: api-key-auth-v0.1.0
@@ -64,7 +64,7 @@ policies:
6464
### Optional Fields
6565
- `gateway.images.builder`: Custom gateway builder image (defaults to `ghcr.io/wso2/api-platform/gateway-builder:<version>`)
6666
- `gateway.images.controller`: Custom gateway controller base image (defaults to `ghcr.io/wso2/api-platform/gateway-controller:<version>`)
67-
- `gateway.images.router`: Custom router base image (defaults to `ghcr.io/wso2/api-platform/gateway-router:<version>`)
67+
- `gateway.images.runtime`: Custom gateway runtime base image (defaults to `ghcr.io/wso2/api-platform/gateway-runtime:<version>`)
6868

6969
Each image path can be specified independently. If not provided, the default image path will be constructed using the `gateway.version`.
7070

cli/src/internal/gateway/docker_build.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type DockerBuildConfig struct {
3333
TempDir string
3434
GatewayBuilder string
3535
GatewayControllerBaseImage string
36-
RouterBaseImage string
36+
GatewayRuntimeBaseImage string
3737
ImageRepository string
3838
GatewayName string
3939
GatewayVersion string
@@ -71,8 +71,8 @@ func BuildGatewayImages(config DockerBuildConfig) error {
7171

7272
fmt.Println(" ✓ Gateway-builder completed")
7373

74-
// Step 2: Build the three images
75-
components := []string{"policy-engine", "gateway-controller", "router"}
74+
// Step 2: Build the two images
75+
components := []string{"gateway-runtime", "gateway-controller"}
7676

7777
if config.Platform != "" {
7878
// Use docker buildx for cross-platform builds
@@ -100,7 +100,7 @@ func BuildGatewayImages(config DockerBuildConfig) error {
100100
func runGatewayBuilder(config DockerBuildConfig, logFile *os.File) error {
101101
args := []string{"run", "--rm", "-v", config.TempDir + ":/workspace", config.GatewayBuilder,
102102
"-gateway-controller-base-image", config.GatewayControllerBaseImage,
103-
"-router-base-image", config.RouterBaseImage,
103+
"-gateway-runtime-base-image", config.GatewayRuntimeBaseImage,
104104
}
105105

106106
cmd := exec.Command("docker", args...)

cli/src/internal/policy/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type GatewayConfig struct {
3636
type GatewayImages struct {
3737
Builder string `yaml:"builder,omitempty"`
3838
Controller string `yaml:"controller,omitempty"`
39-
Router string `yaml:"router,omitempty"`
39+
Runtime string `yaml:"runtime,omitempty"`
4040
}
4141

4242
// ManifestPolicy represents a policy entry in the manifest

cli/src/utils/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const (
3535
DefaultImageRepository = "ghcr.io/wso2/api-platform"
3636
DefaultGatewayBuilder = "ghcr.io/wso2/api-platform/gateway-builder:%s" // %s = version
3737
DefaultGatewayController = "ghcr.io/wso2/api-platform/gateway-controller:%s" // %s = version
38-
DefaultGatewayRouter = "ghcr.io/wso2/api-platform/gateway-router:%s" // %s = version
38+
DefaultGatewayRuntime = "ghcr.io/wso2/api-platform/gateway-runtime:%s" // %s = version
3939

4040
// REST API Endpoints
4141
GatewayHealthPath = "/health"

docs/cli/customizing-gateway-policies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ gateway:
3737
images:
3838
builder: "internal-registry.company.com/wso2/gateway-builder:1.0.5" # Optional: override base image
3939
controller: "internal-registry.company.com/wso2/gateway-controller:1.0.5" # Optional: override base image
40-
router: "internal-registry.company.com/wso2/gateway-router:1.0.5" # Optional: override base image
40+
runtime: "internal-registry.company.com/wso2/gateway-runtime:1.0.5" # Optional: override base image
4141
policies:
4242
- name: api-key-auth
4343
filePath: api-key-auth-v0.1.0 # Local

gateway/gateway-builder/cmd/builder/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var (
5252

5353
func main() {
5454
defaultGatewayControllerBaseImage := "ghcr.io/wso2/api-platform/gateway-controller:" + Version
55-
defaultRouterBaseImage := "ghcr.io/wso2/api-platform/gateway-router:" + Version
55+
defaultGatewayRuntimeBaseImage := "ghcr.io/wso2/api-platform/gateway-runtime:" + Version
5656

5757
// Parse command-line flags
5858
manifestPath := flag.String("manifest", DefaultManifestFile, "Path to policy manifest file")
@@ -63,8 +63,8 @@ func main() {
6363
// Base image configuration
6464
gatewayControllerBaseImage := flag.String("gateway-controller-base-image", defaultGatewayControllerBaseImage,
6565
"Base image for gateway controller to extend (used in generated Dockerfile)")
66-
routerBaseImage := flag.String("router-base-image", defaultRouterBaseImage,
67-
"Base router image (used in generated Dockerfile)")
66+
gatewayRuntimeBaseImage := flag.String("gateway-runtime-base-image", defaultGatewayRuntimeBaseImage,
67+
"Base gateway runtime image (used in generated Dockerfile)")
6868

6969
// Logging flags
7070
logFormat := flag.String("log-format", "json", "Log format: text or json")
@@ -241,7 +241,8 @@ func main() {
241241
Policies: policies,
242242
OutputDir: *outputDir,
243243
GatewayControllerBaseImage: *gatewayControllerBaseImage,
244-
RouterBaseImage: *routerBaseImage,
244+
GatewayRuntimeBaseImage: *gatewayRuntimeBaseImage,
245+
BuilderVersion: Version,
245246
}
246247

247248
generateResult, err := dockerfileGenerator.GenerateAll()
@@ -325,9 +326,8 @@ func printDockerfileGenerationSummary(result *docker.GenerateResult, buildManife
325326
fmt.Println("Gateway Dockerfiles Generated")
326327
fmt.Println("========================================")
327328
fmt.Println("\nGenerated Dockerfiles:")
328-
fmt.Printf(" 1. Policy Engine: %s\n", result.PolicyEngineDockerfile)
329+
fmt.Printf(" 1. Gateway Runtime: %s\n", result.GatewayRuntimeDockerfile)
329330
fmt.Printf(" 2. Gateway Controller: %s\n", result.GatewayControllerDockerfile)
330-
fmt.Printf(" 3. Router: %s\n", result.RouterDockerfile)
331331

332332
fmt.Printf("Manifest: %s\n", manifestPath)
333333

gateway/gateway-builder/cmd/builder/main_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ func TestPrintDockerfileGenerationSummary(t *testing.T) {
7575
// Create mock docker result
7676
result := &docker.GenerateResult{
7777
Success: true,
78-
PolicyEngineDockerfile: "/tmp/output/Dockerfile.policy-engine",
78+
GatewayRuntimeDockerfile: "/tmp/output/Dockerfile.gateway-runtime",
7979
GatewayControllerDockerfile: "/tmp/output/Dockerfile.gateway-controller",
80-
RouterDockerfile: "/tmp/output/Dockerfile.router",
8180
}
8281

8382
// Create mock policies
@@ -95,18 +94,16 @@ func TestPrintDockerfileGenerationSummary(t *testing.T) {
9594

9695
// Verify expected content in output
9796
assert.Contains(t, output, "Gateway Dockerfiles Generated")
98-
assert.Contains(t, output, "Policy Engine")
97+
assert.Contains(t, output, "Gateway Runtime")
9998
assert.Contains(t, output, "Gateway Controller")
100-
assert.Contains(t, output, "Router")
10199
assert.Contains(t, output, "build-manifest.json")
102100
}
103101

104102
func TestPrintDockerfileGenerationSummary_WithMultiplePolicies(t *testing.T) {
105103
result := &docker.GenerateResult{
106104
Success: true,
107-
PolicyEngineDockerfile: "/output/Dockerfile.policy-engine",
105+
GatewayRuntimeDockerfile: "/output/Dockerfile.gateway-runtime",
108106
GatewayControllerDockerfile: "/output/Dockerfile.gateway-controller",
109-
RouterDockerfile: "/output/Dockerfile.router",
110107
}
111108

112109
policies := []*types.DiscoveredPolicy{

0 commit comments

Comments
 (0)