Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持镜像同步机器人的默认用户和密码设置 #109

Merged
merged 4 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading