chore: refactor read scheme to openapi from kubernetes api definition

Previously, only a single embedded Kubernetes API version could be specified, resulting in a lack of support for certain GVKs.
To address this, the goal is to create and utilize a unified scheme that consolidates Kubernetes API definitions.
As a preliminary step, the current method of loading API definitions will be improved.
This commit is contained in:
koba1t
2026-07-17 17:16:44 +09:00
committed by Yugo Kobayashi
parent f7d33c2610
commit 9216c6f573
29 changed files with 1791 additions and 45006 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,43 @@
// Copyright 2026 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package v1_21_2 //nolint:revive // The package name is part of the public API.
import (
"crypto/sha256"
"encoding/hex"
"testing"
"github.com/stretchr/testify/require"
)
func TestAssetCompatibility(t *testing.T) {
b, err := Asset(assetName)
require.NoError(t, err)
digest := sha256.Sum256(b)
require.Equal(t, "5d171b55e9601912807a870d73ffe70bb306f5889a00e76986042a0f2d7b6bc2",
hex.EncodeToString(digest[:]))
info, err := AssetInfo(assetName)
require.NoError(t, err)
require.Equal(t, int64(3469475), info.Size())
require.Equal(t, "swagger.pb", info.Name())
backslashName := "kubernetesapi\\v1_21_2\\swagger.pb"
_, err = Asset(backslashName)
require.NoError(t, err)
children, err := AssetDir("kubernetesapi/v1_21_2")
require.NoError(t, err)
require.Equal(t, []string{"swagger.pb"}, children)
_, err = AssetDir(assetName)
require.Error(t, err)
b[0] ^= 0xff
again := MustAsset(assetName)
require.NotEqual(t, b[0], again[0], "Asset must return a fresh byte slice")
_, err = Asset("missing")
require.Error(t, err)
}
func TestAssetNames(t *testing.T) {
require.Equal(t, []string{assetName}, AssetNames())
}