2019-12-22 20:47:29 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the Apache License 2.0.
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-01-21 05:57:53 +03:00
|
|
|
"flag"
|
|
|
|
"fmt"
|
2020-10-14 18:14:20 +03:00
|
|
|
"net/http"
|
|
|
|
_ "net/http/pprof"
|
2019-12-22 20:47:29 +03:00
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
utillog "github.com/Azure/ARO-RP/pkg/util/log"
|
2020-07-28 12:51:01 +03:00
|
|
|
_ "github.com/Azure/ARO-RP/pkg/util/scheme"
|
2020-06-25 07:38:08 +03:00
|
|
|
"github.com/Azure/ARO-RP/pkg/util/version"
|
2019-12-22 20:47:29 +03:00
|
|
|
)
|
|
|
|
|
2020-01-21 05:57:53 +03:00
|
|
|
func usage() {
|
2020-03-22 07:35:17 +03:00
|
|
|
fmt.Fprint(flag.CommandLine.Output(), "usage:\n")
|
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s deploy config.yaml location\n", os.Args[0])
|
2021-03-08 19:53:06 +03:00
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s gateway\n", os.Args[0])
|
2020-12-01 01:50:29 +03:00
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s mirror [release_image...]\n", os.Args[0])
|
2020-03-22 07:35:17 +03:00
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s monitor\n", os.Args[0])
|
2020-09-26 01:20:03 +03:00
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s portal\n", os.Args[0])
|
2020-03-22 07:35:17 +03:00
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s rp\n", os.Args[0])
|
2020-07-28 12:51:01 +03:00
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s operator {master,worker}\n", os.Args[0])
|
2022-08-18 10:48:23 +03:00
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s update-versions\n", os.Args[0])
|
2024-05-31 16:09:53 +03:00
|
|
|
fmt.Fprintf(flag.CommandLine.Output(), " %s update-role-sets\n", os.Args[0])
|
2020-01-21 05:57:53 +03:00
|
|
|
flag.PrintDefaults()
|
|
|
|
}
|
|
|
|
|
2019-12-22 20:47:29 +03:00
|
|
|
func main() {
|
2020-01-21 05:57:53 +03:00
|
|
|
flag.Usage = usage
|
|
|
|
flag.Parse()
|
|
|
|
|
2020-01-19 02:46:58 +03:00
|
|
|
ctx := context.Background()
|
2021-02-04 14:09:06 +03:00
|
|
|
audit := utillog.GetAuditEntry()
|
2019-12-22 20:47:29 +03:00
|
|
|
log := utillog.GetLogger()
|
|
|
|
|
2020-10-14 18:14:20 +03:00
|
|
|
go func() {
|
|
|
|
log.Warn(http.ListenAndServe("localhost:6060", nil))
|
|
|
|
}()
|
|
|
|
|
2020-06-25 07:38:08 +03:00
|
|
|
log.Printf("starting, git commit %s", version.GitCommit)
|
2019-12-22 20:47:29 +03:00
|
|
|
|
|
|
|
var err error
|
2020-03-05 05:02:28 +03:00
|
|
|
switch strings.ToLower(flag.Arg(0)) {
|
2020-09-26 01:20:03 +03:00
|
|
|
case "deploy":
|
|
|
|
checkArgs(3)
|
|
|
|
err = deploy(ctx, log)
|
2021-03-08 19:53:06 +03:00
|
|
|
case "gateway":
|
|
|
|
checkArgs(1)
|
|
|
|
err = gateway(ctx, log)
|
2019-12-22 20:47:29 +03:00
|
|
|
case "mirror":
|
2020-12-01 01:50:29 +03:00
|
|
|
checkMinArgs(1)
|
2020-01-19 02:46:58 +03:00
|
|
|
err = mirror(ctx, log)
|
|
|
|
case "monitor":
|
2020-03-06 13:28:05 +03:00
|
|
|
checkArgs(1)
|
2020-01-19 02:46:58 +03:00
|
|
|
err = monitor(ctx, log)
|
2019-12-22 20:47:29 +03:00
|
|
|
case "rp":
|
2020-03-06 13:28:05 +03:00
|
|
|
checkArgs(1)
|
2021-02-04 14:09:06 +03:00
|
|
|
err = rp(ctx, log, audit)
|
2020-09-26 01:20:03 +03:00
|
|
|
case "portal":
|
|
|
|
checkArgs(1)
|
2021-04-20 12:01:06 +03:00
|
|
|
err = portal(ctx, log, audit)
|
2020-07-28 12:51:01 +03:00
|
|
|
case "operator":
|
|
|
|
checkArgs(2)
|
|
|
|
err = operator(ctx, log)
|
2022-08-18 10:48:23 +03:00
|
|
|
case "update-versions":
|
|
|
|
checkArgs(1)
|
|
|
|
err = updateOCPVersions(ctx, log)
|
2024-05-31 16:09:53 +03:00
|
|
|
case "update-role-sets":
|
|
|
|
checkArgs(1)
|
|
|
|
err = updatePlatformWorkloadIdentityRoleSets(ctx, log)
|
2020-01-19 02:46:58 +03:00
|
|
|
default:
|
|
|
|
usage()
|
|
|
|
os.Exit(2)
|
2019-12-22 20:47:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2020-03-06 13:28:05 +03:00
|
|
|
|
|
|
|
func checkArgs(required int) {
|
|
|
|
if len(flag.Args()) != required {
|
|
|
|
usage()
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
}
|
2020-12-01 01:50:29 +03:00
|
|
|
|
|
|
|
func checkMinArgs(required int) {
|
|
|
|
if len(flag.Args()) < required {
|
|
|
|
usage()
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
}
|