deployment

This commit is contained in:
qiaofeng1227 2023-09-19 16:07:56 +08:00
parent 1428f2c14b
commit 635469f653
2 changed files with 3 additions and 24 deletions

View File

@ -9,5 +9,4 @@ RUN chmod +x /init_portainer
FROM portainer/portainer-ce:2.19.0
LABEL maintainer="websoft9<help@websoft9.com>"
LABEL version="2.19.0"
COPY --from=builder /init_portainer /

View File

@ -7,7 +7,6 @@ import (
"os"
"os/exec"
"time"
"encoding/json"
)
func main() {
@ -42,7 +41,7 @@ func main() {
}
}
content, err := readPasswordFromFile(filePath)
content, err := ioutil.ReadFile(filePath)
if err != nil {
fmt.Println("read file error:", err)
return
@ -75,26 +74,7 @@ func generatePassword(length int) string {
return string(password)
}
func readPasswordFromFile(filePath string) (string, error) {
data, err := ioutil.ReadFile(filePath)
if err != nil {
return "", err
}
var passwordMap map[string]string
err = json.Unmarshal(data, &passwordMap)
if err != nil {
return "", err
}
password := passwordMap["password"]
return password, nil
}
func writeToFile(filePath , content string) error {
func writeToFile(filePath, password string) error {
data := map[string]string{"username": "admin", "password": password}
jsonData, err := json.Marshal(data)
if err != nil {
return err
}
err = ioutil.WriteFile(filePath, jsonData, 0755)
return err
return ioutil.WriteFile(filePath , []byte(content), 0755)
}