Skip to content

Commit

Permalink
CNF-15570: Add new resource server args to config
Browse files Browse the repository at this point in the history
Adds the command line arguments required by the resource server to
achieve parity with the previous implementation of the resource server.

Signed-off-by: Allain Legacy <[email protected]>
  • Loading branch information
alegacy authored and openshift-merge-bot[bot] committed Dec 9, 2024
1 parent e9695ba commit 4bfffbc
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 187 deletions.
13 changes: 8 additions & 5 deletions internal/cmd/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,17 @@ func GetTokenFlag(

// Names of command line flags:
const (
APIListenerAddressFlagName = "api-listener-address"
APIListenerTLSCertFlagName = "api-listener-tls-crt"
APIListenerTLSKeyFlagName = "api-listener-tls-key"
backendTokenFileFlagName = "backend-token-file"
backendTokenFlagName = "backend-token"
backendTypeFlagName = "backend-type"
backendURLFlagName = "backend-url"
cloudIDFlagName = "cloud-id"
extensionsFlagName = "extensions"
externalAddressFlagName = "external-address"
globalCloudIDFlagName = "global-cloud-id"
BackendURLFlagName = "backend-url"
CloudIDFlagName = "cloud-id"
ExtensionsFlagName = "extensions"
ExternalAddressFlagName = "external-address"
GlobalCloudIDFlagName = "global-cloud-id"
namespaceFlagName = "namespace"
resourceServerTokenFlagName = "resource-server-token"
resourceServerURLFlagName = "resource-server-url"
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/server/start_alarm_notification_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func AlarmNotificationServer() *cobra.Command {
network.AddListenerFlags(flags, network.APIListener, network.APIAddress)
network.AddListenerFlags(flags, network.MetricsListener, network.MetricsAddress)
_ = flags.String(
globalCloudIDFlagName,
GlobalCloudIDFlagName,
"",
"Global O-Cloud identifier.",
)
Expand Down Expand Up @@ -110,19 +110,19 @@ func (c *AlarmNotificationServerCommand) run(cmd *cobra.Command, argv []string)
return exit.Error(1)
}
// Get the cloud identifier:
globalCloudID, err := flags.GetString(globalCloudIDFlagName)
globalCloudID, err := flags.GetString(GlobalCloudIDFlagName)
if err != nil {
logger.Error(
"Failed to get global cloud identifier flag",
"flag", globalCloudIDFlagName,
"flag", GlobalCloudIDFlagName,
"error", err.Error(),
)
return exit.Error(1)
}
if globalCloudID == "" {
logger.Error(
"Global cloud identifier is empty",
"flag", globalCloudIDFlagName,
"flag", GlobalCloudIDFlagName,
)
return exit.Error(1)
}
Expand Down
22 changes: 11 additions & 11 deletions internal/cmd/server/start_alarm_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func AlarmServer() *cobra.Command {
network.AddListenerFlags(flags, network.APIListener, network.APIAddress)
network.AddListenerFlags(flags, network.MetricsListener, network.MetricsAddress)
_ = flags.String(
cloudIDFlagName,
CloudIDFlagName,
"",
"O-Cloud identifier.",
)
_ = flags.String(
backendURLFlagName,
BackendURLFlagName,
"",
"URL of the backend server.",
)
Expand All @@ -78,7 +78,7 @@ func AlarmServer() *cobra.Command {
"Token for authenticating to the resource server.",
)
_ = flags.StringArray(
extensionsFlagName,
ExtensionsFlagName,
[]string{},
"Extension to add to alarms.",
)
Expand Down Expand Up @@ -122,12 +122,12 @@ func (c *AlarmServerCommand) run(cmd *cobra.Command, argv []string) error {
}

// Get the cloud identifier:
cloudID, err := flags.GetString(cloudIDFlagName)
cloudID, err := flags.GetString(CloudIDFlagName)
if err != nil {
c.logger.ErrorContext(
ctx,
"Failed to get cloud identifier flag",
"flag", cloudIDFlagName,
"flag", CloudIDFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand All @@ -136,7 +136,7 @@ func (c *AlarmServerCommand) run(cmd *cobra.Command, argv []string) error {
c.logger.ErrorContext(
ctx,
"Cloud identifier is empty",
"flag", cloudIDFlagName,
"flag", CloudIDFlagName,
)
return exit.Error(1)
}
Expand All @@ -147,12 +147,12 @@ func (c *AlarmServerCommand) run(cmd *cobra.Command, argv []string) error {
)

// Get the backend details:
backendURL, err := flags.GetString(backendURLFlagName)
backendURL, err := flags.GetString(BackendURLFlagName)
if err != nil {
c.logger.ErrorContext(
ctx,
"Failed to get backend URL flag",
"flag", backendURLFlagName,
"flag", BackendURLFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand All @@ -161,7 +161,7 @@ func (c *AlarmServerCommand) run(cmd *cobra.Command, argv []string) error {
c.logger.ErrorContext(
ctx,
"Backend URL is empty",
"flag", backendURLFlagName,
"flag", BackendURLFlagName,
)
return exit.Error(1)
}
Expand Down Expand Up @@ -213,12 +213,12 @@ func (c *AlarmServerCommand) run(cmd *cobra.Command, argv []string) error {
resourceServerToken = backendToken
}

extensions, err := flags.GetStringArray(extensionsFlagName)
extensions, err := flags.GetStringArray(ExtensionsFlagName)
if err != nil {
c.logger.ErrorContext(
ctx,
"Failed to extension flag",
"flag", extensionsFlagName,
"flag", ExtensionsFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand Down
14 changes: 7 additions & 7 deletions internal/cmd/server/start_alarm_subscription_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ func AlarmSubscriptionServer() *cobra.Command {
network.AddListenerFlags(flags, network.APIListener, network.APIAddress)
network.AddListenerFlags(flags, network.MetricsListener, network.MetricsAddress)
_ = flags.String(
globalCloudIDFlagName,
GlobalCloudIDFlagName,
"",
"Global O-Cloud identifier.",
)
_ = flags.StringArray(
extensionsFlagName,
ExtensionsFlagName,
[]string{},
"Extension to add to alarm subscriptions.",
)
Expand Down Expand Up @@ -106,12 +106,12 @@ func (c *AlarmSubscriptionServerCommand) run(cmd *cobra.Command, argv []string)
}

// Get the cloud identifier:
globalCloudID, err := flags.GetString(globalCloudIDFlagName)
globalCloudID, err := flags.GetString(GlobalCloudIDFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to get global cloud identifier flag",
"flag", globalCloudIDFlagName,
"flag", GlobalCloudIDFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand All @@ -120,7 +120,7 @@ func (c *AlarmSubscriptionServerCommand) run(cmd *cobra.Command, argv []string)
logger.ErrorContext(
ctx,
"Global cloud identifier is empty",
"flag", globalCloudIDFlagName,
"flag", GlobalCloudIDFlagName,
)
return exit.Error(1)
}
Expand All @@ -131,12 +131,12 @@ func (c *AlarmSubscriptionServerCommand) run(cmd *cobra.Command, argv []string)
)

// Get the extensions details:
extensions, err := flags.GetStringArray(extensionsFlagName)
extensions, err := flags.GetStringArray(ExtensionsFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to extension flag",
"flag", extensionsFlagName,
"flag", ExtensionsFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand Down
28 changes: 14 additions & 14 deletions internal/cmd/server/start_deployment_manager_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func DeploymentManagerServer() *cobra.Command {
network.AddListenerFlags(flags, network.MetricsListener, network.MetricsAddress)
AddTokenFlags(flags)
_ = flags.String(
cloudIDFlagName,
CloudIDFlagName,
"",
"O-Cloud identifier.",
)
_ = flags.String(
backendURLFlagName,
BackendURLFlagName,
"",
"URL of the backend server.",
)
Expand All @@ -66,12 +66,12 @@ func DeploymentManagerServer() *cobra.Command {
),
)
_ = flags.StringArray(
extensionsFlagName,
ExtensionsFlagName,
[]string{},
"Extension to add to deployment managers.",
)
_ = flags.String(
externalAddressFlagName,
ExternalAddressFlagName,
"",
"External address.",
)
Expand Down Expand Up @@ -114,12 +114,12 @@ func (c *DeploymentManagerServerCommand) run(cmd *cobra.Command, argv []string)
}

// Get the cloud identifier:
cloudID, err := flags.GetString(cloudIDFlagName)
cloudID, err := flags.GetString(CloudIDFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to get cloud identifier flag",
"flag", cloudIDFlagName,
"flag", CloudIDFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand All @@ -128,7 +128,7 @@ func (c *DeploymentManagerServerCommand) run(cmd *cobra.Command, argv []string)
logger.ErrorContext(
ctx,
"Cloud identifier is empty",
"flag", cloudIDFlagName,
"flag", CloudIDFlagName,
)
return exit.Error(1)
}
Expand Down Expand Up @@ -161,12 +161,12 @@ func (c *DeploymentManagerServerCommand) run(cmd *cobra.Command, argv []string)
)
return exit.Error(1)
}
backendURL, err := flags.GetString(backendURLFlagName)
backendURL, err := flags.GetString(BackendURLFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to get backend URL flag",
"flag", backendURLFlagName,
"flag", BackendURLFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand All @@ -175,16 +175,16 @@ func (c *DeploymentManagerServerCommand) run(cmd *cobra.Command, argv []string)
logger.ErrorContext(
ctx,
"Backend URL is empty",
"flag", backendURLFlagName,
"flag", BackendURLFlagName,
)
return exit.Error(1)
}
extensions, err := flags.GetStringArray(extensionsFlagName)
extensions, err := flags.GetStringArray(ExtensionsFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to extension flag",
"flag", extensionsFlagName,
"flag", ExtensionsFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand All @@ -206,12 +206,12 @@ func (c *DeploymentManagerServerCommand) run(cmd *cobra.Command, argv []string)
)

// Get the external address:
externalAddress, err := flags.GetString(externalAddressFlagName)
externalAddress, err := flags.GetString(ExternalAddressFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to get external address flag",
slog.String("flag", externalAddressFlagName),
slog.String("flag", ExternalAddressFlagName),
slog.String("error", err.Error()),
)
return exit.Error(1)
Expand Down
22 changes: 11 additions & 11 deletions internal/cmd/server/start_metadata_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ func MetadataServer() *cobra.Command {
network.AddListenerFlags(flags, network.APIListener, network.APIAddress)
network.AddListenerFlags(flags, network.MetricsListener, network.MetricsAddress)
_ = flags.String(
cloudIDFlagName,
CloudIDFlagName,
"",
"O-Cloud identifier.",
)
_ = flags.String(
globalCloudIDFlagName,
GlobalCloudIDFlagName,
"",
"Global O-Cloud identifier.",
)
_ = flags.String(
externalAddressFlagName,
ExternalAddressFlagName,
"",
"External address.",
)
Expand Down Expand Up @@ -99,12 +99,12 @@ func (c *MetadataServerCommand) run(cmd *cobra.Command, argv []string) error {
}

// Get the cloud identifier:
cloudID, err := flags.GetString(cloudIDFlagName)
cloudID, err := flags.GetString(CloudIDFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to get cloud identifier flag",
"flag", cloudIDFlagName,
"flag", CloudIDFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand All @@ -113,7 +113,7 @@ func (c *MetadataServerCommand) run(cmd *cobra.Command, argv []string) error {
logger.ErrorContext(
ctx,
"Cloud identifier is empty",
"flag", cloudIDFlagName,
"flag", CloudIDFlagName,
)
return exit.Error(1)
}
Expand All @@ -124,12 +124,12 @@ func (c *MetadataServerCommand) run(cmd *cobra.Command, argv []string) error {
)

// Get the cloud identifier:
globalCloudID, err := flags.GetString(globalCloudIDFlagName)
globalCloudID, err := flags.GetString(GlobalCloudIDFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to get global cloud identifier flag",
"flag", globalCloudIDFlagName,
"flag", GlobalCloudIDFlagName,
"error", err.Error(),
)
return exit.Error(1)
Expand All @@ -138,7 +138,7 @@ func (c *MetadataServerCommand) run(cmd *cobra.Command, argv []string) error {
logger.ErrorContext(
ctx,
"Global cloud identifier is empty",
"flag", globalCloudIDFlagName,
"flag", GlobalCloudIDFlagName,
)
return exit.Error(1)
}
Expand All @@ -149,12 +149,12 @@ func (c *MetadataServerCommand) run(cmd *cobra.Command, argv []string) error {
)

// Get the external address:
externalAddress, err := flags.GetString(externalAddressFlagName)
externalAddress, err := flags.GetString(ExternalAddressFlagName)
if err != nil {
logger.ErrorContext(
ctx,
"Failed to get external address flag",
slog.String("flag", externalAddressFlagName),
slog.String("flag", ExternalAddressFlagName),
slog.String("error", err.Error()),
)
return exit.Error(1)
Expand Down
Loading

0 comments on commit 4bfffbc

Please sign in to comment.