working commit

This commit is contained in:
2026-05-30 12:04:50 +02:00
parent c5ed2b2245
commit c964adce89
9 changed files with 37 additions and 28 deletions
+2 -3
View File
@@ -9,7 +9,6 @@ import (
)
const (
uuidRegex = `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`
defaultHostname = "localhost:1025"
)
@@ -41,7 +40,7 @@ func (util *ServiceUtil) MakeServiceCmds() *cobra.Command {
subCmd.PersistentFlags().StringVarP(&util.commonServiceParams.Password, "pass", "P", util.commonServiceParams.Password, "Password")
subCmd.PersistentFlags().StringVarP(&util.commonServiceParams.Hostname, "host", "X", defaultHostname, "Hostname")
subCmd.PersistentFlags().Uint64VarP(&util.commonServiceParams.Timeout, "timeout", "T", defaultTimeout, "Operation timeout")
subCmd.PersistentFlags().BoolVarP(&util.commonServiceParams.SkipTLSVerify, "skipVerify", "S", true, "Skip server certificate verify")
//subCmd.PersistentFlags().BoolVarP(&util.commonServiceParams.SkipTLSVerify, "skipVerify", "S", true, "Skip server certificate verify")
subCmd.MarkFlagsRequiredTogether("user", "pass")
vi := viper.New()
@@ -53,7 +52,7 @@ func (util *ServiceUtil) MakeServiceCmds() *cobra.Command {
// GetService
var getservcmd = &cobra.Command{
Use: "get [user:pass@]hostname[:port]",
Use: "hello [user:pass@]hostname[:port]",
Short: "Get service hello",
Args: cobra.ExactArgs(1),
Run: util.GetHello,
+7 -2
View File
@@ -23,7 +23,10 @@ func (util *ServiceUtil) GetHello(cmd *cobra.Command, args []string) {
printResponse(res, err)
}
type GetHelloResult struct{}
type GetHelloResult struct {
Message string `json:"message"`
Alive bool `json:"alive"`
}
func (util *ServiceUtil) getHello(common *CommonServiceParams, params *GetHelloParams) (*GetHelloResult, error) {
var err error
@@ -38,9 +41,11 @@ func (util *ServiceUtil) getHello(common *CommonServiceParams, params *GetHelloP
ref.SetUserinfo(common.Username, common.Password)
mw := servcli.NewBasicAuthMiddleware(ref.Userinfo())
cli := servcli.NewClient(nil, mw)
err = cli.GetHello(ctx, ref.Raw())
operRes, err := cli.GetHello(ctx, ref.Raw())
if err != nil {
return res, err
}
res.Message = operRes.Message
res.Alive = operRes.Alive
return res, err
}