Comment unused function that depends on k8s.io/kubernetes

This commit is contained in:
Antoine Pelisse 2017-11-13 14:13:09 -08:00
parent 4312d1e34a
commit b4f3d605ca
1 changed files with 39 additions and 42 deletions

View File

@ -17,62 +17,59 @@ limitations under the License.
package manifest package manifest
import ( import (
"errors"
"io/ioutil" "io/ioutil"
"path"
yaml "gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
manifest "k8s.io/kubectl/pkg/apis/manifest/v1alpha1" manifest "k8s.io/kubectl/pkg/apis/manifest/v1alpha1"
"k8s.io/kubernetes/pkg/kubectl/resource"
) )
const kubeManifestFileName = "Kube-manifest.yaml" const kubeManifestFileName = "Kube-manifest.yaml"
// loadBaseAndOverlayPkg returns: // // loadBaseAndOverlayPkg returns:
// - List of FilenameOptions, each FilenameOptions contains all the files and whether recursive for each base defined in overlay kube-manifest.yaml. // // - List of FilenameOptions, each FilenameOptions contains all the files and whether recursive for each base defined in overlay kube-manifest.yaml.
// - Fileoptions for overlay. // // - Fileoptions for overlay.
// - Package object for overlay. // // - Package object for overlay.
// - A potential error. // // - A potential error.
func loadBaseAndOverlayPkg(f string) ([]resource.FilenameOptions, resource.FilenameOptions, *manifest.Manifest, error) { // func loadBaseAndOverlayPkg(f string) ([]resource.FilenameOptions, resource.FilenameOptions, *manifest.Manifest, error) {
overlay, err := loadManifestPkg(path.Join(f, kubeManifestFileName)) // overlay, err := loadManifestPkg(path.Join(f, kubeManifestFileName))
if err != nil { // if err != nil {
return nil, resource.FilenameOptions{}, nil, err // return nil, resource.FilenameOptions{}, nil, err
} // }
overlayFileOptions := resource.FilenameOptions{ // overlayFileOptions := resource.FilenameOptions{
// TODO: support `recursive` when we figure out what its behavior should be. // // TODO: support `recursive` when we figure out what its behavior should be.
// Recursive: overlay.Recursive // // Recursive: overlay.Recursive
} // }
for _, o := range overlay.Patches { // for _, o := range overlay.Patches {
overlayFileOptions.Filenames = append(overlayFileOptions.Filenames, path.Join(f, o)) // overlayFileOptions.Filenames = append(overlayFileOptions.Filenames, path.Join(f, o))
} // }
if len(overlay.Resources) == 0 { // if len(overlay.Resources) == 0 {
return nil, resource.FilenameOptions{}, nil, errors.New("expect at least one base, but got 0") // return nil, resource.FilenameOptions{}, nil, errors.New("expect at least one base, but got 0")
} // }
var baseFileOptionsList []resource.FilenameOptions // var baseFileOptionsList []resource.FilenameOptions
for _, base := range overlay.Resources { // for _, base := range overlay.Resources {
var baseFilenames []string // var baseFilenames []string
baseManifest, err := loadManifestPkg(path.Join(f, base, kubeManifestFileName)) // baseManifest, err := loadManifestPkg(path.Join(f, base, kubeManifestFileName))
if err != nil { // if err != nil {
return nil, resource.FilenameOptions{}, nil, err // return nil, resource.FilenameOptions{}, nil, err
} // }
for _, filename := range baseManifest.Resources { // for _, filename := range baseManifest.Resources {
baseFilenames = append(baseFilenames, path.Join(f, base, filename)) // baseFilenames = append(baseFilenames, path.Join(f, base, filename))
} // }
baseFileOptions := resource.FilenameOptions{ // baseFileOptions := resource.FilenameOptions{
Filenames: baseFilenames, // Filenames: baseFilenames,
// TODO: support `recursive` when we figure out what its behavior should be. // // TODO: support `recursive` when we figure out what its behavior should be.
// Recursive: baseManifest.Recursive, // // Recursive: baseManifest.Recursive,
} // }
baseFileOptionsList = append(baseFileOptionsList, baseFileOptions) // baseFileOptionsList = append(baseFileOptionsList, baseFileOptions)
} // }
return baseFileOptionsList, overlayFileOptions, overlay, nil // return baseFileOptionsList, overlayFileOptions, overlay, nil
} // }
// loadManifestPkg loads a manifest file and parse it in to the Package object. // loadManifestPkg loads a manifest file and parse it in to the Package object.
func loadManifestPkg(filename string) (*manifest.Manifest, error) { func loadManifestPkg(filename string) (*manifest.Manifest, error) {