mirror of
https://github.com/labring/sealos.git
synced 2026-09-24 15:46:19 +08:00
Merge pull request #431 from oldthreefeng/app
read byte to remote file by sftp
This commit is contained in:
@@ -25,7 +25,7 @@ type PkgConfig struct {
|
||||
URL string
|
||||
Name string
|
||||
Workdir string
|
||||
ValuesContent string // -f values.yaml or -f - or default values,read values content before run
|
||||
ValuesContent []byte // -f values.yaml or -f - or default values,read values content before run
|
||||
Workspace string // fmt.Sprintf("%s/%s", p.Workdir, p.Name)
|
||||
}
|
||||
|
||||
@@ -211,12 +211,12 @@ func send(host string, p *PkgConfig) {
|
||||
|
||||
// send package to master
|
||||
func (r *RunOnMaster) Send(config install.SealConfig, p *PkgConfig) {
|
||||
send(config.Masters[0], p)
|
||||
// del because run every node has done this
|
||||
// send(config.Masters[0], p)
|
||||
|
||||
// 默认为空值, 如果ValuesContent有值, 说明使用了file或者-, 将valuesContent写入 workspace/vaules.yml
|
||||
if p.ValuesContent != "" {
|
||||
_ = ReadStringToFile(p.ValuesContent, "/tmp/values.yaml")
|
||||
install.SendPackage("/tmp/values.yaml", config.Masters[:1], p.Workspace,nil,nil)
|
||||
// 默认为空值, 如果ValuesContent有值, 说明使用了file或者-, 将valuesContent远程写入master[0]:/workspace/vaules.yml
|
||||
if p.ValuesContent != nil {
|
||||
install.SSHConfig.CopyConfigFile(config.Masters[0], p.Workspace+"/vaules.yml", p.ValuesContent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,38 +74,25 @@ func NewInstallCommands(cmds []Command) (Runner, Runner) {
|
||||
}
|
||||
|
||||
// getValuesContent is
|
||||
func getValuesContent(s string) (valuesContent string, err error) {
|
||||
func getValuesContent(s string) (valuesContent []byte, err error) {
|
||||
if s == "-" {
|
||||
// deal with stdin
|
||||
return ReadFromStdin()
|
||||
} else if s == "" {
|
||||
// use default and do nothing
|
||||
return s, nil
|
||||
return nil, nil
|
||||
} else {
|
||||
// use -f file
|
||||
return ReadFromFile(s)
|
||||
return ioutil.ReadFile(s)
|
||||
}
|
||||
}
|
||||
|
||||
// ReadFromStdin is
|
||||
func ReadFromStdin() (str string, err error) {
|
||||
func ReadFromStdin() (bt []byte, err error) {
|
||||
var b bytes.Buffer
|
||||
_, err = b.ReadFrom(os.Stdin)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
return b.String(), nil
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
// ReadFromFile is
|
||||
func ReadFromFile(s string) (str string, err error) {
|
||||
y, err := ioutil.ReadFile(s)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(y), nil
|
||||
}
|
||||
|
||||
func ReadStringToFile(s, path string) error {
|
||||
return ioutil.WriteFile(path, []byte(s), os.ModePerm)
|
||||
}
|
||||
@@ -52,8 +52,8 @@ echo "wait for everything ok"
|
||||
sleep 10
|
||||
|
||||
## install kuboard app -f by file ##
|
||||
echo "${SEALOSCMD} install -f $KUBOARDYAML --pkg-url $KUBOARDTAR -w $WORKDIR"
|
||||
${SEALOSCMD} install -f $KUBOARDYAML --pkg-url $KUBOARDTAR -w $WORKDIR
|
||||
echo "${SEALOSCMD} install -f $KUBOARDYAML --pkg-url $KUBOARDTAR -w $WORKDIR -c $CONFIG"
|
||||
${SEALOSCMD} install -f $KUBOARDYAML --pkg-url $KUBOARDTAR -w $WORKDIR -c $CONFIG
|
||||
checkValid installAppByStdin
|
||||
echo "wait for everything ok"
|
||||
sleep 20
|
||||
|
||||
Reference in New Issue
Block a user