Update to version 1.1.0

This commit is contained in:
chihyuwu
2022-04-25 11:10:19 +00:00
parent f0066b40ca
commit ebe7c1d97c
32 changed files with 2197 additions and 445 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/SynologyOpenSource/synology-csi/pkg/dsm/common"
"github.com/SynologyOpenSource/synology-csi/pkg/dsm/webapi"
)
@@ -51,6 +52,30 @@ var cmdDsmLogin = &cobra.Command{
},
}
// Always get the first client from ClientInfo for synocli testing
func LoginDsmForTest() (*webapi.DSM, error) {
info, err := common.LoadConfig("./config/client-info.yml")
if err != nil {
return nil, fmt.Errorf("Failed to read config: %v", err)
}
if len(info.Clients) == 0 {
return nil, fmt.Errorf("No client in client-info.yml")
}
dsm := &webapi.DSM{
Ip: info.Clients[0].Host,
Port: info.Clients[0].Port,
Username: info.Clients[0].Username,
Password: info.Clients[0].Password,
Https: info.Clients[0].Https,
}
if err := dsm.Login(); err != nil {
return nil, fmt.Errorf("Failed to login to DSM: [%s]. err: %v", dsm.Ip, err)
}
return dsm, nil
}
func init() {
cmdDsm.AddCommand(cmdDsmLogin)