Skip to content

Commit

Permalink
fix devflags empty object
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayJagan committed Dec 13, 2023
1 parent 705d980 commit 6e3d55e
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 84 deletions.
2 changes: 1 addition & 1 deletion apis/dscinitialization/v1/dscinitialization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions apis/dscinitialization/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
}
Expand Down
55 changes: 28 additions & 27 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
8 changes: 5 additions & 3 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -60,7 +63,6 @@ func (m *ModelMeshServing) OverrideManifests(_ string) error {
Path = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath)
}
}

return nil
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion components/ray/ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion components/trustyai/trustyai.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
}
Expand Down
88 changes: 44 additions & 44 deletions components/workbenches/workbenches.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion components/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6e3d55e

Please sign in to comment.