-
Notifications
You must be signed in to change notification settings - Fork 5
fix(versions): log release versions when config is missing #745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
8a003bb
to
3785e41
Compare
I'm removing the |
30a65d8
to
4a2bd42
Compare
When no fab.yaml is found, the versions command shows the release versions instead of an error If there are overrides in fab.yaml, they are shown Signed-off-by: Pau Capdevila <[email protected]>
hhfab versions --live Signed-off-by: Pau Capdevila <[email protected]>
Signed-off-by: Pau Capdevila <[email protected]>
Signed-off-by: Pau Capdevila <[email protected]>
Signed-off-by: Pau Capdevila <[email protected]>
4a2bd42
to
fc41208
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the versions
command to:
- Fallback to printing built-in release versions when no
fab.yaml
is found - Introduce a
--live
flag to fetch versions from a running Fabricator in-cluster - Update CI workflows to invoke
bin/hhfab versions
and remove the oldVersions
incmdconfig.go
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
pkg/hhfab/cmdversions.go | New command implementation handling missing config and live fetch |
pkg/hhfab/cmdconfig.go | Remove deprecated Versions function |
cmd/hhfab/main.go | Add --live flag to the versions command |
.github/workflows/ci.yaml | Invoke bin/hhfab versions in multiple CI steps |
Comments suppressed due to low confidence (2)
pkg/hhfab/cmdversions.go:96
- Add unit tests for formatVersions and compareVersionMaps to verify correct YAML output in both override and no-override scenarios.
func formatVersions(releaseVersions, overriddenVersions fabapi.Versions) (string, error) {
pkg/hhfab/cmdversions.go:21
- [nitpick] Add a Go doc comment for the exported Versions function explaining its parameters and behavior (missing config vs live cluster).
func Versions(ctx context.Context, workDir, cacheDir string, hMode HydrateMode, live bool) error {
overriddenMap, err := convertToMap(overriddenVersions) | ||
if err != nil { | ||
slog.Warn("Failed to convert overridden versions", "error", err) | ||
data, _ := kyaml.Marshal(releaseVersions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid ignoring the error from kyaml.Marshal here; handle or log it so that serialization failures in the fallback path are not silently dropped.
data, _ := kyaml.Marshal(releaseVersions) | |
data, marshalErr := kyaml.Marshal(releaseVersions) | |
if marshalErr != nil { | |
slog.Warn("Failed to marshal release versions", "error", marshalErr) | |
return "", fmt.Errorf("marshalling release versions: %w", marshalErr) | |
} |
Copilot uses AI. Check for mistakes.
freshFab := fabapi.Fabricator{} | ||
if err := freshFab.CalculateVersions(fab.Versions); err != nil { | ||
return fmt.Errorf("calculating default versions: %w", err) | ||
} | ||
|
||
versionsData, err := formatVersions(freshFab.Status.Versions, cfg.Fab.Status.Versions) | ||
if err != nil { | ||
return fmt.Errorf("formatting versions: %w", err) | ||
} | ||
|
||
fmt.Println(versionsData) | ||
|
||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] There are multiple duplicated blocks that call CalculateVersions and print results; consider extracting common code into a helper to reduce duplication.
freshFab := fabapi.Fabricator{} | |
if err := freshFab.CalculateVersions(fab.Versions); err != nil { | |
return fmt.Errorf("calculating default versions: %w", err) | |
} | |
versionsData, err := formatVersions(freshFab.Status.Versions, cfg.Fab.Status.Versions) | |
if err != nil { | |
return fmt.Errorf("formatting versions: %w", err) | |
} | |
fmt.Println(versionsData) | |
return nil | |
return processVersions(fab.Versions, cfg.Fab.Status.Versions, false) |
Copilot uses AI. Check for mistakes.
When no fab.yaml is found, the versions command shows the release versions instead of an error:
VS:
If there are overrides in fab.yaml or in the API object, they are shown: