diff --git a/api/inventory/v1alpha1/inventory_types.go b/api/inventory/v1alpha1/inventory_types.go index 97634c6a..a0b3938c 100644 --- a/api/inventory/v1alpha1/inventory_types.go +++ b/api/inventory/v1alpha1/inventory_types.go @@ -81,6 +81,13 @@ type ServerConfig struct { Enabled bool `json:"enabled"` } +// ArtifactsServerConfig contains the configuration for the artifacts server. +type ArtifactsServerConfig struct { + //+kubebuilder:default:={enabled:true} + //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Server Configuration",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:bool"} + ServerConfig `json:",inline"` +} + // ResourceServerConfig contains the configuration for the resource server. type ResourceServerConfig struct { //+kubebuilder:default:={enabled:true} @@ -141,6 +148,10 @@ type InventorySpec struct { //+optional //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Cloud ID",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} CloudID *string `json:"cloudID"` + // ArtifactsServerConfig contains the configuration for the artifacts server. + //+optional + //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Artifacts Server Configuration",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} + ArtifactsServerConfig ArtifactsServerConfig `json:"artifactsServerConfig,omitempty"` // ResourceServerConfig contains the configuration for the resource server. //+optional //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Resource Server Configuration",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} @@ -178,12 +189,14 @@ type DeploymentsStatus struct { ResourceServerStatus string `json:"resourceServerStatus,omitempty"` // +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Alarm Server Status" AlarmServerStatus string `json:"alarmServerStatus,omitempty"` + // +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Artifacts Server Status" + ArtifactsServerStatus string `json:"artifactsServerStatus,omitempty"` } type UsedServerConfig struct { - MetadataServerUsedConfig []string `json:"metadataServerUsedConfig,omitempty"` - ResourceServerUsedConfig []string `json:"resourceServerUsedConfig,omitempty"` - DeploymentManagerServerUsedConfig []string `json:"deploymentManagerServerUsedConfig,omitempty"` + ArtifactsServerUsedConfig []string `json:"artifactsServerUsedConfig,omitempty"` + MetadataServerUsedConfig []string `json:"metadataServerUsedConfig,omitempty"` + ResourceServerUsedConfig []string `json:"resourceServerUsedConfig,omitempty"` } // InventoryStatus defines the observed state of Inventory diff --git a/api/inventory/v1alpha1/zz_generated.deepcopy.go b/api/inventory/v1alpha1/zz_generated.deepcopy.go index c21059f6..f4617afa 100644 --- a/api/inventory/v1alpha1/zz_generated.deepcopy.go +++ b/api/inventory/v1alpha1/zz_generated.deepcopy.go @@ -46,6 +46,22 @@ func (in *AlarmServerConfig) DeepCopy() *AlarmServerConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArtifactsServerConfig) DeepCopyInto(out *ArtifactsServerConfig) { + *out = *in + out.ServerConfig = in.ServerConfig +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArtifactsServerConfig. +func (in *ArtifactsServerConfig) DeepCopy() *ArtifactsServerConfig { + if in == nil { + return nil + } + out := new(ArtifactsServerConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterServerConfig) DeepCopyInto(out *ClusterServerConfig) { *out = *in @@ -154,6 +170,7 @@ func (in *InventorySpec) DeepCopyInto(out *InventorySpec) { *out = new(string) **out = **in } + out.ArtifactsServerConfig = in.ArtifactsServerConfig in.ResourceServerConfig.DeepCopyInto(&out.ResourceServerConfig) in.ClusterServerConfig.DeepCopyInto(&out.ClusterServerConfig) in.AlarmServerConfig.DeepCopyInto(&out.AlarmServerConfig) @@ -317,6 +334,11 @@ func (in *TLSConfig) DeepCopy() *TLSConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UsedServerConfig) DeepCopyInto(out *UsedServerConfig) { *out = *in + if in.ArtifactsServerUsedConfig != nil { + in, out := &in.ArtifactsServerUsedConfig, &out.ArtifactsServerUsedConfig + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.MetadataServerUsedConfig != nil { in, out := &in.MetadataServerUsedConfig, &out.MetadataServerUsedConfig *out = make([]string, len(*in)) @@ -327,11 +349,6 @@ func (in *UsedServerConfig) DeepCopyInto(out *UsedServerConfig) { *out = make([]string, len(*in)) copy(*out, *in) } - if in.DeploymentManagerServerUsedConfig != nil { - in, out := &in.DeploymentManagerServerUsedConfig, &out.DeploymentManagerServerUsedConfig - *out = make([]string, len(*in)) - copy(*out, *in) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UsedServerConfig. diff --git a/bundle/manifests/o2ims.oran.openshift.io_inventories.yaml b/bundle/manifests/o2ims.oran.openshift.io_inventories.yaml index 9c905b74..132ad47e 100644 --- a/bundle/manifests/o2ims.oran.openshift.io_inventories.yaml +++ b/bundle/manifests/o2ims.oran.openshift.io_inventories.yaml @@ -67,6 +67,19 @@ spec: required: - enabled type: object + artifactsServerConfig: + default: + enabled: true + description: ArtifactsServerConfig contains the configuration for + the artifacts server. + properties: + enabled: + default: true + description: Enabled indicates if the server should be started. + type: boolean + required: + - enabled + type: object caBundleName: description: |- CaBundleName references a config map that contains a set of custom CA certificates to be used when communicating @@ -296,6 +309,8 @@ spec: properties: alarmServerStatus: type: string + artifactsServerStatus: + type: string deploymentServerStatus: type: string metadataServerStatus: @@ -315,7 +330,7 @@ spec: type: string usedServerConfig: properties: - deploymentManagerServerUsedConfig: + artifactsServerUsedConfig: items: type: string type: array diff --git a/bundle/manifests/oran-o2ims.clusterserviceversion.yaml b/bundle/manifests/oran-o2ims.clusterserviceversion.yaml index 22eaec37..e6f38772 100644 --- a/bundle/manifests/oran-o2ims.clusterserviceversion.yaml +++ b/bundle/manifests/oran-o2ims.clusterserviceversion.yaml @@ -758,6 +758,12 @@ spec: being first and the root CA being last. displayName: TLS client certificate path: alarmServerConfig.clientTLS.clientCertificateName + - description: ArtifactsServerConfig contains the configuration for the artifacts + server. + displayName: Artifacts Server Configuration + path: artifactsServerConfig + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text - description: |- CaBundleName references a config map that contains a set of custom CA certificates to be used when communicating with any outside entity (e.g., the SMO, the authorization server, etc.) that has its TLS certificate signed by @@ -915,6 +921,8 @@ spec: path: deploymentStatus - displayName: Alarm Server Status path: deploymentStatus.alarmServerStatus + - displayName: Artifacts Server Status + path: deploymentStatus.artifactsServerStatus - displayName: Deployment Server Status path: deploymentStatus.deploymentServerStatus - displayName: Metadata Server Status diff --git a/config/crd/bases/o2ims.oran.openshift.io_inventories.yaml b/config/crd/bases/o2ims.oran.openshift.io_inventories.yaml index 224e6ce7..17872379 100644 --- a/config/crd/bases/o2ims.oran.openshift.io_inventories.yaml +++ b/config/crd/bases/o2ims.oran.openshift.io_inventories.yaml @@ -67,6 +67,19 @@ spec: required: - enabled type: object + artifactsServerConfig: + default: + enabled: true + description: ArtifactsServerConfig contains the configuration for + the artifacts server. + properties: + enabled: + default: true + description: Enabled indicates if the server should be started. + type: boolean + required: + - enabled + type: object caBundleName: description: |- CaBundleName references a config map that contains a set of custom CA certificates to be used when communicating @@ -296,6 +309,8 @@ spec: properties: alarmServerStatus: type: string + artifactsServerStatus: + type: string deploymentServerStatus: type: string metadataServerStatus: @@ -315,7 +330,7 @@ spec: type: string usedServerConfig: properties: - deploymentManagerServerUsedConfig: + artifactsServerUsedConfig: items: type: string type: array diff --git a/config/manifests/bases/oran-o2ims.clusterserviceversion.yaml b/config/manifests/bases/oran-o2ims.clusterserviceversion.yaml index e769a89a..730da589 100644 --- a/config/manifests/bases/oran-o2ims.clusterserviceversion.yaml +++ b/config/manifests/bases/oran-o2ims.clusterserviceversion.yaml @@ -162,6 +162,12 @@ spec: being first and the root CA being last. displayName: TLS client certificate path: alarmServerConfig.clientTLS.clientCertificateName + - description: ArtifactsServerConfig contains the configuration for the artifacts + server. + displayName: Artifacts Server Configuration + path: artifactsServerConfig + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text - description: |- CaBundleName references a config map that contains a set of custom CA certificates to be used when communicating with any outside entity (e.g., the SMO, the authorization server, etc.) that has its TLS certificate signed by @@ -319,6 +325,8 @@ spec: path: deploymentStatus - displayName: Alarm Server Status path: deploymentStatus.alarmServerStatus + - displayName: Artifacts Server Status + path: deploymentStatus.artifactsServerStatus - displayName: Deployment Server Status path: deploymentStatus.deploymentServerStatus - displayName: Metadata Server Status diff --git a/config/testing/client-service-account-rbac.yaml b/config/testing/client-service-account-rbac.yaml index a67a2c1e..9da71c5e 100644 --- a/config/testing/client-service-account-rbac.yaml +++ b/config/testing/client-service-account-rbac.yaml @@ -16,6 +16,10 @@ rules: - /o2ims-infrastructureMonitoring/api_versions - /o2ims-infrastructureCluster/* - /o2ims-infrastructureCluster/api_versions + - /o2ims-infrastructureArtifacts/* + - /o2ims-infrastructureArtifacts/api_versions + - /o2ims-infrastructureArtifacts/v1/managedInfrastructureTemplates + - /o2ims-infrastructureArtifacts/v1/managedInfrastructureTemplates/* verbs: - get - nonResourceURLs: diff --git a/internal/controllers/inventory_controller.go b/internal/controllers/inventory_controller.go index ebcfe567..8d2b78dd 100644 --- a/internal/controllers/inventory_controller.go +++ b/internal/controllers/inventory_controller.go @@ -275,6 +275,79 @@ func (t *reconcilerTask) setupClusterServerConfig(ctx context.Context, defaultRe return nextReconcile, err } +// setupArtifactsServerConfig creates the resource necessary to start the Artifacts Server. +func (t *reconcilerTask) setupArtifactsServerConfig(ctx context.Context, defaultResult ctrl.Result) (nextReconcile ctrl.Result, err error) { + nextReconcile = defaultResult + + err = t.createServiceAccount(ctx, utils.InventoryArtifactsServerName) + if err != nil { + t.logger.ErrorContext( + ctx, + "Failed to deploy ServiceAccount for the Artifacts server.", + slog.String("error", err.Error()), + ) + return + } + + err = t.createArtifactsServerClusterRole(ctx) + if err != nil { + t.logger.ErrorContext( + ctx, + "Failed to create artifacts cluster role", + slog.String("error", err.Error()), + ) + return + } + err = t.createArtifactsServerClusterRoleBinding(ctx) + if err != nil { + t.logger.ErrorContext( + ctx, + "Failed to create artifacts cluster role binding", + slog.String("error", err.Error()), + ) + return + } + + // Create the role binding needed to allow the kube-rbac-proxy to interact with the API server to validate incoming + // API requests from clients. + err = t.createServerRbacClusterRoleBinding(ctx, utils.InventoryArtifactsServerName) + if err != nil { + t.logger.ErrorContext( + ctx, + "Failed to create Artifacts server RBAC proxy cluster role binding", + slog.String("error", err.Error()), + ) + return + } + + // Create the Service needed for the Artifacts server. + err = t.createService(ctx, utils.InventoryArtifactsServerName, utils.DefaultServicePort, utils.DefaultTargetPort) + if err != nil { + t.logger.ErrorContext( + ctx, + "Failed to deploy Service for the Artifacts server.", + slog.String("error", err.Error()), + ) + return + } + + // Create the artifacts-server deployment. + errorReason, err := t.deployServer(ctx, utils.InventoryArtifactsServerName) + if err != nil { + t.logger.ErrorContext( + ctx, + "Failed to deploy the Artifacts server.", + slog.String("error", err.Error()), + ) + if errorReason == "" { + nextReconcile = ctrl.Result{RequeueAfter: 60 * time.Second} + return nextReconcile, err + } + } + + return +} + // setupAlarmServerConfig creates the resources necessary to start the Alarm Server. func (t *reconcilerTask) setupAlarmServerConfig(ctx context.Context, defaultResult ctrl.Result) (nextReconcile ctrl.Result, err error) { nextReconcile = defaultResult @@ -619,7 +692,8 @@ func (t *reconcilerTask) run(ctx context.Context) (nextReconcile ctrl.Result, er } // Create the needed Ingress if at least one server is required by the Spec. - if t.object.Spec.ResourceServerConfig.Enabled || t.object.Spec.AlarmServerConfig.Enabled { + if t.object.Spec.ResourceServerConfig.Enabled || t.object.Spec.AlarmServerConfig.Enabled || + t.object.Spec.ArtifactsServerConfig.Enabled { err = t.createIngress(ctx) if err != nil { t.logger.ErrorContext( @@ -669,6 +743,15 @@ func (t *reconcilerTask) run(ctx context.Context) (nextReconcile ctrl.Result, er } } + // Start the artifacts server if required by the Spec. + if t.object.Spec.ArtifactsServerConfig.Enabled { + // Create the artifacts server. + nextReconcile, err = t.setupArtifactsServerConfig(ctx, nextReconcile) + if err != nil { + return + } + } + err = t.updateInventoryDeploymentStatus(ctx) if err != nil { t.logger.ErrorContext( @@ -681,6 +764,70 @@ func (t *reconcilerTask) run(ctx context.Context) (nextReconcile ctrl.Result, er return } +func (t *reconcilerTask) createArtifactsServerClusterRole(ctx context.Context) error { + role := &rbacv1.ClusterRole{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf( + "%s-%s", t.object.Namespace, utils.InventoryArtifactsServerName, + ), + }, + Rules: []rbacv1.PolicyRule{ + // We need to read ClusterTemplates. + { + APIGroups: []string{ + "o2ims.provisioning.oran.org", + }, + Resources: []string{ + "clustertemplates", + }, + Verbs: []string{ + "get", + "list", + "watch", + }, + }, + }, + } + + if err := utils.CreateK8sCR(ctx, t.client, role, t.object, utils.UPDATE); err != nil { + return fmt.Errorf("failed to create Artifacts server cluster role: %w", err) + } + + return nil +} + +func (t *reconcilerTask) createArtifactsServerClusterRoleBinding(ctx context.Context) error { + binding := &rbacv1.ClusterRoleBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf( + "%s-%s", + t.object.Namespace, utils.InventoryArtifactsServerName, + ), + }, + RoleRef: rbacv1.RoleRef{ + APIGroup: rbacv1.GroupName, + Kind: "ClusterRole", + Name: fmt.Sprintf( + "%s-%s", + t.object.Namespace, utils.InventoryArtifactsServerName, + ), + }, + Subjects: []rbacv1.Subject{ + { + Kind: rbacv1.ServiceAccountKind, + Namespace: t.object.Namespace, + Name: utils.InventoryArtifactsServerName, + }, + }, + } + + if err := utils.CreateK8sCR(ctx, t.client, binding, t.object, utils.UPDATE); err != nil { + return fmt.Errorf("failed to create Artifacts Server cluster role binding: %w", err) + } + + return nil +} + // createSharedRbacProxyRole creates a cluster role that is used by the kube-rbac-proxy to access the authentication and // authorization parts of the kubernetes API so that incoming API requests can be validated. This same cluster role is // attached to each of the server service accounts since each of them has its own kube-rbac-proxy that all share the @@ -1439,6 +1586,21 @@ func (t *reconcilerTask) createIngress(ctx context.Context) error { }, }, }, + { + Path: "/o2ims-infrastructureArtifacts", + PathType: func() *networkingv1.PathType { + pathType := networkingv1.PathTypePrefix + return &pathType + }(), + Backend: networkingv1.IngressBackend{ + Service: &networkingv1.IngressServiceBackend{ + Name: utils.InventoryArtifactsServerName, + Port: networkingv1.ServiceBackendPort{ + Name: utils.InventoryIngressName, + }, + }, + }, + }, { Path: "/o2ims-infrastructureMonitoring", PathType: func() *networkingv1.PathType { @@ -1535,6 +1697,10 @@ func (t *reconcilerTask) updateInventoryUsedConfigStatus( t.object.Status.UsedServerConfig.ResourceServerUsedConfig = deploymentArgs } + if serverName == utils.InventoryArtifactsServerName { + t.object.Status.UsedServerConfig.ArtifactsServerUsedConfig = deploymentArgs + } + // If there is an error passed, include it in the condition. if err != nil { meta.SetStatusCondition( diff --git a/internal/controllers/inventory_controller_test.go b/internal/controllers/inventory_controller_test.go index b6ff0ffc..75d01eee 100644 --- a/internal/controllers/inventory_controller_test.go +++ b/internal/controllers/inventory_controller_test.go @@ -275,7 +275,7 @@ var _ = DescribeTable( }, ), Entry( - "Resource and alarms servers required", + "Resource, alarms and artifacts servers required", []client.Object{ &inventoryv1alpha1.Inventory{ ObjectMeta: metav1.ObjectMeta{ @@ -295,6 +295,11 @@ var _ = DescribeTable( Enabled: true, }, }, + ArtifactsServerConfig: inventoryv1alpha1.ArtifactsServerConfig{ + ServerConfig: inventoryv1alpha1.ServerConfig{ + Enabled: true, + }, + }, }, }, }, @@ -307,7 +312,7 @@ var _ = DescribeTable( func(result ctrl.Result, reconciler Reconciler) { Expect(result).To(Equal(ctrl.Result{RequeueAfter: 5 * time.Minute})) - // Check that the metadata deployment exists. + // Check that the resource server exists. resourceDeployment := &appsv1.Deployment{} err := reconciler.Client.Get( context.TODO(), @@ -318,7 +323,7 @@ var _ = DescribeTable( resourceDeployment) Expect(err).ToNot(HaveOccurred()) - // Check that the deployment manager server exists. + // Check that the alarms server exists. alarmsDeployment := &appsv1.Deployment{} err = reconciler.Client.Get( context.TODO(), @@ -328,6 +333,17 @@ var _ = DescribeTable( }, alarmsDeployment) Expect(err).ToNot(HaveOccurred()) + + // Check that the artifacts server exists. + artifactsDeployment := &appsv1.Deployment{} + err = reconciler.Client.Get( + context.TODO(), + types.NamespacedName{ + Name: utils.InventoryArtifactsServerName, + Namespace: utils.InventoryNamespace, + }, + artifactsDeployment) + Expect(err).ToNot(HaveOccurred()) }, ), Entry( diff --git a/internal/controllers/utils/constants.go b/internal/controllers/utils/constants.go index 0577a4e9..8603231e 100644 --- a/internal/controllers/utils/constants.go +++ b/internal/controllers/utils/constants.go @@ -9,10 +9,11 @@ const ( // Base resource names const ( - InventoryDatabase = "postgres" - InventoryResource = "resource" - InventoryAlarms = "alarms" - InventoryCluster = "cluster" + InventoryDatabase = "postgres" + InventoryResource = "resource" + InventoryAlarms = "alarms" + InventoryCluster = "cluster" + InventoryArtifacts = "artifacts" ) // Suffix for server names @@ -20,10 +21,11 @@ const serverSuffix = "-server" // Deployment names const ( - InventoryDatabaseServerName = InventoryDatabase + serverSuffix - InventoryResourceServerName = InventoryResource + serverSuffix - InventoryAlarmServerName = InventoryAlarms + serverSuffix - InventoryClusterServerName = InventoryCluster + serverSuffix + InventoryDatabaseServerName = InventoryDatabase + serverSuffix + InventoryResourceServerName = InventoryResource + serverSuffix + InventoryAlarmServerName = InventoryAlarms + serverSuffix + InventoryClusterServerName = InventoryCluster + serverSuffix + InventoryArtifactsServerName = InventoryArtifacts + serverSuffix ) // InventoryIngressName the name of our Ingress controller instance @@ -42,6 +44,13 @@ var ( "serve", "--api-listener-address=127.0.0.1:8000", } + + ArtifactsServerArgs = []string{ + "artifacts-server", + "serve", + "--api-listener-address=127.0.0.1:8000", + } + ResourceServerArgs = []string{ "resource-server", "serve", diff --git a/internal/controllers/utils/utils.go b/internal/controllers/utils/utils.go index 4d95e98a..5ce20bb1 100644 --- a/internal/controllers/utils/utils.go +++ b/internal/controllers/utils/utils.go @@ -159,7 +159,8 @@ func HasApiEndpoints(serverName string) bool { return serverName == InventoryDatabaseServerName || serverName == InventoryClusterServerName || serverName == InventoryAlarmServerName || - serverName == InventoryResourceServerName + serverName == InventoryResourceServerName || + serverName == InventoryArtifactsServerName } // HasDatabase determines whether a server owns a logical database instance @@ -425,6 +426,13 @@ func GetServerArgs(inventory *inventoryv1alpha1.Inventory, serverName string) (r return } + if serverName == InventoryArtifactsServerName { + result = slices.Clone(ArtifactsServerArgs) + + // TODO: Add SMO/OAuth command line arguments when notifications are added. + return + } + // ResourceServer if serverName == InventoryResourceServerName { result = slices.Clone(ResourceServerArgs) @@ -773,6 +781,10 @@ func CreateDefaultInventoryCR(ctx context.Context, c client.Client) error { ServerConfig: inventoryv1alpha1.ServerConfig{ Enabled: true}, }, + ArtifactsServerConfig: inventoryv1alpha1.ArtifactsServerConfig{ + ServerConfig: inventoryv1alpha1.ServerConfig{ + Enabled: true}, + }, ResourceServerConfig: inventoryv1alpha1.ResourceServerConfig{ ServerConfig: inventoryv1alpha1.ServerConfig{ Enabled: true, diff --git a/internal/service/artifacts/api/server.go b/internal/service/artifacts/api/server.go index 496b72e3..1aff2b03 100644 --- a/internal/service/artifacts/api/server.go +++ b/internal/service/artifacts/api/server.go @@ -8,16 +8,20 @@ import ( "github.com/google/uuid" provisioningv1alpha1 "github.com/openshift-kni/oran-o2ims/api/provisioning/v1alpha1" api "github.com/openshift-kni/oran-o2ims/internal/service/artifacts/api/generated" + "github.com/openshift-kni/oran-o2ims/internal/service/common/utils" "sigs.k8s.io/controller-runtime/pkg/client" ) -// ArtifactsServer implements StrictServerInterface. This ensures that we've conformed to the `StrictServerInterface` with a compile-time check -var _ api.StrictServerInterface = (*ArtifactsServer)(nil) - +type ArtifactsServerConfig struct { + utils.CommonServerConfig +} type ArtifactsServer struct { HubClient client.Client } +// ArtifactsServer implements StrictServerInterface. This ensures that we've conformed to the `StrictServerInterface` with a compile-time check +var _ api.StrictServerInterface = (*ArtifactsServer)(nil) + // Get managed infrastructure templates // (GET /o2ims-infrastructureArtifacts/v1/managedInfrastructureTemplates) func (r *ArtifactsServer) GetManagedInfrastructureTemplates( diff --git a/internal/service/artifacts/cmd/serve.go b/internal/service/artifacts/cmd/serve.go index bbdeabbd..56ec866d 100644 --- a/internal/service/artifacts/cmd/serve.go +++ b/internal/service/artifacts/cmd/serve.go @@ -1,13 +1,18 @@ package cmd import ( + "fmt" "log/slog" "os" artifacts "github.com/openshift-kni/oran-o2ims/internal/service/artifacts" + "github.com/openshift-kni/oran-o2ims/internal/service/artifacts/api" + utils2 "github.com/openshift-kni/oran-o2ims/internal/service/common/utils" "github.com/spf13/cobra" ) +var config api.ArtifactsServerConfig + // artifactsServer represents start command for the artifacts server var artifactsServer = &cobra.Command{ Use: "serve", @@ -20,6 +25,18 @@ var artifactsServer = &cobra.Command{ }, } +// setServerFlags creates the flag instances for the server +func setServerFlags(cmd *cobra.Command) error { + if err := utils2.SetCommonServerFlags(cmd, &config.CommonServerConfig); err != nil { + return fmt.Errorf("could not set common server flags: %w", err) + } + + return nil +} + func init() { + if err := setServerFlags(artifactsServer); err != nil { + panic(err) + } artifactsRootCmd.AddCommand(artifactsServer) } diff --git a/vendor/github.com/openshift-kni/oran-o2ims/api/inventory/v1alpha1/inventory_types.go b/vendor/github.com/openshift-kni/oran-o2ims/api/inventory/v1alpha1/inventory_types.go index 97634c6a..a0b3938c 100644 --- a/vendor/github.com/openshift-kni/oran-o2ims/api/inventory/v1alpha1/inventory_types.go +++ b/vendor/github.com/openshift-kni/oran-o2ims/api/inventory/v1alpha1/inventory_types.go @@ -81,6 +81,13 @@ type ServerConfig struct { Enabled bool `json:"enabled"` } +// ArtifactsServerConfig contains the configuration for the artifacts server. +type ArtifactsServerConfig struct { + //+kubebuilder:default:={enabled:true} + //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Server Configuration",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:bool"} + ServerConfig `json:",inline"` +} + // ResourceServerConfig contains the configuration for the resource server. type ResourceServerConfig struct { //+kubebuilder:default:={enabled:true} @@ -141,6 +148,10 @@ type InventorySpec struct { //+optional //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Cloud ID",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} CloudID *string `json:"cloudID"` + // ArtifactsServerConfig contains the configuration for the artifacts server. + //+optional + //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Artifacts Server Configuration",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} + ArtifactsServerConfig ArtifactsServerConfig `json:"artifactsServerConfig,omitempty"` // ResourceServerConfig contains the configuration for the resource server. //+optional //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Resource Server Configuration",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} @@ -178,12 +189,14 @@ type DeploymentsStatus struct { ResourceServerStatus string `json:"resourceServerStatus,omitempty"` // +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Alarm Server Status" AlarmServerStatus string `json:"alarmServerStatus,omitempty"` + // +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Artifacts Server Status" + ArtifactsServerStatus string `json:"artifactsServerStatus,omitempty"` } type UsedServerConfig struct { - MetadataServerUsedConfig []string `json:"metadataServerUsedConfig,omitempty"` - ResourceServerUsedConfig []string `json:"resourceServerUsedConfig,omitempty"` - DeploymentManagerServerUsedConfig []string `json:"deploymentManagerServerUsedConfig,omitempty"` + ArtifactsServerUsedConfig []string `json:"artifactsServerUsedConfig,omitempty"` + MetadataServerUsedConfig []string `json:"metadataServerUsedConfig,omitempty"` + ResourceServerUsedConfig []string `json:"resourceServerUsedConfig,omitempty"` } // InventoryStatus defines the observed state of Inventory diff --git a/vendor/github.com/openshift-kni/oran-o2ims/api/inventory/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/oran-o2ims/api/inventory/v1alpha1/zz_generated.deepcopy.go index c21059f6..f4617afa 100644 --- a/vendor/github.com/openshift-kni/oran-o2ims/api/inventory/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift-kni/oran-o2ims/api/inventory/v1alpha1/zz_generated.deepcopy.go @@ -46,6 +46,22 @@ func (in *AlarmServerConfig) DeepCopy() *AlarmServerConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArtifactsServerConfig) DeepCopyInto(out *ArtifactsServerConfig) { + *out = *in + out.ServerConfig = in.ServerConfig +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArtifactsServerConfig. +func (in *ArtifactsServerConfig) DeepCopy() *ArtifactsServerConfig { + if in == nil { + return nil + } + out := new(ArtifactsServerConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterServerConfig) DeepCopyInto(out *ClusterServerConfig) { *out = *in @@ -154,6 +170,7 @@ func (in *InventorySpec) DeepCopyInto(out *InventorySpec) { *out = new(string) **out = **in } + out.ArtifactsServerConfig = in.ArtifactsServerConfig in.ResourceServerConfig.DeepCopyInto(&out.ResourceServerConfig) in.ClusterServerConfig.DeepCopyInto(&out.ClusterServerConfig) in.AlarmServerConfig.DeepCopyInto(&out.AlarmServerConfig) @@ -317,6 +334,11 @@ func (in *TLSConfig) DeepCopy() *TLSConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UsedServerConfig) DeepCopyInto(out *UsedServerConfig) { *out = *in + if in.ArtifactsServerUsedConfig != nil { + in, out := &in.ArtifactsServerUsedConfig, &out.ArtifactsServerUsedConfig + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.MetadataServerUsedConfig != nil { in, out := &in.MetadataServerUsedConfig, &out.MetadataServerUsedConfig *out = make([]string, len(*in)) @@ -327,11 +349,6 @@ func (in *UsedServerConfig) DeepCopyInto(out *UsedServerConfig) { *out = make([]string, len(*in)) copy(*out, *in) } - if in.DeploymentManagerServerUsedConfig != nil { - in, out := &in.DeploymentManagerServerUsedConfig, &out.DeploymentManagerServerUsedConfig - *out = make([]string, len(*in)) - copy(*out, *in) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UsedServerConfig.