mirror of
https://github.com/mudler/luet.git
synced 2025-08-29 04:10:54 +00:00
Allow repo add to set authentication for private repository (#370)
Co-authored-by: lei wang <leiwang@leideMacBook-Air.local>
This commit is contained in:
parent
550642b4f2
commit
e31051062c
@ -45,9 +45,9 @@ Adds a repository to the system. URLs, local files or inline repo can be specifi
|
|||||||
|
|
||||||
luet repo add ... --name "foo"
|
luet repo add ... --name "foo"
|
||||||
|
|
||||||
# Inline:
|
# Inline (provided you have $PASSWORD environent variable set):
|
||||||
|
|
||||||
luet repo add testfo --description "Bar" --url "FOZZ" --type "ff"
|
luet repo add testfo --description "Bar" --url "FOZZ" --type "ff" --username "user" --passwd $(echo "$PASSWORD")
|
||||||
|
|
||||||
`,
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
@ -61,6 +61,8 @@ Adds a repository to the system. URLs, local files or inline repo can be specifi
|
|||||||
url, _ := cmd.Flags().GetString("url")
|
url, _ := cmd.Flags().GetString("url")
|
||||||
ref, _ := cmd.Flags().GetString("reference")
|
ref, _ := cmd.Flags().GetString("reference")
|
||||||
prio, _ := cmd.Flags().GetInt("priority")
|
prio, _ := cmd.Flags().GetInt("priority")
|
||||||
|
username, _ := cmd.Flags().GetString("username")
|
||||||
|
passwd, _ := cmd.Flags().GetString("passwd")
|
||||||
|
|
||||||
if len(util.DefaultContext.Config.RepositoriesConfDir) == 0 && d == "" {
|
if len(util.DefaultContext.Config.RepositoriesConfDir) == 0 && d == "" {
|
||||||
util.DefaultContext.Fatal("No repository dirs defined")
|
util.DefaultContext.Fatal("No repository dirs defined")
|
||||||
@ -82,6 +84,10 @@ Adds a repository to the system. URLs, local files or inline repo can be specifi
|
|||||||
Type: t,
|
Type: t,
|
||||||
Urls: []string{url},
|
Urls: []string{url},
|
||||||
Priority: prio,
|
Priority: prio,
|
||||||
|
Authentication: map[string]string{
|
||||||
|
"username": username,
|
||||||
|
"password": passwd,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r, err = types.LoadRepository([]byte(str))
|
r, err = types.LoadRepository([]byte(str))
|
||||||
@ -103,6 +109,12 @@ Adds a repository to the system. URLs, local files or inline repo can be specifi
|
|||||||
if prio != 0 {
|
if prio != 0 {
|
||||||
r.Priority = prio
|
r.Priority = prio
|
||||||
}
|
}
|
||||||
|
if username != "" && passwd != "" {
|
||||||
|
r.Authentication = map[string]string{
|
||||||
|
"username": username,
|
||||||
|
"password": passwd,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(util.DefaultContext.Config.System.Rootfs, d, fmt.Sprintf("%s.yaml", r.Name))
|
file := filepath.Join(util.DefaultContext.Config.System.Rootfs, d, fmt.Sprintf("%s.yaml", r.Name))
|
||||||
@ -133,5 +145,7 @@ Adds a repository to the system. URLs, local files or inline repo can be specifi
|
|||||||
cmd.Flags().String("url", "", "Repository URL")
|
cmd.Flags().String("url", "", "Repository URL")
|
||||||
cmd.Flags().String("reference", "", "Repository Reference ID")
|
cmd.Flags().String("reference", "", "Repository Reference ID")
|
||||||
cmd.Flags().IntP("priority", "p", 99, "repository prio")
|
cmd.Flags().IntP("priority", "p", 99, "repository prio")
|
||||||
|
cmd.Flags().String("username", "", "repository username")
|
||||||
|
cmd.Flags().String("passwd", "", "repository password")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user