-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(checkhealth): create new command to check overall status
- Loading branch information
Showing
5 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
CURRENT_DIR := $(shell pwd) | ||
|
||
clean: | ||
@echo "\n----- Start CLEAN -----\n" | ||
@echo "# Remove all the daje metadata and builds..." | ||
rm -r $(CURRENT_DIR)/bin &>/dev/null | ||
@echo "\n----- End CLEAN -----" | ||
|
||
# The version in this build has the form `<tag>|<commit_sha>` | ||
build: | ||
@echo "PROD: Building daje..." | ||
build: clean | ||
@echo "\n----- Start BUILD -----\n" | ||
@echo "# Building daje for production environment..." | ||
go build -ldflags "-X github.com/Schrodinger-Hat/Daje/constants.Version=$(shell git describe --exact-match --tags $(git rev-parse HEAD) 2>/dev/null || git rev-parse --short HEAD)" -o ./bin/daje . | ||
@echo "\n----- End BUILD -----" | ||
|
||
# For debugging reason the version in this build has the form `<current_branch>+<commit_sha>+<number_of_changes_not_committed>` | ||
build-test-dev: | ||
@echo "TEST-DEV: Building daje for testing pourpose..." | ||
rm -rf $(CURRENT_DIR)/testdata | ||
build-test-dev: clean | ||
@echo "\n----- Start BUILD-TEST-DEV -----\n" | ||
@echo "# Building daje for development environment..." | ||
go build -ldflags "-X github.com/Schrodinger-Hat/Daje/constants.DajeConfigBaseDir=$(CURRENT_DIR)/testdata -X github.com/Schrodinger-Hat/Daje/constants.Version=$(shell git branch --show-current)+$(shell git rev-parse --short origin/main)+$(shell git status --porcelain | wc -l)" -o ./bin/daje . | ||
@echo "\n----- End BUILD-TEST-DEV -----" | ||
|
||
checkhealth: build-test-dev | ||
@echo "\n----- Start CHECKHEALTH -----\n" | ||
@echo "# run checkhealth command..." | ||
./bin/daje checkhealth | ||
@echo "\n----- End CHECKHEALTH -----" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
package constants | ||
|
||
import "path" | ||
|
||
var DajeConfigBaseDir = "~/.config/" | ||
var DajeDotfileName = "daje.conf" | ||
var DajeDotfilePath = path.Join(DajeConfigBaseDir, DajeDotfileName) | ||
|
||
var Version = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package tuning | ||
|
||
// TODO: when the first tuning options will be available we need something to prove that the system is tuned accordingly to the configuration | ||
func IsSystemTuned() bool { | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package checkhealth | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/Schrodinger-Hat/Daje/constants" | ||
"github.com/Schrodinger-Hat/Daje/internal/tuning" | ||
) | ||
|
||
func NewCmdCheckhealth() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "checkhealth [flags]", | ||
Short: "Check Daje health", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return submitAction() | ||
}, | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
func submitAction() error { | ||
|
||
fmt.Println("Version: ", constants.Version) | ||
fmt.Println("Configuration path: ", constants.DajeDotfilePath) | ||
fmt.Println("Tuning: ", tuning.IsSystemTuned()) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters