1 package edgebsl
2
3 import (
4 "flag"
5
6 "github.com/peterbourgon/ff/v3"
7
8 "edge-infra.dev/pkg/edge/bsl"
9 )
10
11 func NewConfig(args []string) (BslConfig, *flag.FlagSet, error) {
12 config := BslConfig{
13 AccessKey: &bsl.AccessKey{},
14 }
15
16 fs := flag.NewFlagSet("bslctl", flag.ExitOnError)
17
18 fs.StringVar(
19 &config.ActivationSubscriptionURL,
20 "activation_subscription_url",
21 "",
22 "endpoint for customer activation subscription",
23 )
24
25 fs.StringVar(
26 &config.RootURI,
27 "bsl_endpoint",
28 "",
29 "bsl endpoint for bslctl",
30 )
31
32 fs.StringVar(
33 &config.BslReconcilesInterval,
34 "bsl_reconcile_interval",
35 DefaultReconcileInterval,
36 "reconcile interval that bslctl will be running with",
37 )
38
39 fs.StringVar(
40 &config.RootOrg,
41 "bsl_root_org",
42 "",
43 "bsl root org",
44 )
45
46 fs.StringVar(
47 &config.OrgPrefix,
48 "bsp_organization_prefix",
49 "",
50 "bsl organization prefix",
51 )
52
53 fs.StringVar(
54 &config.TopLevelProjectID,
55 "top_level_project_id",
56 "",
57 "top level project ID",
58 )
59
60 fs.StringVar(&config.AccessKey.SecretKey,
61 "edge_bsl_secret_key",
62 "",
63 "secret key for access the bsl",
64 )
65
66 fs.StringVar(&config.AccessKey.SharedKey,
67 "edge_bsl_shared_key",
68 "",
69 "shared key for access the bsl",
70 )
71
72 fs.StringVar(&config.BasicAuthCreds.Username,
73 "edge_bsl_basic_auth_username",
74 "",
75 "secret key for access the bsl",
76 )
77
78 fs.StringVar(&config.BasicAuthCreds.Password,
79 "edge_bsl_basic_auth_password",
80 "",
81 "shared key for access the bsl",
82 )
83
84
85 fs.StringVar(&config.SQL.ConnectionName,
86 "sql_connection_name",
87 config.SQL.ConnectionName,
88 "sql connection name",
89 )
90
91 fs.StringVar(&config.SQL.User,
92 "sql_user",
93 config.SQL.User,
94 "sql db user",
95 )
96
97 fs.StringVar(&config.SQL.DatabaseName,
98 "sql_db_name",
99 config.SQL.DatabaseName,
100 "sql db name",
101 )
102
103 fs.StringVar(&config.Mode,
104 "mode",
105 "release",
106 "gin server mode",
107 )
108
109 fs.StringVar(&config.Port,
110 "port",
111 "9092",
112 "the port edge bsl server should run on",
113 )
114
115 if err := ff.Parse(fs, args[1:], ff.WithEnvVarNoPrefix()); err != nil {
116 return BslConfig{}, &flag.FlagSet{}, err
117 }
118
119 return config, fs, nil
120 }
121
View as plain text