-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
refactor: SUSE - update OSType constants and references for compatibi… #8202
base: release/v0.58
Are you sure you want to change the base?
refactor: SUSE - update OSType constants and references for compatibi… #8202
Conversation
santhosh1729
commented
Jan 6, 2025
- Renamed deprecated SUE OSType constants to maintain backward compatibility.
- Modified all occurrences where the old constants were used to ensure consistency
Can we just replace the legacy names with the new names in a single place? For example: diff --git a/pkg/fanal/types/artifact.go b/pkg/fanal/types/artifact.go
index b25aaa954..18f026653 100644
--- a/pkg/fanal/types/artifact.go
+++ b/pkg/fanal/types/artifact.go
@@ -45,6 +45,14 @@ func (o *OS) Merge(newOS OS) {
o.Extended = true
}
}
+ o.Normalize()
+}
+
+// Normalize normalizes OS family names for backward compatibility
+func (o *OS) Normalize() {
+ if alias, ok := OSTypeAliases[o.Family]; ok {
+ o.Family = alias
+ }
}
type Repository struct {
diff --git a/pkg/fanal/types/const.go b/pkg/fanal/types/const.go
index 42f248ba1..2e07709ad 100644
--- a/pkg/fanal/types/const.go
+++ b/pkg/fanal/types/const.go
@@ -41,14 +41,17 @@ const (
SLES OSType = "sles"
Ubuntu OSType = "ubuntu"
Wolfi OSType = "wolfi"
-
- // These below constants are retained for backward compatibility with older versions of Aqua
- OpenSUSELeapLegacy OSType = "opensuse.leap"
- OpenSUSETumbleweedLegacy OSType = "opensuse.tumbleweed"
- SLEMicroLegacy OSType = "suse linux enterprise micro"
- SLESLegacy OSType = "suse linux enterprise server"
)
+// OSTypeAliases is a map of aliases for operating systems.
+// This is used to map the old family names to the new ones for backward compatibility.
+var OSTypeAliases = map[OSType]OSType{
+ "opensuse.leap": OpenSUSELeap,
+ "opensuse.tumbleweed": OpenSUSETumbleweed,
+ "suse linux enterprise micro": SLEMicro,
+ "suse linux enterprise server": SLES,
+}
+
// Programming language dependencies
const (
Bundler LangType = "bundler" |
2f52db6
to
2aca44f
Compare
|
@knqyf263 I have updated the pr with suggested changes, Thank you!! |
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.
The logic looks good, but we need to add a test.
Sure, I will add it. Thank you!! |
2aca44f
to
a5b00a8
Compare
@knqyf263 I have added test for the change, can you please review it once? |
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.
Left a small comment. The rest looks good.
pkg/fanal/applier/applier_test.go
Outdated
@@ -961,6 +961,91 @@ func TestApplier_ApplyLayers(t *testing.T) { | |||
}, | |||
wantErr: "unknown OS", | |||
}, | |||
{ | |||
name: "SUSE Images - Legacy OS Name with Backward Compatibility", |
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.
nit: Other cases are lowercase.
name: "SUSE Images - Legacy OS Name with Backward Compatibility", | |
name: "SUSE images - legacy OS name with backward compatibility", |
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.
@knqyf263 I have updated the Test Name as suggested, Thank you!!
@DmitriyLewen Would you also take a look? |
a5b00a8
to
049d0a0
Compare
…lity 1. Renamed deprecated OSType constants to maintain backward compatibility. 2. Modified all occurrences where the old constants were used to ensure consistency (cherry picked from commit 3d21d19)
049d0a0
to
8d89b2a
Compare