Skip to content

Latest commit

 

History

History
97 lines (69 loc) · 2.78 KB

development-guide.md

File metadata and controls

97 lines (69 loc) · 2.78 KB

Development guide

Run your first build

Follow the "Run from source code" section on README.

Setup environment for development

Fork KHI repository

You can't create a new branch our repository directly. Please fork our repository on your account to modify.

Setup commit signature verification

Please check this document to make sure your commits are signed. Our repository can't accept unsigned commits.

Setup Git hook

Run the following shell command to setup Git hook. It runs format or lint codes before commiting changes.

$ make setup-hooks

Setup VSCode config

Save the following code as .vscode/launch.json.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Start KHI Backend",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "./cmd/kubernetes-history-inspector/",
            "cwd": "${workspaceFolder}",
            "args": [
                "--host",
                "127.0.0.1",
                "--port",
                "8080",
                "--frontend-asset-folder",
                "./dist",
            ],
            "dlvLoadConfig": {
                "followPointers": true,
                "maxVariableRecurse": 1,
                "maxStringLen": 100000,
                "maxArrayValues": 64,
                "maxStructFields": -1
            },
        }
    ], 
}

You can run the server with VSCode. You can refer this document for more details.

Run frontend server for development

To develop frontend code, we usually start Angular dev server on port 4200 with the following code.

$ make watch-web

This will build the frontend code with the configuration to access APIs on localhost:8080. You can use KHI with accessing localhost:4200 instead of localhost:8080. Angular dev server automatically build and serve the new build when you change the frontend code.

Run test

Run the following code to verify frontend and backend codes.

$ make test

When you want to run backend tests without Cloud Logging, run the following code.

$ go test ./... -args -skip-cloud-logging=true

Auto generated codes

Generated codes from backend codes

Several frontend codes are automativally generated from backend codes.

  • /web/src/app/generated.sass
  • /web/src/app/generated.ts

These files are generated with scripts/frontend-codegen/main.go Golang codes. It reads several Golang constant arrays and generate frontend codes with templates.