diff --git a/apis/dscinitialization/v1/dscinitialization_types.go b/apis/dscinitialization/v1/dscinitialization_types.go index 3c5055f5c95..8c8cd6e7aa4 100644 --- a/apis/dscinitialization/v1/dscinitialization_types.go +++ b/apis/dscinitialization/v1/dscinitialization_types.go @@ -49,7 +49,7 @@ type DSCInitializationSpec struct { // This is not recommended to be used in production environment. // +operator-sdk:csv:customresourcedefinitions:type=spec,order=4 // +optional - DevFlags DevFlags `json:"devFlags,omitempty"` + DevFlags *DevFlags `json:"devFlags,omitempty"` } type Monitoring struct { diff --git a/apis/dscinitialization/v1/zz_generated.deepcopy.go b/apis/dscinitialization/v1/zz_generated.deepcopy.go index d8b29a11839..800f45905ed 100644 --- a/apis/dscinitialization/v1/zz_generated.deepcopy.go +++ b/apis/dscinitialization/v1/zz_generated.deepcopy.go @@ -32,7 +32,7 @@ func (in *DSCInitialization) DeepCopyInto(out *DSCInitialization) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) } @@ -91,7 +91,11 @@ func (in *DSCInitializationSpec) DeepCopyInto(out *DSCInitializationSpec) { *out = *in out.Monitoring = in.Monitoring out.ServiceMesh = in.ServiceMesh - out.DevFlags = in.DevFlags + if in.DevFlags != nil { + in, out := &in.DevFlags, &out.DevFlags + *out = new(DevFlags) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DSCInitializationSpec. diff --git a/components/codeflare/codeflare.go b/components/codeflare/codeflare.go index 6c1e685a0ec..9066aa6f2da 100644 --- a/components/codeflare/codeflare.go +++ b/components/codeflare/codeflare.go @@ -32,6 +32,9 @@ type CodeFlare struct { } func (c *CodeFlare) OverrideManifests(_ string) error { + if c.DevFlags == nil { + return nil + } // If devflags are set, update default manifests path if len(c.DevFlags.Manifests) != 0 { manifestConfig := c.DevFlags.Manifests[0] @@ -85,7 +88,7 @@ func (c *CodeFlare) ReconcileComponent(cli client.Client, owner metav1.Object, d } // Update image parameters only when we do not have customized manifests set - if dscispec.DevFlags.ManifestsUri == "" && len(c.DevFlags.Manifests) == 0 { + if c.DevFlags != nil && dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" && len(c.DevFlags.Manifests) == 0 { if err := deploy.ApplyParams(CodeflarePath+"/bases", c.SetImageParamsMap(imageParamMap), true); err != nil { return err } diff --git a/components/component.go b/components/component.go index 56a1b9c0aa7..39e30a4b749 100644 --- a/components/component.go +++ b/components/component.go @@ -32,7 +32,7 @@ type Component struct { // Add developer fields // +optional // +operator-sdk:csv:customresourcedefinitions:type=spec,order=2 - DevFlags DevFlags `json:"devFlags,omitempty"` + DevFlags *DevFlags `json:"devFlags,omitempty"` } func (c *Component) GetManagementState() operatorv1.ManagementState { diff --git a/components/dashboard/dashboard.go b/components/dashboard/dashboard.go index 7d83d3eee06..17cb777843d 100644 --- a/components/dashboard/dashboard.go +++ b/components/dashboard/dashboard.go @@ -48,6 +48,9 @@ type Dashboard struct { } func (d *Dashboard) OverrideManifests(platform string) error { + if d.DevFlags == nil { + return nil + } // If devflags are set, update default manifests path if len(d.DevFlags.Manifests) != 0 { manifestConfig := d.DevFlags.Manifests[0] @@ -127,7 +130,7 @@ func (d *Dashboard) ReconcileComponent(cli client.Client, owner metav1.Object, d } // Update image parameters (ODH does not use this solution, only downstream) - if dscispec.DevFlags.ManifestsUri == "" && len(d.DevFlags.Manifests) == 0 { + if d.DevFlags != nil && dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" && len(d.DevFlags.Manifests) == 0 { if err := deploy.ApplyParams(PathSupported, d.SetImageParamsMap(imageParamMap), false); err != nil { return err } diff --git a/components/datasciencepipelines/datasciencepipelines.go b/components/datasciencepipelines/datasciencepipelines.go index 0a331974918..b6bc06df2b9 100644 --- a/components/datasciencepipelines/datasciencepipelines.go +++ b/components/datasciencepipelines/datasciencepipelines.go @@ -29,6 +29,9 @@ type DataSciencePipelines struct { } func (d *DataSciencePipelines) OverrideManifests(_ string) error { + if d.DevFlags == nil { + return nil + } // If devflags are set, update default manifests path if len(d.DevFlags.Manifests) != 0 { manifestConfig := d.DevFlags.Manifests[0] @@ -76,7 +79,7 @@ func (d *DataSciencePipelines) ReconcileComponent(cli client.Client, owner metav // skip check if the dependent operator has beeninstalled, this is done in dashboard // Update image parameters only when we do not have customized manifests set - if dscispec.DevFlags.ManifestsUri == "" && len(d.DevFlags.Manifests) == 0 { + if d.DevFlags != nil && dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" && len(d.DevFlags.Manifests) == 0 { if err := deploy.ApplyParams(Path, d.SetImageParamsMap(imageParamMap), false); err != nil { return err } diff --git a/components/kserve/kserve.go b/components/kserve/kserve.go index fd9fd032cf9..df6c7535ec7 100644 --- a/components/kserve/kserve.go +++ b/components/kserve/kserve.go @@ -41,35 +41,36 @@ type Kserve struct { } func (k *Kserve) OverrideManifests(_ string) error { + if k.DevFlags == nil { + return nil + } // Download manifests if defined by devflags - if len(k.DevFlags.Manifests) != 0 { - // Go through each manifests and set the overlays if defined - for _, subcomponent := range k.DevFlags.Manifests { - if strings.Contains(subcomponent.URI, DependentComponentName) { - // Download subcomponent - if err := deploy.DownloadManifests(DependentComponentName, subcomponent); err != nil { - return err - } - // If overlay is defined, update paths - defaultKustomizePath := "base" - if subcomponent.SourcePath != "" { - defaultKustomizePath = subcomponent.SourcePath - } - DependentPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath) + // Go through each manifests and set the overlays if defined + for _, subcomponent := range k.DevFlags.Manifests { + if strings.Contains(subcomponent.URI, DependentComponentName) { + // Download subcomponent + if err := deploy.DownloadManifests(DependentComponentName, subcomponent); err != nil { + return err + } + // If overlay is defined, update paths + defaultKustomizePath := "base" + if subcomponent.SourcePath != "" { + defaultKustomizePath = subcomponent.SourcePath } + DependentPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath) + } - if strings.Contains(subcomponent.URI, ComponentName) { - // Download subcomponent - if err := deploy.DownloadManifests(ComponentName, subcomponent); err != nil { - return err - } - // If overlay is defined, update paths - defaultKustomizePath := "overlays/odh" - if subcomponent.SourcePath != "" { - defaultKustomizePath = subcomponent.SourcePath - } - Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath) + if strings.Contains(subcomponent.URI, ComponentName) { + // Download subcomponent + if err := deploy.DownloadManifests(ComponentName, subcomponent); err != nil { + return err + } + // If overlay is defined, update paths + defaultKustomizePath := "overlays/odh" + if subcomponent.SourcePath != "" { + defaultKustomizePath = subcomponent.SourcePath } + Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath) } } @@ -116,7 +117,7 @@ func (k *Kserve) ReconcileComponent(cli client.Client, owner metav1.Object, dsci } // Update image parameters only when we do not have customized manifests set - if dscispec.DevFlags.ManifestsUri == "" && len(k.DevFlags.Manifests) == 0 { + if k.DevFlags != nil && dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" && len(k.DevFlags.Manifests) == 0 { if err := deploy.ApplyParams(Path, k.SetImageParamsMap(imageParamMap), false); err != nil { return err } @@ -133,7 +134,7 @@ func (k *Kserve) ReconcileComponent(cli client.Client, owner metav1.Object, dsci return err } // Update image parameters for odh-model-controller - if dscispec.DevFlags.ManifestsUri == "" && len(k.DevFlags.Manifests) == 0 { + if k.DevFlags != nil && dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" && len(k.DevFlags.Manifests) == 0 { if err := deploy.ApplyParams(DependentPath, k.SetImageParamsMap(dependentParamMap), false); err != nil { return err } diff --git a/components/modelmeshserving/modelmeshserving.go b/components/modelmeshserving/modelmeshserving.go index 75acf6d72e3..9fa2c078bc9 100644 --- a/components/modelmeshserving/modelmeshserving.go +++ b/components/modelmeshserving/modelmeshserving.go @@ -32,6 +32,9 @@ type ModelMeshServing struct { } func (m *ModelMeshServing) OverrideManifests(_ string) error { + if m.DevFlags == nil { + return nil + } // Go through each manifests and set the overlays if defined for _, subcomponent := range m.DevFlags.Manifests { if strings.Contains(subcomponent.URI, DependentComponentName) { @@ -60,7 +63,6 @@ func (m *ModelMeshServing) OverrideManifests(_ string) error { Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath) } } - return nil } @@ -104,7 +106,7 @@ func (m *ModelMeshServing) ReconcileComponent(cli client.Client, owner metav1.Ob return err } // Update image parameters - if dscispec.DevFlags.ManifestsUri == "" && len(m.DevFlags.Manifests) == 0 { + if m.DevFlags != nil && dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" && len(m.DevFlags.Manifests) == 0 { if err := deploy.ApplyParams(Path, m.SetImageParamsMap(imageParamMap), false); err != nil { return err } @@ -123,7 +125,7 @@ func (m *ModelMeshServing) ReconcileComponent(cli client.Client, owner metav1.Ob return err } // Update image parameters for odh-model-controller - if dscispec.DevFlags.ManifestsUri == "" { + if dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" { if err := deploy.ApplyParams(DependentPath, m.SetImageParamsMap(dependentImageParamMap), false); err != nil { return err } diff --git a/components/ray/ray.go b/components/ray/ray.go index 0d0e2a90e0f..64b3664b9b7 100644 --- a/components/ray/ray.go +++ b/components/ray/ray.go @@ -29,6 +29,9 @@ type Ray struct { } func (r *Ray) OverrideManifests(_ string) error { + if r.DevFlags == nil { + return nil + } // If devflags are set, update default manifests path if len(r.DevFlags.Manifests) != 0 { manifestConfig := r.DevFlags.Manifests[0] @@ -69,7 +72,7 @@ func (r *Ray) ReconcileComponent(cli client.Client, owner metav1.Object, dscispe return err } - if dscispec.DevFlags.ManifestsUri == "" || len(r.DevFlags.Manifests) == 0 { + if (dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "") || (r.DevFlags != nil && len(r.DevFlags.Manifests) == 0) { if err := deploy.ApplyParams(RayPath, r.SetImageParamsMap(imageParamMap), true); err != nil { return err } diff --git a/components/trustyai/trustyai.go b/components/trustyai/trustyai.go index ee3da9062a5..badc2c7a2f5 100644 --- a/components/trustyai/trustyai.go +++ b/components/trustyai/trustyai.go @@ -28,6 +28,9 @@ type TrustyAI struct { } func (t *TrustyAI) OverrideManifests(_ string) error { + if t.DevFlags == nil { + return nil + } // If devflags are set, update default manifests path if len(t.DevFlags.Manifests) != 0 { manifestConfig := t.DevFlags.Manifests[0] @@ -67,7 +70,7 @@ func (t *TrustyAI) ReconcileComponent(cli client.Client, owner metav1.Object, ds return err } - if dscispec.DevFlags.ManifestsUri == "" { + if dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" { if err := deploy.ApplyParams(Path, t.SetImageParamsMap(imageParamMap), false); err != nil { return err } diff --git a/components/workbenches/workbenches.go b/components/workbenches/workbenches.go index f3b645d2999..843afe325a4 100644 --- a/components/workbenches/workbenches.go +++ b/components/workbenches/workbenches.go @@ -36,57 +36,57 @@ type Workbenches struct { } func (w *Workbenches) OverrideManifests(platform string) error { + if w.DevFlags == nil { + return nil + } // Download manifests if defined by devflags - if len(w.DevFlags.Manifests) != 0 { - // Go through each manifests and set the overlays if defined - for _, subcomponent := range w.DevFlags.Manifests { - if strings.Contains(subcomponent.URI, DependentComponentName) { - // Download subcomponent - if err := deploy.DownloadManifests(DependentComponentName, subcomponent); err != nil { - return err - } - // If overlay is defined, update paths - defaultKustomizePath := "overlays/additional" - defaultKustomizePathSupported := "notebook-images/overlays/additional" - if subcomponent.SourcePath != "" { - defaultKustomizePath = subcomponent.SourcePath - defaultKustomizePathSupported = subcomponent.SourcePath - } - if platform == string(deploy.ManagedRhods) || platform == string(deploy.SelfManagedRhods) { - notebookImagesPathSupported = filepath.Join(deploy.DefaultManifestPath, "jupyterhub", defaultKustomizePathSupported) - } else { - notebookImagesPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath) - } + // Go through each manifests and set the overlays if defined + for _, subcomponent := range w.DevFlags.Manifests { + if strings.Contains(subcomponent.URI, DependentComponentName) { + // Download subcomponent + if err := deploy.DownloadManifests(DependentComponentName, subcomponent); err != nil { + return err } + // If overlay is defined, update paths + defaultKustomizePath := "overlays/additional" + defaultKustomizePathSupported := "notebook-images/overlays/additional" + if subcomponent.SourcePath != "" { + defaultKustomizePath = subcomponent.SourcePath + defaultKustomizePathSupported = subcomponent.SourcePath + } + if platform == string(deploy.ManagedRhods) || platform == string(deploy.SelfManagedRhods) { + notebookImagesPathSupported = filepath.Join(deploy.DefaultManifestPath, "jupyterhub", defaultKustomizePathSupported) + } else { + notebookImagesPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath) + } + } - if strings.Contains(subcomponent.ContextDir, "components/odh-notebook-controller") { - // Download subcomponent - if err := deploy.DownloadManifests("odh-notebook-controller/odh-notebook-controller", subcomponent); err != nil { - return err - } - // If overlay is defined, update paths - defaultKustomizePathNbc := "base" - if subcomponent.SourcePath != "" { - defaultKustomizePathNbc = subcomponent.SourcePath - } - notebookControllerPath = filepath.Join(deploy.DefaultManifestPath, "odh-notebook-controller/odh-notebook-controller", defaultKustomizePathNbc) + if strings.Contains(subcomponent.ContextDir, "components/odh-notebook-controller") { + // Download subcomponent + if err := deploy.DownloadManifests("odh-notebook-controller/odh-notebook-controller", subcomponent); err != nil { + return err + } + // If overlay is defined, update paths + defaultKustomizePathNbc := "base" + if subcomponent.SourcePath != "" { + defaultKustomizePathNbc = subcomponent.SourcePath } + notebookControllerPath = filepath.Join(deploy.DefaultManifestPath, "odh-notebook-controller/odh-notebook-controller", defaultKustomizePathNbc) + } - if strings.Contains(subcomponent.ContextDir, "components/notebook-controller") { - // Download subcomponent - if err := deploy.DownloadManifests("odh-notebook-controller/kf-notebook-controller", subcomponent); err != nil { - return err - } - // If overlay is defined, update paths - defaultKustomizePathKfNbc := "overlays/openshift" - if subcomponent.SourcePath != "" { - defaultKustomizePathKfNbc = subcomponent.SourcePath - } - kfnotebookControllerPath = filepath.Join(deploy.DefaultManifestPath, "odh-notebook-controller/kf-notebook-controller", defaultKustomizePathKfNbc) + if strings.Contains(subcomponent.ContextDir, "components/notebook-controller") { + // Download subcomponent + if err := deploy.DownloadManifests("odh-notebook-controller/kf-notebook-controller", subcomponent); err != nil { + return err } + // If overlay is defined, update paths + defaultKustomizePathKfNbc := "overlays/openshift" + if subcomponent.SourcePath != "" { + defaultKustomizePathKfNbc = subcomponent.SourcePath + } + kfnotebookControllerPath = filepath.Join(deploy.DefaultManifestPath, "odh-notebook-controller/kf-notebook-controller", defaultKustomizePathKfNbc) } } - return nil } @@ -137,7 +137,7 @@ func (w *Workbenches) ReconcileComponent(cli client.Client, owner metav1.Object, // Update image parameters for nbc in downstream if enabled { - if dscispec.DevFlags.ManifestsUri == "" && len(w.DevFlags.Manifests) == 0 { + if w.DevFlags != nil && dscispec.DevFlags != nil && dscispec.DevFlags.ManifestsUri == "" && len(w.DevFlags.Manifests) == 0 { if platform == deploy.ManagedRhods || platform == deploy.SelfManagedRhods { // for kf-notebook-controller image if err := deploy.ApplyParams(notebookControllerPath, w.SetImageParamsMap(imageParamMap), false); err != nil { diff --git a/components/zz_generated.deepcopy.go b/components/zz_generated.deepcopy.go index e9af55fc108..e7968282dc9 100644 --- a/components/zz_generated.deepcopy.go +++ b/components/zz_generated.deepcopy.go @@ -26,7 +26,11 @@ import () // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Component) DeepCopyInto(out *Component) { *out = *in - in.DevFlags.DeepCopyInto(&out.DevFlags) + if in.DevFlags != nil { + in, out := &in.DevFlags, &out.DevFlags + *out = new(DevFlags) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Component.