Skip to content

Commit

Permalink
Merge pull request canonical#262 from UtkarshBhatthere/maintenance/up…
Browse files Browse the repository at this point in the history
…dateGomod

Updated gomodule dependencies
  • Loading branch information
UtkarshBhatthere authored Nov 24, 2023
2 parents 5723d89 + 8e7c400 commit 8944311
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 98 deletions.
2 changes: 1 addition & 1 deletion microceph/cmd/microceph/cluster_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ func (c *cmdClusterBootstrap) Run(cmd *cobra.Command, args []string) error {
address := util.NetworkInterfaceAddress()
address = util.CanonicalNetworkAddress(address, 7443)

return m.NewCluster(hostname, address, time.Minute*5)
return m.NewCluster(hostname, address, nil, time.Minute*5)
}
3 changes: 2 additions & 1 deletion microceph/cmd/microceph/cluster_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ func (c *cmdClusterJoin) Run(cmd *cobra.Command, args []string) error {
address := util.NetworkInterfaceAddress()
address = util.CanonicalNetworkAddress(address, 7443)

return m.JoinCluster(hostname, address, args[0], time.Minute*5)
token := args[0]
return m.JoinCluster(hostname, address, token, nil, time.Minute*5)
}
26 changes: 12 additions & 14 deletions microceph/cmd/microceph/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/canonical/lxd/lxd/util"
cli "github.com/canonical/lxd/shared/cmd"
"github.com/canonical/microcluster/microcluster"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -60,40 +59,39 @@ func (c *cmdInit) Run(cmd *cobra.Command, args []string) error {

// Get system address.
address := util.NetworkInterfaceAddress()
address, err = cli.AskString(fmt.Sprintf("Please choose the address MicroCeph will be listening on [default=%s]: ", address), address, nil)
address, err = c.common.Asker.AskString(fmt.Sprintf("Please choose the address MicroCeph will be listening on [default=%s]: ", address), address, nil)
if err != nil {
return err
}
address = util.CanonicalNetworkAddress(address, 7443)

wantsBootstrap, err := cli.AskBool("Would you like to create a new MicroCeph cluster? (yes/no) [default=no]: ", "no")
wantsBootstrap, err := c.common.Asker.AskBool("Would you like to create a new MicroCeph cluster? (yes/no) [default=no]: ", "no")
if err != nil {
return err
}

if wantsBootstrap {
mode = "bootstrap"

// Offer overriding the name.
hostName, err = cli.AskString(fmt.Sprintf("Please choose a name for this system [default=%s]: ", hostName), hostName, nil)
hostName, err = c.common.Asker.AskString(fmt.Sprintf("Please choose a name for this system [default=%s]: ", hostName), hostName, nil)
if err != nil {
return err
}

// Bootstrap the cluster.
err = m.NewCluster(hostName, address, time.Minute*2)
err = m.NewCluster(hostName, address, nil, time.Minute*2)
if err != nil {
return err
}
} else {
mode = "join"

token, err := cli.AskString("Please enter your join token: ", "", nil)
token, err := c.common.Asker.AskString("Please enter your join token: ", "", nil)
if err != nil {
return err
}

err = m.JoinCluster(hostName, address, token, time.Minute*2)
err = m.JoinCluster(hostName, address, token, nil, time.Minute*2)
if err != nil {
return err
}
Expand All @@ -104,14 +102,14 @@ func (c *cmdInit) Run(cmd *cobra.Command, args []string) error {

// Add additional servers.
if mode != "join" {
wantsMachines, err := cli.AskBool("Would you like to add additional servers to the cluster? (yes/no) [default=no]: ", "no")
wantsMachines, err := c.common.Asker.AskBool("Would you like to add additional servers to the cluster? (yes/no) [default=no]: ", "no")
if err != nil {
return err
}

if wantsMachines {
for {
tokenName, err := cli.AskString("What's the name of the new MicroCeph server? (empty to exit): ", "", func(input string) error { return nil })
tokenName, err := c.common.Asker.AskString("What's the name of the new MicroCeph server? (empty to exit): ", "", func(input string) error { return nil })
if err != nil {
return err
}
Expand All @@ -132,7 +130,7 @@ func (c *cmdInit) Run(cmd *cobra.Command, args []string) error {
}

// Add some disks.
wantsDisks, err := cli.AskBool("Would you like to add additional local disks to MicroCeph? (yes/no) [default=yes]: ", "yes")
wantsDisks, err := c.common.Asker.AskBool("Would you like to add additional local disks to MicroCeph? (yes/no) [default=yes]: ", "yes")
if err != nil {
return err
}
Expand All @@ -144,7 +142,7 @@ func (c *cmdInit) Run(cmd *cobra.Command, args []string) error {
}

for {
diskPath, err := cli.AskString("What's the disk path? (empty to exit): ", "", func(input string) error { return nil })
diskPath, err := c.common.Asker.AskString("What's the disk path? (empty to exit): ", "", func(input string) error { return nil })
if err != nil {
return err
}
Expand All @@ -153,12 +151,12 @@ func (c *cmdInit) Run(cmd *cobra.Command, args []string) error {
break
}

diskWipe, err := cli.AskBool("Would you like the disk to be wiped? [default=no]: ", "no")
diskWipe, err := c.common.Asker.AskBool("Would you like the disk to be wiped? [default=no]: ", "no")
if err != nil {
return err
}

diskEncrypt, err := cli.AskBool("Would you like the disk to be encrypted? [default=no]: ", "no")
diskEncrypt, err := c.common.Asker.AskBool("Would you like the disk to be encrypted? [default=no]: ", "no")
if err != nil {
return err
}
Expand Down
8 changes: 5 additions & 3 deletions microceph/cmd/microceph/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
package main

import (
"bufio"
"os"

"github.com/spf13/cobra"

cli "github.com/canonical/lxd/shared/cmd"
"github.com/canonical/microceph/microceph/version"
"github.com/spf13/cobra"
)

// CmdControl has functions that are common to the microctl commands.
// command line tools.
type CmdControl struct {
cmd *cobra.Command //nolint:structcheck,unused // FIXME: Remove the nolint flag when this is in use.

Asker cli.Asker // Asker object for prompts on CLI.
FlagHelp bool
FlagVersion bool
FlagLogDebug bool
Expand All @@ -23,7 +25,7 @@ type CmdControl struct {

func main() {
// common flags.
commonCmd := CmdControl{}
commonCmd := CmdControl{Asker: cli.NewAsker(bufio.NewReader(os.Stdin))}

app := &cobra.Command{
Use: "microceph",
Expand Down
12 changes: 7 additions & 5 deletions microceph/cmd/microcephd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var Debug bool
var Verbose bool

type cmdGlobal struct {
cmd *cobra.Command //nolint:structcheck,unused // FIXME: Remove the nolint flag when this is in use.
// cmd *cobra.Command //nolint:structcheck,unused // FIXME: Remove the nolint flag when this is in use.

flagHelp bool
flagVersion bool
Expand All @@ -51,8 +51,8 @@ type cmdDaemon struct {

func (c *cmdDaemon) Command() *cobra.Command {
cmd := &cobra.Command{
Use: "microd",
Short: "Example daemon for MicroCluster - This will start a daemon with a running control socket and no database",
Use: "microcephd",
Short: "Daemon for MicroCeph",
Version: version.Version,
}

Expand All @@ -68,14 +68,16 @@ func (c *cmdDaemon) Run(cmd *cobra.Command, args []string) error {
}

h := &config.Hooks{}
h.OnBootstrap = func(s *state.State) error {
h.OnBootstrap = func(s *state.State, initConfig map[string]string) error {
interf := common.CephState{State: s}
return ceph.Bootstrap(interf)
}
h.PostJoin = func(s *state.State) error {

h.PostJoin = func(s *state.State, initConfig map[string]string) error {
interf := common.CephState{State: s}
return ceph.Join(interf)
}

h.OnStart = func(s *state.State) error {
interf := common.CephState{State: s}
return ceph.Start(interf)
Expand Down
53 changes: 29 additions & 24 deletions microceph/go.mod
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
module github.com/canonical/microceph/microceph

go 1.18
go 1.21.4

require (
github.com/Rican7/retry v0.3.1
github.com/canonical/lxd v0.0.0-20230829115710-2146784688fc
github.com/canonical/microcluster v0.0.0-20230705140256-7726061a60bb
github.com/gorilla/mux v1.8.0
github.com/canonical/lxd v0.0.0-20231123164030-a4a8f23e15f5
github.com/canonical/microcluster v0.0.0-20231123220630-031b9c1ec7ad
github.com/gorilla/mux v1.8.1
github.com/olekukonko/tablewriter v0.0.5
github.com/pborman/uuid v1.2.1
github.com/spf13/cobra v1.7.0
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
github.com/tidwall/gjson v1.16.0
github.com/tidwall/gjson v1.17.0
)

require (
github.com/armon/go-proxyproto v0.0.0-20210323213023-7e956b284f0a // indirect
github.com/canonical/go-dqlite v1.20.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/armon/go-proxyproto v0.1.0 // indirect
github.com/canonical/go-dqlite v1.21.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e // indirect
github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/frankban/quicktest v1.14.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/go-macaroon-bakery/macaroon-bakery/v3 v3.0.1 // indirect
github.com/go-macaroon-bakery/macaroonpb v1.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/renameio v1.0.1 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gorilla/schema v1.2.0 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/gorilla/schema v1.2.1 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/gosexy/gettext v0.0.0-20160830220431-74466a0a0c4a // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jaypipes/pcidb v1.0.0 // indirect
Expand All @@ -38,31 +40,34 @@ require (
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/mattn/go-sqlite3 v1.14.18 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/openfga/go-sdk v0.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.6 // indirect
github.com/pkg/xattr v0.4.9 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rogpeppe/fastuuid v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/zitadel/oidc/v2 v2.8.3 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
github.com/zitadel/oidc/v2 v2.12.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/errgo.v1 v1.0.1 // indirect
gopkg.in/httprequest.v1 v1.2.1 // indirect
gopkg.in/macaroon.v2 v2.1.0 // indirect
Expand Down
Loading

0 comments on commit 8944311

Please sign in to comment.