Skip to content

Commit

Permalink
支持镜像同步机器人的默认用户和密码设置 (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
caoyingjunz authored Jul 20, 2024
1 parent 5c77467 commit ea2ce91
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ env:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
misspell-check:
runs-on: ubuntu-latest
container: pouchcontainer/pouchlinter:v0.1.2
steps:
- name: Checkout
uses: actions/checkout@v2
# misspell-check:
# runs-on: ubuntu-latest
# container: pouchcontainer/pouchlinter:v0.1.2
# steps:
# - name: Checkout
# uses: actions/checkout@v2

# - name: Lint markdown files
# run: find ./ -name "*.md" | xargs mdl -r ~MD010,~MD013,~MD022,~MD024,~MD029,~MD031,~MD032,~MD033,~MD034,~MD036
Expand Down
18 changes: 16 additions & 2 deletions practise/image-practise/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
"go-learning/practise/image-practise/image"
)

const (
defaultUser = "pixiu"
defaultPassword = "123456"
)

var (
harbor = flag.String("harbor", "harbor.cloud.pixiuio.com", "Choose a harbor to push (default harbor.cloud.pixiuio.com")
imageRepository = flag.String("image-repository", "pixiuio", "Choose a container registry to push (default pixiuio")
Expand All @@ -32,11 +37,20 @@ func main() {
klog.Fatal(err)
}

loginUser := *user
if len(loginUser) == 0 || loginUser == "--password" {
loginUser = defaultUser
}
loginPassword := *password
if len(loginPassword) == 0 {
loginPassword = defaultPassword
}

img := image.Image{
Harbor: *harbor,
ImageRepository: *imageRepository,
User: *user,
Password: *password,
User: loginUser,
Password: loginPassword,
Cfg: cfg,
}

Expand Down
6 changes: 6 additions & 0 deletions practise/sftp-practise.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func CopyFromRemote(remoteFile, localFile, user, passwd, host string, port int)
}
defer srcFile.Close()

// 直接读到内存
//buf, err := io.ReadAll(srcFile)
//if err != nil {
// return nil, err
//}

f, err := os.Create(localFile)
if err != nil {
return fmt.Errorf("create file %s failed %v", localFile, err)
Expand Down

0 comments on commit ea2ce91

Please sign in to comment.