Skip to content

Commit

Permalink
skipping the component versions if "version" field is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ugiordan committed Jan 29, 2025
1 parent e56b6fc commit 5f73611
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package releases

import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"

"gopkg.in/yaml.v3"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/opendatahub-io/opendatahub-operator/v2/apis/common"
Expand Down Expand Up @@ -122,19 +122,23 @@ func (a *Action) render(ctx context.Context, rr *types.ReconciliationRequest) ([

// Unmarshal YAML into defined struct
var componentMeta common.ComponentReleaseStatus
if err := json.Unmarshal(yamlData, &componentMeta); err != nil {
if err := yaml.Unmarshal(yamlData, &componentMeta); err != nil {

Check failure on line 125 in pkg/controller/actions/status/releases/action_fetch_releases_status.go

View workflow job for this annotation

GitHub Actions / golangci-lint

the given struct should be annotated with the `yaml` tag (musttag)
return nil, fmt.Errorf("error unmarshaling YAML: %w", err)
}

// Parse and populate releases
componentReleasesStatus := make([]common.ComponentRelease, 0, len(componentMeta.Releases))
for _, release := range componentMeta.Releases {
componentVersion := strings.TrimSpace(release.Version)
componentReleasesStatus = append(componentReleasesStatus, common.ComponentRelease{
Name: release.Name,
Version: componentVersion,
RepoURL: release.RepoURL,
})

// Appending the component version only if it's not empty
if componentVersion != "" {
componentReleasesStatus = append(componentReleasesStatus, common.ComponentRelease{
Name: release.Name,
Version: componentVersion,
RepoURL: release.RepoURL,
})
}
}

return componentReleasesStatus, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ releases:
repoUrl: https://github.com/kubeflow/kfp-tekton
`,
expectedReleases: 0,
expectedError: true,
expectedError: false,
},
{
name: "should handle empty metadata file path gracefully",
Expand Down

0 comments on commit 5f73611

Please sign in to comment.