Skip to content

Commit 68334f3

Browse files
committed
refactor(config,sbom): drop python aliases, use python-installed-package-cataloger
Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
1 parent 4072782 commit 68334f3

6 files changed

Lines changed: 18 additions & 97 deletions

File tree

docs/_data/werf_yaml.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,8 @@ sections:
588588
- name: type
589589
value: "string"
590590
description:
591-
en: "Package ecosystem type (go-mod, python-uv, python-pip, python-poetry; aliases: uv, pip, poetry)"
592-
ru: "Тип экосистемы пакетов (go-mod, python-uv, python-pip, python-poetry; алиасы: uv, pip, poetry)"
591+
en: "Package ecosystem type (go-mod, python-uv, python-pip, python-poetry)"
592+
ru: "Тип экосистемы пакетов (go-mod, python-uv, python-pip, python-poetry)"
593593
- name: workdir
594594
value: "string"
595595
description:

pkg/config/packages_directive.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type FileBasedSpec struct {
2828

2929
type PackageEcosystem struct {
3030
Type PackagesDirectiveType
31-
Aliases []string
3231
DefaultSpec string
3332
DefaultLock string
3433
InstallCmd func(workdir, spec string) string
@@ -47,45 +46,32 @@ var ecosystems = map[PackagesDirectiveType]PackageEcosystem{
4746
},
4847
PackagesDirectiveTypePythonUV: {
4948
Type: PackagesDirectiveTypePythonUV,
50-
Aliases: []string{"uv"},
5149
DefaultSpec: "pyproject.toml",
5250
DefaultLock: "uv.lock",
5351
InstallCmd: func(workdir, _ string) string { return fmt.Sprintf("cd %q && uv sync --frozen", workdir) },
54-
CatalogerName: "python-package-cataloger",
52+
CatalogerName: "python-installed-package-cataloger",
5553
UseWorkdirFilter: true,
5654
},
5755
PackagesDirectiveTypePythonPip: {
5856
Type: PackagesDirectiveTypePythonPip,
59-
Aliases: []string{"pip"},
6057
DefaultSpec: "requirements.txt",
6158
DefaultLock: "",
6259
InstallCmd: func(workdir, spec string) string {
6360
return fmt.Sprintf("cd %q && pip install --no-cache-dir -r %q", workdir, spec)
6461
},
65-
CatalogerName: "python-package-cataloger",
62+
CatalogerName: "python-installed-package-cataloger",
6663
UseWorkdirFilter: true,
6764
},
6865
PackagesDirectiveTypePythonPoetry: {
6966
Type: PackagesDirectiveTypePythonPoetry,
70-
Aliases: []string{"poetry"},
7167
DefaultSpec: "pyproject.toml",
7268
DefaultLock: "poetry.lock",
7369
InstallCmd: func(workdir, _ string) string { return fmt.Sprintf("cd %q && poetry install --no-root", workdir) },
74-
CatalogerName: "python-package-cataloger",
70+
CatalogerName: "python-installed-package-cataloger",
7571
UseWorkdirFilter: true,
7672
},
7773
}
7874

79-
var aliasToType = func() map[string]PackagesDirectiveType {
80-
idx := map[string]PackagesDirectiveType{}
81-
for _, eco := range ecosystems {
82-
for _, a := range eco.Aliases {
83-
idx[a] = eco.Type
84-
}
85-
}
86-
return idx
87-
}()
88-
8975
// Ecosystems returns a defensive copy of the file-based package ecosystems registry.
9076
// The returned map is safe to iterate; mutating it does not affect the internal registry.
9177
func Ecosystems() map[PackagesDirectiveType]PackageEcosystem {

pkg/config/packages_directive_python_test.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package config
33
import (
44
. "github.com/onsi/ginkgo/v2"
55
. "github.com/onsi/gomega"
6-
76
"github.com/werf/common-go/pkg/util"
87
)
98

@@ -49,26 +48,6 @@ var _ = Describe("rawPackagesDirective python", func() {
4948
},
5049
),
5150

52-
Entry("uv (short alias) canonicalizes to python-uv with defaults",
53-
map[string]interface{}{
54-
"image": "image1",
55-
"from": "python:3.12",
56-
"packages": []map[string]interface{}{
57-
{"type": "uv", "workdir": "/app"},
58-
},
59-
},
60-
[]*PackagesDirective{
61-
{
62-
Type: PackagesDirectiveTypePythonUV,
63-
FileBased: FileBasedSpec{
64-
Workdir: "/app",
65-
Spec: "pyproject.toml",
66-
Lock: "uv.lock",
67-
},
68-
},
69-
},
70-
),
71-
7251
Entry("python-pip with only workdir defaults spec and empty lock",
7352
map[string]interface{}{
7453
"image": "image1",
@@ -89,26 +68,6 @@ var _ = Describe("rawPackagesDirective python", func() {
8968
},
9069
),
9170

92-
Entry("pip (short alias) canonicalizes to python-pip",
93-
map[string]interface{}{
94-
"image": "image1",
95-
"from": "python:3.12",
96-
"packages": []map[string]interface{}{
97-
{"type": "pip", "workdir": "/app"},
98-
},
99-
},
100-
[]*PackagesDirective{
101-
{
102-
Type: PackagesDirectiveTypePythonPip,
103-
FileBased: FileBasedSpec{
104-
Workdir: "/app",
105-
Spec: "requirements.txt",
106-
Lock: "",
107-
},
108-
},
109-
},
110-
),
111-
11271
Entry("python-poetry with only workdir defaults spec and lock",
11372
map[string]interface{}{
11473
"image": "image1",
@@ -129,26 +88,6 @@ var _ = Describe("rawPackagesDirective python", func() {
12988
},
13089
),
13190

132-
Entry("poetry (short alias) canonicalizes to python-poetry",
133-
map[string]interface{}{
134-
"image": "image1",
135-
"from": "python:3.12",
136-
"packages": []map[string]interface{}{
137-
{"type": "poetry", "workdir": "/app"},
138-
},
139-
},
140-
[]*PackagesDirective{
141-
{
142-
Type: PackagesDirectiveTypePythonPoetry,
143-
FileBased: FileBasedSpec{
144-
Workdir: "/app",
145-
Spec: "pyproject.toml",
146-
Lock: "poetry.lock",
147-
},
148-
},
149-
},
150-
),
151-
15291
Entry("python-uv with explicit spec and lock overrides defaults",
15392
map[string]interface{}{
15493
"image": "image1",

pkg/config/raw_packages_directive.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ func (r *rawPackagesDirective) docForErrors() *doc {
4949
}
5050

5151
func (r *rawPackagesDirective) toDirective() (*PackagesDirective, error) {
52-
if canonical, ok := aliasToType[r.Type]; ok {
53-
r.Type = string(canonical)
54-
}
55-
5652
d := &PackagesDirective{
5753
Type: PackagesDirectiveType(r.Type),
5854
}

pkg/sbom/managedinput/managedinput_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,44 +144,44 @@ var _ = Describe("FilterBOMBySourcePaths", func() {
144144
})
145145

146146
var _ = Describe("ToCatalogers python", func() {
147-
DescribeTable("maps python directives to python-package-cataloger",
147+
DescribeTable("maps python directives to python-installed-package-cataloger",
148148
func(packages []*config.PackagesDirective, expected []scanner.Cataloger) {
149149
Expect(ToCatalogers(packages)).To(Equal(expected))
150150
},
151151

152-
Entry("python-pip maps to python-package-cataloger with spec path only (no lock)",
152+
Entry("python-pip maps to python-installed-package-cataloger with spec path only (no lock)",
153153
[]*config.PackagesDirective{
154154
{
155155
Type: config.PackagesDirectiveTypePythonPip,
156156
FileBased: config.FileBasedSpec{Workdir: "/app", Spec: "requirements.txt", Lock: ""},
157157
},
158158
},
159159
[]scanner.Cataloger{
160-
{Name: "python-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/requirements.txt"}, Workdir: "/app"},
160+
{Name: "python-installed-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/requirements.txt"}, Workdir: "/app"},
161161
},
162162
),
163163

164-
Entry("python-uv maps to python-package-cataloger with spec and lock paths",
164+
Entry("python-uv maps to python-installed-package-cataloger with spec and lock paths",
165165
[]*config.PackagesDirective{
166166
{
167167
Type: config.PackagesDirectiveTypePythonUV,
168168
FileBased: config.FileBasedSpec{Workdir: "/app", Spec: "pyproject.toml", Lock: "uv.lock"},
169169
},
170170
},
171171
[]scanner.Cataloger{
172-
{Name: "python-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/pyproject.toml", "/app/uv.lock"}, Workdir: "/app"},
172+
{Name: "python-installed-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/pyproject.toml", "/app/uv.lock"}, Workdir: "/app"},
173173
},
174174
),
175175

176-
Entry("python-poetry maps to python-package-cataloger with spec and lock paths",
176+
Entry("python-poetry maps to python-installed-package-cataloger with spec and lock paths",
177177
[]*config.PackagesDirective{
178178
{
179179
Type: config.PackagesDirectiveTypePythonPoetry,
180180
FileBased: config.FileBasedSpec{Workdir: "/svc", Spec: "pyproject.toml", Lock: "poetry.lock"},
181181
},
182182
},
183183
[]scanner.Cataloger{
184-
{Name: "python-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/svc/pyproject.toml", "/svc/poetry.lock"}, Workdir: "/svc"},
184+
{Name: "python-installed-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/svc/pyproject.toml", "/svc/poetry.lock"}, Workdir: "/svc"},
185185
},
186186
),
187187
)
@@ -190,7 +190,7 @@ var _ = Describe("ToCatalogers python", func() {
190190
var _ = Describe("FilterBOMBySourcePaths python declared", func() {
191191
distInfoProps := func(workdir, pkgName string, extraPaths ...string) *[]cdx.Property {
192192
props := []cdx.Property{
193-
{Name: "syft:package:foundBy", Value: "python-package-cataloger"},
193+
{Name: "syft:package:foundBy", Value: "python-installed-package-cataloger"},
194194
{Name: "syft:location:0:path", Value: workdir + "/.venv/lib/python3.12/site-packages/" + pkgName + ".dist-info/METADATA"},
195195
}
196196
for i, p := range extraPaths {
@@ -226,7 +226,7 @@ var _ = Describe("FilterBOMBySourcePaths python declared", func() {
226226
},
227227
},
228228
[]scanner.Cataloger{
229-
{Name: "python-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/pyproject.toml", "/app/uv.lock"}, Workdir: "/app"},
229+
{Name: "python-installed-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/pyproject.toml", "/app/uv.lock"}, Workdir: "/app"},
230230
},
231231
[]string{"requests"},
232232
),
@@ -239,7 +239,7 @@ var _ = Describe("FilterBOMBySourcePaths python declared", func() {
239239
},
240240
},
241241
[]scanner.Cataloger{
242-
{Name: "python-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/requirements.txt"}, Workdir: "/app"},
242+
{Name: "python-installed-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/requirements.txt"}, Workdir: "/app"},
243243
},
244244
[]string{"requests"},
245245
),
@@ -252,7 +252,7 @@ var _ = Describe("FilterBOMBySourcePaths python declared", func() {
252252
},
253253
},
254254
[]scanner.Cataloger{
255-
{Name: "python-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/svc/pyproject.toml", "/svc/poetry.lock"}, Workdir: "/svc"},
255+
{Name: "python-installed-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/svc/pyproject.toml", "/svc/poetry.lock"}, Workdir: "/svc"},
256256
},
257257
[]string{"requests"},
258258
),
@@ -265,7 +265,7 @@ var _ = Describe("FilterBOMBySourcePaths python declared", func() {
265265
},
266266
},
267267
[]scanner.Cataloger{
268-
{Name: "python-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/pyproject.toml"}, Workdir: "/app"},
268+
{Name: "python-installed-package-cataloger", FilterMode: scanner.CatalogerFilterWorkdirPrefix, SourcePaths: []string{"/app/pyproject.toml"}, Workdir: "/app"},
269269
},
270270
[]string{"requests"},
271271
),

test/e2e/sbom/_fixtures/inject/pip_simple/werf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ git:
1111
- add: /
1212
to: /app
1313
packages:
14-
- type: pip
14+
- type: python-pip
1515
workdir: /app

0 commit comments

Comments
 (0)