Skip to content

Commit

Permalink
refactor(cli): move scheduler status and update module name and imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Jan 6, 2021
1 parent 4510c52 commit 7ea97b6
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/cli/cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/exec"

"github.com/spf13/cobra"
"github.com/symbiont-io/detsys-testkit/lib"
"github.com/symbiont-io/detsys-testkit/src/lib"
)

var dbCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"

"github.com/spf13/cobra"
"github.com/symbiont-io/detsys-testkit/lib"
"github.com/symbiont-io/detsys-testkit/src/lib"
)

var debugCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var rootCmd = &cobra.Command{
}

func init() {
rootCmd.AddCommand(statusCmd)
rootCmd.AddCommand(dbCmd)
dbCmd.AddCommand(dbInitCmd)
dbCmd.AddCommand(dbDropTablesCmd)
Expand All @@ -24,6 +23,7 @@ func init() {
rootCmd.AddCommand(schedulerCmd)
schedulerCmd.AddCommand(schedulerUpCmd)
schedulerCmd.AddCommand(schedulerDownCmd)
schedulerCmd.AddCommand(schedulerStatusCmd)
rootCmd.AddCommand(generateCmd)
rootCmd.AddCommand(versionsCmd)
}
Expand Down
17 changes: 17 additions & 0 deletions src/cli/cmd/scheduler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
Expand All @@ -9,6 +10,7 @@ import (
"strconv"

"github.com/spf13/cobra"
"github.com/symbiont-io/detsys-testkit/src/lib"
)

var schedulerCmd = &cobra.Command{
Expand Down Expand Up @@ -95,3 +97,18 @@ var schedulerDownCmd = &cobra.Command{
}
},
}

var schedulerStatusCmd = &cobra.Command{
Use: "status",
Short: "Show the status of the scheduler",
Long: ``,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
json, err := json.Marshal(lib.Status())
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(string(json))
},
}
24 changes: 0 additions & 24 deletions src/cli/cmd/status.go

This file was deleted.

12 changes: 9 additions & 3 deletions src/cli/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ let
in

buildGoModule rec {
pname = "detsys";
pname = "cli";
version = "latest";
goPackagePath = "github.com/symbiont-io/detsys-testkit/${pname}";
goPackagePath = "github.com/symbiont-io/detsys-testkit/src/${pname}";

src = gitignoreSource ./.;
buildInputs = [ detsysLib ];

# This hash should be the output of:
# go mod vendor && nix-hash --base32 --type sha256 vendor
vendorSha256 = "1yirdqkwnaz0iikcipn1nxcgv2ywrg0zhwjklzf6xns8w038bylp";
vendorSha256 = "0d7nwxx0i834w0kvixl4map8wb6kw4cz30ckvk394cxm4sblzipd";

buildFlagsArray =
[ "-ldflags=-X main.version=${lib.commitIdFromGitRepo ./../../.git}" ];
Expand All @@ -33,4 +33,10 @@ buildGoModule rec {
# Static linking.
export CGO_ENABLED=0
'';

# Rename the resulting binary. (We can't use buildFlags with `-o`, because
# that also gets passed to `go install` which does not recognise that flag.)
postBuild = ''
mv $GOPATH/bin/cli $GOPATH/bin/detsys
'';
}
6 changes: 3 additions & 3 deletions src/cli/go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/symbiont-io/detsys-testkit/detsys
module github.com/symbiont-io/detsys-testkit/src/cli

go 1.15

replace github.com/symbiont-io/detsys-testkit/lib => ../lib
replace github.com/symbiont-io/detsys-testkit/src/lib => ../lib

require (
github.com/spf13/cobra v1.1.1
github.com/symbiont-io/detsys-testkit/lib v0.0.0-00010101000000-000000000000
github.com/symbiont-io/detsys-testkit/src/lib v0.0.0-00010101000000-000000000000
)
1 change: 0 additions & 1 deletion src/cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
Expand Down
2 changes: 1 addition & 1 deletion src/cli/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/symbiont-io/detsys-testkit/detsys/cmd"
"github.com/symbiont-io/detsys-testkit/src/cli/cmd"
)

var version = "unknown"
Expand Down

0 comments on commit 7ea97b6

Please sign in to comment.