mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-21 10:45:25 +02:00
Prepare for release (#37)
* Prepare for release Added LICENSE, set version and configured GoReleaser/Docker * Updated LICENSE
This commit is contained in:
@@ -5,18 +5,32 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cirruslabs/orchard/internal/controller"
|
||||
"github.com/cirruslabs/orchard/internal/netconstants"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var ErrRunFailed = errors.New("failed to run controller")
|
||||
|
||||
var address string
|
||||
|
||||
func newRunCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "run",
|
||||
Short: "Run the controller",
|
||||
RunE: runController,
|
||||
}
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = strconv.FormatInt(netconstants.DefaultControllerPort, 10)
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringVarP(&address, "listen", "l", fmt.Sprintf(":%s", port), "address to listen on")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func runController(cmd *cobra.Command, args []string) (err error) {
|
||||
@@ -53,6 +67,7 @@ func runController(cmd *cobra.Command, args []string) (err error) {
|
||||
}
|
||||
|
||||
controller, err := controller.New(
|
||||
controller.WithListenAddr(address),
|
||||
controller.WithDataDir(dataDir),
|
||||
controller.WithLogger(logger),
|
||||
controller.WithTLSConfig(&tls.Config{
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/cirruslabs/orchard/internal/command/portforward"
|
||||
"github.com/cirruslabs/orchard/internal/command/stop"
|
||||
"github.com/cirruslabs/orchard/internal/command/worker"
|
||||
"github.com/cirruslabs/orchard/internal/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -19,6 +20,7 @@ func NewRootCmd() *cobra.Command {
|
||||
Use: "orchard",
|
||||
SilenceUsage: true,
|
||||
SilenceErrors: true,
|
||||
Version: version.FullVersion,
|
||||
}
|
||||
|
||||
addGroupedCommands(command, "Working With Resources:",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
goversion "github.com/hashicorp/go-version"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
var (
|
||||
Version = "unknown"
|
||||
Commit = "unknown"
|
||||
FullVersion = ""
|
||||
)
|
||||
|
||||
//nolint:gochecknoinits
|
||||
func init() {
|
||||
if Version == "unknown" {
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if ok {
|
||||
// We parse the version here for two reasons:
|
||||
// * to weed out the "(devel)" version and fallback to "unknown" instead
|
||||
// (see https://github.com/golang/go/issues/29228 for details on when this might happen)
|
||||
// * to remove the "v" prefix from the BuildInfo's version (e.g. "v0.7.0") and thus be consistent
|
||||
// with the binary builds, where the version string would be "0.7.0" instead
|
||||
semver, err := goversion.NewSemver(info.Main.Version)
|
||||
if err == nil {
|
||||
Version = semver.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FullVersion = fmt.Sprintf("%s-%s", Version, Commit)
|
||||
}
|
||||
Reference in New Issue
Block a user