mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Merge pull request #457 from Liujingfang1/split
split k8sdeps package into sub packages
This commit is contained in:
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package k8sdeps
|
package kunstruct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package k8sdeps
|
package kunstruct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -14,7 +14,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package k8sdeps
|
// Package kunstruct provides unstructured from api machinery and factory for creating unstructured
|
||||||
|
package kunstruct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package k8sdeps
|
package kunstruct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/ifc"
|
"sigs.k8s.io/kustomize/pkg/ifc"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
@@ -29,7 +29,7 @@ import (
|
|||||||
|
|
||||||
func TestNameHashTransformer(t *testing.T) {
|
func TestNameHashTransformer(t *testing.T) {
|
||||||
rf := resource.NewFactory(
|
rf := resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
objs := resmap.ResMap{
|
objs := resmap.ResMap{
|
||||||
resid.NewResId(cmap, "cm1"): rf.FromMap(
|
resid.NewResId(cmap, "cm1"): rf.FromMap(
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
@@ -29,7 +29,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var rf = resource.NewFactory(
|
var rf = resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
|
var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
|
||||||
var foo = gvk.Gvk{Group: "example.com", Version: "v1", Kind: "Foo"}
|
var foo = gvk.Gvk{Group: "example.com", Version: "v1", Kind: "Foo"}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package k8sdeps
|
// Package validator provides functions to validate labels, annotations, namespace using apimachinery
|
||||||
|
package validator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -20,8 +20,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps/transformer"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/transformer"
|
||||||
|
"sigs.k8s.io/kustomize/internal/k8sdeps/validator"
|
||||||
"sigs.k8s.io/kustomize/pkg/commands"
|
"sigs.k8s.io/kustomize/pkg/commands"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,9 +30,9 @@ func main() {
|
|||||||
defer glog.Flush()
|
defer glog.Flush()
|
||||||
|
|
||||||
if err := commands.NewDefaultCommand(
|
if err := commands.NewDefaultCommand(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl(),
|
kunstruct.NewKunstructuredFactoryImpl(),
|
||||||
transformer.NewFactoryImpl(),
|
transformer.NewFactoryImpl(),
|
||||||
k8sdeps.NewKustValidator()).Execute(); err != nil {
|
validator.NewKustValidator()).Execute(); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps/transformer"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/transformer"
|
||||||
"sigs.k8s.io/kustomize/pkg/commands/kustfile"
|
"sigs.k8s.io/kustomize/pkg/commands/kustfile"
|
||||||
"sigs.k8s.io/kustomize/pkg/constants"
|
"sigs.k8s.io/kustomize/pkg/constants"
|
||||||
@@ -131,7 +131,7 @@ func runBuildTestCase(t *testing.T, testcaseName string, updateKustomizeExpected
|
|||||||
buf := bytes.NewBuffer([]byte{})
|
buf := bytes.NewBuffer([]byte{})
|
||||||
err = ops.RunBuild(
|
err = ops.RunBuild(
|
||||||
buf, fSys,
|
buf, fSys,
|
||||||
k8sdeps.NewKunstructuredFactoryImpl(),
|
kunstruct.NewKunstructuredFactoryImpl(),
|
||||||
transformer.NewFactoryImpl())
|
transformer.NewFactoryImpl())
|
||||||
switch {
|
switch {
|
||||||
case err != nil && len(testcase.ExpectedError) == 0:
|
case err != nil && len(testcase.ExpectedError) == 0:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/internal/loadertest"
|
"sigs.k8s.io/kustomize/pkg/internal/loadertest"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
"sigs.k8s.io/kustomize/pkg/patch"
|
||||||
@@ -32,7 +32,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var rf = resource.NewFactory(
|
var rf = resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
|
|
||||||
func TestNewPatchJson6902FactoryNoTarget(t *testing.T) {
|
func TestNewPatchJson6902FactoryNoTarget(t *testing.T) {
|
||||||
p := patch.Json6902{}
|
p := patch.Json6902{}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/evanphx/json-patch"
|
"github.com/evanphx/json-patch"
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
@@ -32,7 +32,7 @@ var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
|
|||||||
|
|
||||||
func TestJsonPatchJSONTransformer_Transform(t *testing.T) {
|
func TestJsonPatchJSONTransformer_Transform(t *testing.T) {
|
||||||
rf := resource.NewFactory(
|
rf := resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
id := resid.NewResId(deploy, "deploy1")
|
id := resid.NewResId(deploy, "deploy1")
|
||||||
base := resmap.ResMap{
|
base := resmap.ResMap{
|
||||||
id: rf.FromMap(
|
id: rf.FromMap(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/ifc"
|
"sigs.k8s.io/kustomize/pkg/ifc"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
@@ -30,7 +30,7 @@ import (
|
|||||||
var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
|
var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
|
||||||
var statefulset = gvk.Gvk{Group: "apps", Version: "v1", Kind: "StatefulSet"}
|
var statefulset = gvk.Gvk{Group: "apps", Version: "v1", Kind: "StatefulSet"}
|
||||||
var rf = resource.NewFactory(
|
var rf = resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
var rmF = NewFactory(rf)
|
var rmF = NewFactory(rf)
|
||||||
|
|
||||||
func TestEncodeAsYaml(t *testing.T) {
|
func TestEncodeAsYaml(t *testing.T) {
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ package resource
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
)
|
)
|
||||||
|
|
||||||
var factory = NewFactory(
|
var factory = NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
|
|
||||||
var testConfigMap = factory.FromMap(
|
var testConfigMap = factory.FromMap(
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps/transformer"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/transformer"
|
||||||
"sigs.k8s.io/kustomize/pkg/constants"
|
"sigs.k8s.io/kustomize/pkg/constants"
|
||||||
"sigs.k8s.io/kustomize/pkg/fs"
|
"sigs.k8s.io/kustomize/pkg/fs"
|
||||||
@@ -89,7 +89,7 @@ metadata:
|
|||||||
)
|
)
|
||||||
|
|
||||||
var rf = resmap.NewFactory(resource.NewFactory(
|
var rf = resmap.NewFactory(resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl()))
|
kunstruct.NewKunstructuredFactoryImpl()))
|
||||||
|
|
||||||
func makeKustTarget(t *testing.T, l ifc.Loader) *KustTarget {
|
func makeKustTarget(t *testing.T, l ifc.Loader) *KustTarget {
|
||||||
fakeFs := fs.MakeFakeFS()
|
fakeFs := fs.MakeFakeFS()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
@@ -30,7 +30,7 @@ import (
|
|||||||
|
|
||||||
func TestImageTagTransformer(t *testing.T) {
|
func TestImageTagTransformer(t *testing.T) {
|
||||||
var rf = resource.NewFactory(
|
var rf = resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
|
|
||||||
m := resmap.ResMap{
|
m := resmap.ResMap{
|
||||||
resid.NewResId(deploy, "deploy1"): rf.FromMap(
|
resid.NewResId(deploy, "deploy1"): rf.FromMap(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
@@ -41,7 +41,7 @@ var pvc = gvk.Gvk{Version: "v1", Kind: "PersistentVolumeClaim"}
|
|||||||
var crb = gvk.Gvk{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRoleBinding"}
|
var crb = gvk.Gvk{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRoleBinding"}
|
||||||
var sa = gvk.Gvk{Version: "v1", Kind: "ServiceAccount"}
|
var sa = gvk.Gvk{Version: "v1", Kind: "ServiceAccount"}
|
||||||
var ingress = gvk.Gvk{Kind: "Ingress"}
|
var ingress = gvk.Gvk{Kind: "Ingress"}
|
||||||
var rf = resource.NewFactory(k8sdeps.NewKunstructuredFactoryImpl())
|
var rf = resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())
|
||||||
var defaultTransformerConfig = config.NewFactory(nil).DefaultConfig()
|
var defaultTransformerConfig = config.NewFactory(nil).DefaultConfig()
|
||||||
|
|
||||||
func TestLabelsRun(t *testing.T) {
|
func TestLabelsRun(t *testing.T) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
"sigs.k8s.io/kustomize/pkg/resource"
|
"sigs.k8s.io/kustomize/pkg/resource"
|
||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
func TestNameReferenceRun(t *testing.T) {
|
func TestNameReferenceRun(t *testing.T) {
|
||||||
rf := resource.NewFactory(
|
rf := resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
m := resmap.ResMap{
|
m := resmap.ResMap{
|
||||||
resid.NewResId(cmap, "cm1"): rf.FromMap(
|
resid.NewResId(cmap, "cm1"): rf.FromMap(
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
"sigs.k8s.io/kustomize/pkg/resource"
|
"sigs.k8s.io/kustomize/pkg/resource"
|
||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
func TestNamespaceRun(t *testing.T) {
|
func TestNamespaceRun(t *testing.T) {
|
||||||
rf := resource.NewFactory(
|
rf := resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
m := resmap.ResMap{
|
m := resmap.ResMap{
|
||||||
resid.NewResId(cmap, "cm1"): rf.FromMap(
|
resid.NewResId(cmap, "cm1"): rf.FromMap(
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/k8sdeps"
|
"sigs.k8s.io/kustomize/internal/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
"sigs.k8s.io/kustomize/pkg/resource"
|
"sigs.k8s.io/kustomize/pkg/resource"
|
||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
func TestPrefixNameRun(t *testing.T) {
|
func TestPrefixNameRun(t *testing.T) {
|
||||||
rf := resource.NewFactory(
|
rf := resource.NewFactory(
|
||||||
k8sdeps.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
m := resmap.ResMap{
|
m := resmap.ResMap{
|
||||||
resid.NewResId(cmap, "cm1"): rf.FromMap(
|
resid.NewResId(cmap, "cm1"): rf.FromMap(
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|||||||
Reference in New Issue
Block a user