diff --git a/README.md b/README.md index fb666ee..b90c28e 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,13 @@ Flags: -h, --help help for sync --http.port string listem port for http endpoints (default ":9754") --kubeconfig string (optional) absolute path to the kubeconfig file - --log.level string listem port for http endpoints (default "info") + --log.level string log level (default "info") --namespace string namespace that will store the dashboard config map (default "default") --repository.auth.password string password to perform authentication --repository.auth.username string username to perform authentication - --repository.branch string path to clone the git repository (default "main") - --repository.path string path to clone the git repository + --repository.branch string git repository branch (default "main") --repository.url string git repository url - --sync-timer duration interval to sync and sync dashboards (default 5m0s) + --sync-timer duration interval to sync and sync dashboards (default 5m) ``` @@ -33,7 +32,7 @@ Contributions are very welcome! See our [CONTRIBUTING.md](CONTRIBUTING.md) for m ## Docker images -Docker images are available on [Docker Hub](https://hub.docker.com/repository/docker/ntakashi/gitana). +Docker images are available on [Docker Hub](https://hub.docker.com/r/ntakashi/gitana). ## Building from source diff --git a/cmd/sync.go b/cmd/sync.go index 0a58ee6..d95ff60 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -17,6 +17,7 @@ package cmd import ( "context" + "encoding/json" "log" "net/http" "os" @@ -49,6 +50,7 @@ var syncCmd = &cobra.Command{ logrus.Info("Welcome to gitana...") if err := pcmd.Validate(); err != nil { + logrus.Error(err) os.Exit(1) } @@ -108,6 +110,38 @@ func createHttpServer(port string) *http.Server { mux := http.NewServeMux() mux.Handle("/metrics", promhttp.Handler()) + mux.HandleFunc("/-/health", func(rw http.ResponseWriter, _ *http.Request) { + rw.WriteHeader(http.StatusOK) + rw.Header().Set("Content-Type", "application/json") + + resp := map[string]string{ + "message": "Healthy", + } + + jsonResp, err := json.Marshal(resp) + + if err != nil { + log.Fatalf("Error happened in JSON marshal. Err: %s", err) + } + + rw.Write(jsonResp) + }) + mux.HandleFunc("/-/ready", func(rw http.ResponseWriter, _ *http.Request) { + rw.WriteHeader(http.StatusOK) + rw.Header().Set("Content-Type", "application/json") + + resp := map[string]string{ + "message": "Ready", + } + + jsonResp, err := json.Marshal(resp) + + if err != nil { + log.Fatalf("Error happened in JSON marshal. Err: %s", err) + } + + rw.Write(jsonResp) + }) srv := &http.Server{ Addr: port, diff --git a/go.mod b/go.mod index 02d22b6..8fe6a28 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/sirupsen/logrus v1.8.1 github.com/spf13/cobra v1.2.1 github.com/spf13/viper v1.9.0 - github.com/stretchr/testify v1.7.0 // indirect + github.com/stretchr/testify v1.7.0 github.com/xanzy/ssh-agent v0.3.1 // indirect golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/net v0.0.0-20210929161516-d455829e376d // indirect