From 2e0e43cd768de47f762aa8350a27c12483444fc1 Mon Sep 17 00:00:00 2001 From: Jeffrey Regan Date: Wed, 6 Jun 2018 11:00:57 -0700 Subject: [PATCH] Improve package doc. --- pkg/app/application.go | 2 ++ pkg/app/application_test.go | 2 +- pkg/commands/commands.go | 1 + pkg/configmapandsecret/configmap_secret.go | 1 + pkg/configmapandsecret/util/util.go | 1 + pkg/diff/doc.go | 2 -- pkg/diff/rundiff.go | 17 +++++++++++++++++ pkg/fs/fs.go | 1 + pkg/hash/hash.go | 1 + .../loadertest/fakeloader.go | 1 + pkg/loader/loader.go | 1 + pkg/resmap/configmap_test.go | 2 +- pkg/resmap/resmap.go | 19 ++++++++++++++++++- pkg/resmap/resmap_test.go | 2 +- pkg/resource/resource.go | 1 + pkg/transformers/transformer.go | 5 +++-- pkg/types/kustomization.go | 1 + 17 files changed, 52 insertions(+), 8 deletions(-) delete mode 100644 pkg/diff/doc.go rename pkg/{loader => internal}/loadertest/fakeloader.go (97%) diff --git a/pkg/app/application.go b/pkg/app/application.go index 464a37bc6..d16e9be13 100644 --- a/pkg/app/application.go +++ b/pkg/app/application.go @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package app implements state for the set of all resources being customized. +// Should rename this - there's nothing "app"y about it. package app import ( diff --git a/pkg/app/application_test.go b/pkg/app/application_test.go index 75745fed5..6ad41b36d 100644 --- a/pkg/app/application_test.go +++ b/pkg/app/application_test.go @@ -22,8 +22,8 @@ import ( "testing" "github.com/kubernetes-sigs/kustomize/pkg/constants" + "github.com/kubernetes-sigs/kustomize/pkg/internal/loadertest" "github.com/kubernetes-sigs/kustomize/pkg/loader" - "github.com/kubernetes-sigs/kustomize/pkg/loader/loadertest" "github.com/kubernetes-sigs/kustomize/pkg/resmap" "github.com/kubernetes-sigs/kustomize/pkg/resource" corev1 "k8s.io/api/core/v1" diff --git a/pkg/commands/commands.go b/pkg/commands/commands.go index 70f93e9f8..ad980bf8e 100644 --- a/pkg/commands/commands.go +++ b/pkg/commands/commands.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package commands holds the CLI glue mapping textual commands/args to method calls. package commands import ( diff --git a/pkg/configmapandsecret/configmap_secret.go b/pkg/configmapandsecret/configmap_secret.go index aa0fa5e61..a010ca07b 100644 --- a/pkg/configmapandsecret/configmap_secret.go +++ b/pkg/configmapandsecret/configmap_secret.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package configmapandsecret generates configmaps and secrets per generator rules. package configmapandsecret import ( diff --git a/pkg/configmapandsecret/util/util.go b/pkg/configmapandsecret/util/util.go index fd1bf1364..dbff43c49 100644 --- a/pkg/configmapandsecret/util/util.go +++ b/pkg/configmapandsecret/util/util.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package util offers Configmap and Secret generation utilities. package util import ( diff --git a/pkg/diff/doc.go b/pkg/diff/doc.go deleted file mode 100644 index 5921c481b..000000000 --- a/pkg/diff/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package diff runs system diff to compare resource collections -package diff diff --git a/pkg/diff/rundiff.go b/pkg/diff/rundiff.go index 4d36312a6..5918ea35c 100644 --- a/pkg/diff/rundiff.go +++ b/pkg/diff/rundiff.go @@ -1,3 +1,20 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package diff runs system `diff` to compare resource collections. package diff import ( diff --git a/pkg/fs/fs.go b/pkg/fs/fs.go index 2d6aedf5a..788ea68ff 100644 --- a/pkg/fs/fs.go +++ b/pkg/fs/fs.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package fs provides a file system abstraction layer. package fs import ( diff --git a/pkg/hash/hash.go b/pkg/hash/hash.go index de0036245..bdd277bd2 100644 --- a/pkg/hash/hash.go +++ b/pkg/hash/hash.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package hash generates hash strings from configmaps and secrets. package hash import ( diff --git a/pkg/loader/loadertest/fakeloader.go b/pkg/internal/loadertest/fakeloader.go similarity index 97% rename from pkg/loader/loadertest/fakeloader.go rename to pkg/internal/loadertest/fakeloader.go index c3125dc13..7cc48f2c0 100644 --- a/pkg/loader/loadertest/fakeloader.go +++ b/pkg/internal/loadertest/fakeloader.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package loadertest holds a fake for the Loader interface. package loadertest import ( diff --git a/pkg/loader/loader.go b/pkg/loader/loader.go index 5b0c59d59..6fc5fa95e 100644 --- a/pkg/loader/loader.go +++ b/pkg/loader/loader.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package loader has a data loading interface and various implementations. package loader import "fmt" diff --git a/pkg/resmap/configmap_test.go b/pkg/resmap/configmap_test.go index ea10010d8..e5e0aef3a 100644 --- a/pkg/resmap/configmap_test.go +++ b/pkg/resmap/configmap_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - "github.com/kubernetes-sigs/kustomize/pkg/loader/loadertest" + "github.com/kubernetes-sigs/kustomize/pkg/internal/loadertest" "github.com/kubernetes-sigs/kustomize/pkg/resource" "github.com/kubernetes-sigs/kustomize/pkg/types" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/resmap/resmap.go b/pkg/resmap/resmap.go index 6d47f5ce1..f62809786 100644 --- a/pkg/resmap/resmap.go +++ b/pkg/resmap/resmap.go @@ -1,3 +1,20 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package resmap implements a map from ResId to Resource that tracks all resources in a kustomization. package resmap import ( @@ -17,7 +34,7 @@ import ( k8syaml "k8s.io/apimachinery/pkg/util/yaml" ) -// ResMap is a map from ResId to Resource +// ResMap is a map from ResId to Resource. type ResMap map[resource.ResId]*resource.Resource // EncodeAsYaml encodes a ResMap to YAML; encoded objects separated by `---`. diff --git a/pkg/resmap/resmap_test.go b/pkg/resmap/resmap_test.go index b76f0e89d..bd2741d46 100644 --- a/pkg/resmap/resmap_test.go +++ b/pkg/resmap/resmap_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - "github.com/kubernetes-sigs/kustomize/pkg/loader/loadertest" + "github.com/kubernetes-sigs/kustomize/pkg/internal/loadertest" "github.com/kubernetes-sigs/kustomize/pkg/resource" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/resource/resource.go b/pkg/resource/resource.go index f129f711b..bf00a630f 100644 --- a/pkg/resource/resource.go +++ b/pkg/resource/resource.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package resource implements representations of k8s API resources as "unstructured" objects. package resource import ( diff --git a/pkg/transformers/transformer.go b/pkg/transformers/transformer.go index 6dbfe406b..aad9406d8 100644 --- a/pkg/transformers/transformer.go +++ b/pkg/transformers/transformer.go @@ -14,12 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package transformers has implementations of resmap.ResMap transformers. package transformers import "github.com/kubernetes-sigs/kustomize/pkg/resmap" -// Transformer can transform objects. +// A Transformer modifies an instance of resmap.ResMap. type Transformer interface { - // Transform modifies objects in a map, e.g. add prefixes or additional labels. + // Transform modifies data in the argument, e.g. adding labels to resources that can be labelled. Transform(m resmap.ResMap) error } diff --git a/pkg/types/kustomization.go b/pkg/types/kustomization.go index f389ee09a..d5b9f0707 100644 --- a/pkg/types/kustomization.go +++ b/pkg/types/kustomization.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package types holds struct definitions that should find a better home. package types // Kustomization holds the information needed to generate customized k8s api resources.