зеркало из https://github.com/Azure/ARO-RP.git
allow mirror tool to mirror single (e.g. hotfix) releases
This commit is contained in:
Родитель
60d6004087
Коммит
11259cbb49
|
@ -22,7 +22,7 @@ import (
|
|||
func usage() {
|
||||
fmt.Fprint(flag.CommandLine.Output(), "usage:\n")
|
||||
fmt.Fprintf(flag.CommandLine.Output(), " %s deploy config.yaml location\n", os.Args[0])
|
||||
fmt.Fprintf(flag.CommandLine.Output(), " %s mirror\n", os.Args[0])
|
||||
fmt.Fprintf(flag.CommandLine.Output(), " %s mirror [release_image...]\n", os.Args[0])
|
||||
fmt.Fprintf(flag.CommandLine.Output(), " %s monitor\n", os.Args[0])
|
||||
fmt.Fprintf(flag.CommandLine.Output(), " %s rp\n", os.Args[0])
|
||||
fmt.Fprintf(flag.CommandLine.Output(), " %s operator {master,worker}\n", os.Args[0])
|
||||
|
@ -47,7 +47,7 @@ func main() {
|
|||
var err error
|
||||
switch strings.ToLower(flag.Arg(0)) {
|
||||
case "mirror":
|
||||
checkArgs(1)
|
||||
checkMinArgs(1)
|
||||
err = mirror(ctx, log)
|
||||
case "monitor":
|
||||
checkArgs(1)
|
||||
|
@ -77,3 +77,10 @@ func checkArgs(required int) {
|
|||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
|
||||
func checkMinArgs(required int) {
|
||||
if len(flag.Args()) < required {
|
||||
usage()
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
|
@ -72,10 +73,20 @@ func mirror(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
log.Print("reading release graph")
|
||||
releases, err := pkgmirror.AddFromGraph(version.NewVersion(4, 3))
|
||||
if err != nil {
|
||||
return err
|
||||
var releases []pkgmirror.Node
|
||||
if len(flag.Args()) == 1 {
|
||||
log.Print("reading release graph")
|
||||
releases, err = pkgmirror.AddFromGraph(version.NewVersion(4, 3))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
for _, arg := range flag.Args()[1:] {
|
||||
releases = append(releases, pkgmirror.Node{
|
||||
Version: arg,
|
||||
Payload: arg,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var errorOccurred bool
|
||||
|
@ -88,27 +99,29 @@ func mirror(ctx context.Context, log *logrus.Entry) error {
|
|||
}
|
||||
}
|
||||
|
||||
for _, ref := range []string{
|
||||
version.MdsdImage("linuxgeneva-microsoft" + acrDomainSuffix),
|
||||
version.MdmImage("linuxgeneva-microsoft" + acrDomainSuffix),
|
||||
} {
|
||||
log.Printf("mirroring %s -> %s", ref, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref))
|
||||
err = pkgmirror.Copy(ctx, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref), ref, dstAuth, srcAuthGeneva)
|
||||
if err != nil {
|
||||
log.Errorf("%s: %s\n", ref, err)
|
||||
errorOccurred = true
|
||||
if len(flag.Args()) == 1 {
|
||||
for _, ref := range []string{
|
||||
version.MdsdImage("linuxgeneva-microsoft" + acrDomainSuffix),
|
||||
version.MdmImage("linuxgeneva-microsoft" + acrDomainSuffix),
|
||||
} {
|
||||
log.Printf("mirroring %s -> %s", ref, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref))
|
||||
err = pkgmirror.Copy(ctx, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref), ref, dstAuth, srcAuthGeneva)
|
||||
if err != nil {
|
||||
log.Errorf("%s: %s\n", ref, err)
|
||||
errorOccurred = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, ref := range []string{
|
||||
"registry.redhat.io/rhel7/support-tools:latest",
|
||||
"registry.redhat.io/rhel8/support-tools:latest",
|
||||
} {
|
||||
log.Printf("mirroring %s -> %s", ref, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref))
|
||||
err = pkgmirror.Copy(ctx, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref), ref, dstAuth, srcAuthRedhat)
|
||||
if err != nil {
|
||||
log.Errorf("%s: %s\n", ref, err)
|
||||
errorOccurred = true
|
||||
for _, ref := range []string{
|
||||
"registry.redhat.io/rhel7/support-tools:latest",
|
||||
"registry.redhat.io/rhel8/support-tools:latest",
|
||||
} {
|
||||
log.Printf("mirroring %s -> %s", ref, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref))
|
||||
err = pkgmirror.Copy(ctx, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref), ref, dstAuth, srcAuthRedhat)
|
||||
if err != nil {
|
||||
log.Errorf("%s: %s\n", ref, err)
|
||||
errorOccurred = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче