diff --git a/Makefile b/Makefile index 2d1df77edd..4fe7aebffb 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,15 @@ ifndef MYSQL_PORT_3306_TCP_ADDR MYSQL_PORT_3306_TCP_ADDR = 127.0.0.1 endif +KIT_VERSION = "\ + -X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.appName=${APP_NAME} \ + -X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.version=${VERSION} \ + -X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.branch=${BRANCH} \ + -X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.revision=${REVISION} \ + -X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.buildDate=${NOW} \ + -X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.buildUser=${USER} \ + -X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.goVersion=${GOVERSION}" + all: build define HELP_TEXT @@ -85,13 +94,8 @@ endif build: export GOGC = off build: export CGO_ENABLED=0 build: .prefix - go build -i -o ${OUTPUT} -ldflags "\ - -X github.com/kolide/fleet/server/version.version=${VERSION} \ - -X github.com/kolide/fleet/server/version.branch=${BRANCH} \ - -X github.com/kolide/fleet/server/version.revision=${REVISION} \ - -X github.com/kolide/fleet/server/version.buildDate=${NOW} \ - -X github.com/kolide/fleet/server/version.buildUser=${USER} \ - -X github.com/kolide/fleet/server/version.goVersion=${GOVERSION}" + $(eval APP_NAME = fleet) + go build -i -o ${OUTPUT} -ldflags ${KIT_VERSION} ./cmd/fleet lint-js: eslint frontend --ext .js,.jsx diff --git a/cli/config_dump.go b/cmd/fleet/config_dump.go similarity index 98% rename from cli/config_dump.go rename to cmd/fleet/config_dump.go index 2ecaf837f5..bab2ccdb77 100644 --- a/cli/config_dump.go +++ b/cmd/fleet/config_dump.go @@ -1,4 +1,4 @@ -package cli +package main import ( "fmt" diff --git a/cli/healthz_test.go b/cmd/fleet/healthz_test.go similarity index 98% rename from cli/healthz_test.go rename to cmd/fleet/healthz_test.go index b309288dbe..4786158a7d 100644 --- a/cli/healthz_test.go +++ b/cmd/fleet/healthz_test.go @@ -1,4 +1,4 @@ -package cli +package main import ( "errors" diff --git a/cli/root.go b/cmd/fleet/main.go similarity index 80% rename from cli/root.go rename to cmd/fleet/main.go index e483c265e5..d11f481f6c 100644 --- a/cli/root.go +++ b/cmd/fleet/main.go @@ -1,15 +1,22 @@ -package cli +package main import ( "fmt" + "math/rand" "os" + "time" + _ "github.com/go-sql-driver/mysql" "github.com/kolide/fleet/server/config" "github.com/spf13/cobra" ) -// Launch is the entrypoint that sets up and runs the Kolide commands. -func Launch() { +func init() { + rand.Seed(time.Now().UnixNano()) +} + +// Launch is the entrypoint that sets up and runs the Fleet commands. +func main() { rootCmd := createRootCmd() configManager := config.NewManager(rootCmd) @@ -33,10 +40,9 @@ func initFatal(err error, message string) { func createRootCmd() *cobra.Command { // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "kolide", + Use: "fleet", Short: "osquery management and orchestration", - Long: ` -osquery management and orchestration + Long: `Kolide Fleet (https://kolide.com/fleet) Configurable Options: diff --git a/cli/prepare.go b/cmd/fleet/prepare.go similarity index 91% rename from cli/prepare.go rename to cmd/fleet/prepare.go index 03f95bb7c3..baf8450512 100644 --- a/cli/prepare.go +++ b/cmd/fleet/prepare.go @@ -1,4 +1,4 @@ -package cli +package main import ( "bufio" @@ -20,11 +20,11 @@ func createPrepareCmd(configManager config.Manager) *cobra.Command { var prepareCmd = &cobra.Command{ Use: "prepare", - Short: "Subcommands for initializing kolide infrastructure", + Short: "Subcommands for initializing Fleet infrastructure", Long: ` -Subcommands for initializing kolide infrastructure +Subcommands for initializing Fleet infrastructure -To setup kolide infrastructure, use one of the available commands. +To setup Fleet infrastructure, use one of the available commands. `, Run: func(cmd *cobra.Command, args []string) { cmd.Help() @@ -58,7 +58,7 @@ To setup kolide infrastructure, use one of the available commands. if !noPrompt { fmt.Printf("################################################################################\n" + "# WARNING:\n" + - "# This will perform Kolide database migrations. Please back up your data before\n" + + "# This will perform Fleet database migrations. Please back up your data before\n" + "# continuing.\n" + "#\n" + "# Press Enter to continue, or Control-c to exit.\n" + diff --git a/cli/serve.go b/cmd/fleet/serve.go similarity index 96% rename from cli/serve.go rename to cmd/fleet/serve.go index 1fb131ed7a..b67fda972b 100644 --- a/cli/serve.go +++ b/cmd/fleet/serve.go @@ -1,4 +1,4 @@ -package cli +package main import ( "context" @@ -24,7 +24,7 @@ import ( "github.com/kolide/fleet/server/pubsub" "github.com/kolide/fleet/server/service" "github.com/kolide/fleet/server/sso" - "github.com/kolide/fleet/server/version" + "github.com/kolide/kit/version" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/spf13/cobra" @@ -42,14 +42,14 @@ func createServeCmd(configManager config.Manager) *cobra.Command { serveCmd := &cobra.Command{ Use: "serve", - Short: "Launch the kolide server", + Short: "Launch the Fleet server", Long: ` -Launch the kolide server +Launch the Fleet server -Use kolide serve to run the main HTTPS server. The Kolide server bundles +Use fleet serve to run the main HTTPS server. The Fleet server bundles together all static assets and dependent libraries into a statically linked go binary (which you're executing right now). Use the options below to customize -the way that the kolide server works. +the way that the Fleet server works. `, Run: func(cmd *cobra.Command, args []string) { config := configManager.LoadConfig() @@ -83,8 +83,8 @@ the way that the kolide server works. case kolide.SomeMigrationsCompleted: fmt.Printf("################################################################################\n"+ "# WARNING:\n"+ - "# Your Kolide database is missing required migrations. This is likely to cause\n"+ - "# errors in Kolide.\n"+ + "# Your Fleet database is missing required migrations. This is likely to cause\n"+ + "# errors in Fleet.\n"+ "#\n"+ "# Run `%s prepare db` to perform migrations.\n"+ "################################################################################\n", @@ -93,7 +93,7 @@ the way that the kolide server works. case kolide.NoMigrationsCompleted: fmt.Printf("################################################################################\n"+ "# ERROR:\n"+ - "# Your Kolide database is not initialized. Kolide cannot start up.\n"+ + "# Your Fleet database is not initialized. Fleet cannot start up.\n"+ "#\n"+ "# Run `%s prepare db` to initialize the database.\n"+ "################################################################################\n", diff --git a/cli/version.go b/cmd/fleet/version.go similarity index 86% rename from cli/version.go rename to cmd/fleet/version.go index e654332df4..5b8041a4e7 100644 --- a/cli/version.go +++ b/cmd/fleet/version.go @@ -1,8 +1,8 @@ -package cli +package main import ( "github.com/kolide/fleet/server/config" - "github.com/kolide/fleet/server/version" + "github.com/kolide/kit/version" "github.com/spf13/cobra" ) @@ -13,7 +13,7 @@ func createVersionCmd(configManager config.Manager) *cobra.Command { ) var versionCmd = &cobra.Command{ Use: "version", - Short: "Print kolide version", + Short: "Print Fleet version", Long: ` Print version information and related build info`, Run: func(cmd *cobra.Command, args []string) { diff --git a/glide.lock b/glide.lock index 578cdbe06e..eecb2bbe71 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: a580dd48772ffed8168170ef7c7874e1dbe74f2288d44613378367e05d8ec722 -updated: 2017-08-13T10:48:17.061574863-05:00 +hash: 50aef4de2679ec2dab8998862af276111be16e0e53d73018fae85cc896f9da8f +updated: 2017-10-06T17:42:16.1040243-06:00 imports: - name: github.com/alecthomas/template version: a0175ee3bccc567396460bf5acd36800cb10c49c @@ -53,7 +53,10 @@ imports: version: c3cefd437628a0b7d31b34fe44b3a7a540e98527 subpackages: - proto + - ptypes - ptypes/any + - ptypes/duration + - ptypes/timestamp - name: github.com/gorilla/context version: 08b5f424b9271eedf6f9f0ce86cb9396ed337a42 - name: github.com/gorilla/mux @@ -90,6 +93,11 @@ imports: repo: git@github.com:kolide/agent-api.git - name: github.com/kolide/goose version: 4a7848793d4402d338de853019ad72b9a4b3e68e +- name: github.com/kolide/kit + version: a2a44361a9498eabc6814e96c5a6f378305b771e + repo: git@github.com:kolide/kit.git + subpackages: + - version - name: github.com/kolide/osquery-go version: 5419715d060ff8c2e1b7f6ff5a8127ac2ce3fbdc subpackages: @@ -203,11 +211,12 @@ imports: subpackages: - googleapis/rpc/status - name: google.golang.org/grpc - version: b8669c35455183da6d5c474ea6e72fbf55183274 + version: f92cdcd7dcdc69e81b2d7b338479a19a8723cfa3 subpackages: - codes + - connectivity - credentials - - grpclb/grpc_lb_v1 + - grpclb/grpc_lb_v1/messages - grpclog - internal - keepalive diff --git a/glide.yaml b/glide.yaml index 85b9515e95..3ded6fa373 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,5 +1,9 @@ package: github.com/kolide/fleet import: +- package: github.com/kolide/kit + repo: git@github.com:kolide/kit.git + subpackages: + - version - package: github.com/alecthomas/template version: a0175ee3bccc567396460bf5acd36800cb10c49c subpackages: diff --git a/main.go b/main.go deleted file mode 100644 index 4563a61d7e..0000000000 --- a/main.go +++ /dev/null @@ -1,17 +0,0 @@ -package main - -import ( - "math/rand" - "time" - - _ "github.com/go-sql-driver/mysql" - "github.com/kolide/fleet/cli" -) - -func init() { - rand.Seed(time.Now().UnixNano()) -} - -func main() { - cli.Launch() -} diff --git a/server/version/version.go b/server/version/version.go deleted file mode 100644 index 4780582e52..0000000000 --- a/server/version/version.go +++ /dev/null @@ -1,72 +0,0 @@ -// Package version provides utilities for displaying version information -package version - -import ( - "encoding/json" - "fmt" - "net/http" -) - -// info vars -// set at build time with ldflags -// example: -// go build -ldflags "-X github.com/kolide/fleet/version.version=1.0.0-development" -var ( - version = "unknown" - branch = "unknown" - revision = "unknown" - goVersion = "unknown" - buildDate = "unknown" - buildUser = "unknown" -) - -// Info holds version and build info about Kolide -type Info struct { - Version string `json:"version"` - Branch string `json:"branch"` - Revision string `json:"revision"` - GoVersion string `json:"go_version"` - BuildDate string `json:"build_date"` - BuildUser string `json:"build_user"` -} - -// Version returns a struct with the current version information -func Version() Info { - return Info{ - Version: version, - Branch: branch, - Revision: revision, - GoVersion: goVersion, - BuildDate: buildDate, - BuildUser: buildUser, - } -} - -// Print outputs the app name and version string -func Print() { - v := Version() - fmt.Printf("kolide version %s\n", v.Version) -} - -// PrintFull outputs the app name and detailed version information -func PrintFull() { - v := Version() - fmt.Printf("kolide - version %s\n", v.Version) - fmt.Printf(" branch: \t%s\n", v.Branch) - fmt.Printf(" revision: \t%s\n", v.Revision) - fmt.Printf(" build date: \t%s\n", v.BuildDate) - fmt.Printf(" build user: \t%s\n", v.BuildUser) - fmt.Printf(" go version: \t%s\n", v.GoVersion) -} - -// Handler provides an HTTP Handler which returns JSON formatted version info -func Handler() http.Handler { - v := Version() - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=utf-8") - enc := json.NewEncoder(w) - enc.SetIndent("", " ") - enc.Encode(v) - - }) -}