Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: jlumbroso/free-disk-space@v1.3.1

- uses: actions/checkout@v6

- name: setup Go
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.1.0"
".": "1.0.0"
}
38 changes: 0 additions & 38 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,39 +1 @@
# Changelog

## [1.0.2](https://github.com/devsy-org/apiserver/compare/v1.0.1...v1.0.2) (2026-04-12)


### Bug Fixes

* export shell variables to resolve shellcheck SC2034 warnings ([#12](https://github.com/devsy-org/apiserver/issues/12)) ([7e0ae3e](https://github.com/devsy-org/apiserver/commit/7e0ae3e6220065484433e3578328c8aa577ecf93))

## [1.0.1](https://github.com/devsy-org/apiserver/compare/v1.0.0...v1.0.1) (2026-04-12)


### Bug Fixes

* move exclude-dirs to linters.exclusions.paths for golangci-lint v2 ([#10](https://github.com/devsy-org/apiserver/issues/10)) ([5539adf](https://github.com/devsy-org/apiserver/commit/5539adf2f95d4e6e3dea41a7ee6b600e44cf96a4))

## 1.0.0 (2026-04-12)


### Features

* add group converter ([28c307a](https://github.com/devsy-org/apiserver/commit/28c307acd2deeb75f18b1142119698e0589fe178))
* add status rest generator ([a087db8](https://github.com/devsy-org/apiserver/commit/a087db850f7feeb85b15134b4874f2c41d11a47b))
* add status rest generator ([07b679f](https://github.com/devsy-org/apiserver/commit/07b679fb7d0ec741c203eeeb44cf8de0989ee3dc))


### Bug Fixes

* add tags for unversioned apis ([a106e2f](https://github.com/devsy-org/apiserver/commit/a106e2f2e0f1f9392dc8c4a873a9e3c37ecf74f7))
* add tags for unversioned apis ([acc9f39](https://github.com/devsy-org/apiserver/commit/acc9f397b07e4b7da29d467d24095d425cbf8420))
* breaking changes after version bump ([5f191d3](https://github.com/devsy-org/apiserver/commit/5f191d3077814787694d7cf317ed3d09df5b5a09))
* bump k8s version to 1.31 ([56b9af3](https://github.com/devsy-org/apiserver/commit/56b9af3c14844c35e1ec7a7344ef8dbd0e4b58e1))
* disable validatingadmissionpolicy plugin ([79262a1](https://github.com/devsy-org/apiserver/commit/79262a153ae84a37ee7b5d93c1aa152db28e9c0b))
* disable validatingadmissionpolicy plugin via config not feature flag ([f17d504](https://github.com/devsy-org/apiserver/commit/f17d504a4d0da95e503189e4e039fcbab214e325))
* force JSON serialization ([619975b](https://github.com/devsy-org/apiserver/commit/619975b667ebdaa1dd558dd7e399deb3dd2215e2))
* new tracerprovider required by admissionConfig ([cac25ae](https://github.com/devsy-org/apiserver/commit/cac25ae971c3929d2af969dbd1db8927ad646bfc))
* properly init config ([395e1e5](https://github.com/devsy-org/apiserver/commit/395e1e5c9eac0136182bf884d1a143f6fa4349e5))
* resolve pre-commit trailing whitespace, EOF, and formatting issues ([#8](https://github.com/devsy-org/apiserver/issues/8)) ([1b18f03](https://github.com/devsy-org/apiserver/commit/1b18f038ccb8c408654d9941f8631ac809f19b61))
* wrong done channel ([#26](https://github.com/devsy-org/apiserver/issues/26)) ([2a1d356](https://github.com/devsy-org/apiserver/commit/2a1d356b8c09f87fdc5ca0b746e2390c7ba72547))
68 changes: 41 additions & 27 deletions pkg/generate/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type APIGroup struct {
Aliases map[string]*Alias
Pkg *types.Package
PkgPath string

// importAliases tracks import alias → package path to detect and resolve collisions.
importAliases map[string]string
}

type Struct struct {
Expand Down Expand Up @@ -191,6 +194,7 @@ func (b *APIsBuilder) ParseAPIs() {
Versions: map[string]*APIVersion{},
UnversionedResources: map[string]*APIResource{},
Aliases: map[string]*Alias{},
importAliases: map[string]string{},
}

for version, kindMap := range versionMap {
Expand Down Expand Up @@ -639,11 +643,7 @@ func (apigroup *APIGroup) DoType(t *types.Type) (*Struct, []*types.Type) {
if strings.HasPrefix(mSubType.Name.Package, "k8s.io/api/") {
// Import the package under an alias so it doesn't conflict with other groups
// having the same version
importAlias := path.Base(
path.Dir(mSubType.Name.Package),
) + path.Base(
mSubType.Name.Package,
)
importAlias := apigroup.resolveImportAlias(mSubType.Name.Package)
uImport = fmt.Sprintf("%s \"%s\"", importAlias, mSubType.Name.Package)
if hasElem {
// Replace the full package with the alias when referring to the type
Expand Down Expand Up @@ -683,42 +683,22 @@ func (apigroup *APIGroup) DoType(t *types.Type) (*Struct, []*types.Type) {
name := str[endPkg+1:]
prefix := str[:startPkg+1]

uImportBase := path.Base(pkg)
uImportName := path.Base(path.Dir(pkg)) + uImportBase
uImportName := apigroup.resolveImportAlias(pkg)
uImport = fmt.Sprintf("%s \"%s\"", uImportName, pkg)

uType = prefix + uImportName + "." + name

// fmt.Printf("\nDifferent Parent Package: %s\nChild Package: %s\nKind: %s (Kind.String() %s)\nImport stmt: %s\nType: %s\n\n",
// pkg,
// member.Type.Name.Package,
// member.Type.Kind,
// member.Type.String(),
// uImport,
// uType)
} else {
// Handle non- Pointer, Maps, Slices
pkg := t.Name.Package
name := t.Name.Name

// Come up with the alias the package is imported under
// Concatenate with directory package to reduce naming collisions
uImportBase := path.Base(pkg)
uImportName := path.Base(path.Dir(pkg)) + uImportBase
uImportName := apigroup.resolveImportAlias(pkg)

// Create the import statement
uImport = fmt.Sprintf("%s \"%s\"", uImportName, pkg)

// Create the field type name - should be <pkgalias>.<TypeName>
uType = uImportName + "." + name

// fmt.Printf("\nDifferent Parent Package: %s\nChild Package: %s\nKind: %s (Kind.String() %s)\nImport stmt: %s\nType: %s\n\n",
// pkg,
// member.Type.Name.Package,
// member.Type.Kind,
// member.Type.String(),
// uImport,
// uType)
}
}
}
Expand Down Expand Up @@ -758,3 +738,37 @@ func (apigroup *APIGroup) DoType(t *types.Type) (*Struct, []*types.Type) {
}
return s, remaining
}

// resolveImportAlias returns a unique import alias for the given package path.
// The base alias is formed from the last two path segments (e.g. "storage/v1" → "storagev1").
// If that alias is already used by a different package, the module name (third path segment)
// is prepended to disambiguate (e.g. "agentstoragev1").
func (g *APIGroup) resolveImportAlias(pkgPath string) string {
base := path.Base(path.Dir(pkgPath)) + path.Base(pkgPath)

if existing, ok := g.importAliases[base]; ok && existing == pkgPath {
return base
}

if _, ok := g.importAliases[base]; !ok {
g.importAliases[base] = pkgPath
return base
}

// Collision: disambiguate using the module name (third segment of the import path).
parts := strings.Split(pkgPath, "/")
moduleName := ""
if len(parts) >= 3 {
moduleName = parts[2]
}
prefix := strings.ReplaceAll(moduleName, "-", "")
prefix = strings.TrimSuffix(prefix, "apis")
prefix = strings.TrimSuffix(prefix, "api")
if prefix == "" || prefix == base {
prefix = strings.ReplaceAll(moduleName, "-", "")
}

alias := prefix + base
g.importAliases[alias] = pkgPath
return alias
}
7 changes: 4 additions & 3 deletions pkg/generate/unversioned_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ var UnversionedAPIImports = []string{
"k8s.io/apiserver/pkg/registry/generic",
"k8s.io/apiserver/pkg/registry/rest",
"github.com/devsy-org/apiserver/pkg/builders",
"github.com/devsy-org/apiserver/pkg/managerfactory",
}

var UnversionedAPITemplate = `
type NewRESTFunc func() rest.Storage
type NewRESTFunc func(factory managerfactory.SharedManagerFactory) rest.Storage
Comment on lines +63 to +67

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find the managerfactory package and confirm SharedManagerFactory is defined & exported.
fd -t d managerfactory
rg -nP -C2 '\btype\s+SharedManagerFactory\b'
rg -nP -C1 '\bSharedManagerFactory\b' -g '!**/generate/**'

Repository: devsy-org/apiserver

Length of output: 45


🏁 Script executed:

# Search for any files/directories with "manager" in the name
fd -i manager

# Try simpler grep patterns for SharedManagerFactory
rg 'SharedManagerFactory' -i

# Check if there are any Go files in pkg directory
fd -t f '\.go$' pkg/

# Look for factory-related files
fd -i factory

Repository: devsy-org/apiserver

Length of output: 816


🏁 Script executed:

# Read the unversioned_generator.go file with line numbers
cat -n pkg/generate/unversioned_generator.go | head -100

# Check imports in that file
rg -n 'import|managerfactory' pkg/generate/unversioned_generator.go -A 5 -B 5

Repository: devsy-org/apiserver

Length of output: 5112


🏁 Script executed:

# List all directories under pkg
ls -la pkg/

# Search for any mention of managerfactory in comments or other contexts
rg 'managerfactory' -i

# Check if Factory variable is defined anywhere
rg '\bFactory\b' -t go

Repository: devsy-org/apiserver

Length of output: 921


Missing managerfactory package and SharedManagerFactory type will cause compilation failures in all generated packages.

The generated code imports a non-existent package (github.com/devsy-org/apiserver/pkg/managerfactory) and references an undefined type (SharedManagerFactory). The template also references an undefined Factory variable. Every generated unversioned API package will fail to compile until the managerfactory package is created with the SharedManagerFactory type, and the Factory variable is provided in the generated package scope.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/generate/unversioned_generator.go` around lines 63 - 67, The
UnversionedAPITemplate references a non-existent import and symbols: update the
generator so the template either imports a real package or remove the bogus
import and types; specifically ensure that the managerfactory package and the
SharedManagerFactory type exist (or change NewRESTFunc to use the correct
existing factory type) and that the generated package defines the Factory
variable before any generated code uses it. Locate UnversionedAPITemplate and
the NewRESTFunc signature, then either create
github.com/devsy-org/apiserver/pkg/managerfactory with type SharedManagerFactory
and expose it, or change the template to reference the actual factory type and
add a generated top-level Factory variable in the output package so compilation
succeeds.


var (
{{ range $api := .UnversionedResources -}}
Expand All @@ -75,12 +76,12 @@ var (
New{{ $api.REST }},
)
New{{ $api.REST }} = func(getter generic.RESTOptionsGetter) rest.Storage {
return New{{ $api.REST }}Func()
return New{{ $api.REST }}Func(Factory)
}
New{{ $api.REST }}Func NewRESTFunc
{{ if $api.StatusREST -}}
New{{ $api.StatusREST }} = func(getter generic.RESTOptionsGetter) rest.Storage {
return New{{ $api.StatusREST }}Func()
return New{{ $api.StatusREST }}Func(Factory)
}
New{{ $api.StatusREST }}Func NewRESTFunc
{{ end -}}
Expand Down
Loading