mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 15:13:08 +00:00
Move Resource functionality to its own package
Create a unified Builder object for working with files, selectors, types, and items that makes it easier to get multi-object functionality. Supports all of the behaviors previously in resource.go, but with additional flexibility to allow multi-type retrieval and access, directories, URLs, nested objects, and lists.
This commit is contained in:
@@ -105,6 +105,7 @@ func FirstNonEmptyString(args ...string) string {
|
||||
}
|
||||
|
||||
// Return a list of file names of a certain type within a given directory.
|
||||
// TODO: replace with resource.Builder
|
||||
func GetFilesFromDir(directory string, fileType string) []string {
|
||||
files := []string{}
|
||||
|
||||
@@ -121,6 +122,7 @@ func GetFilesFromDir(directory string, fileType string) []string {
|
||||
|
||||
// ReadConfigData reads the bytes from the specified filesytem or network
|
||||
// location or from stdin if location == "-".
|
||||
// TODO: replace with resource.Builder
|
||||
func ReadConfigData(location string) ([]byte, error) {
|
||||
if len(location) == 0 {
|
||||
return nil, fmt.Errorf("location given but empty")
|
||||
@@ -144,6 +146,7 @@ func ReadConfigData(location string) ([]byte, error) {
|
||||
return ReadConfigDataFromLocation(location)
|
||||
}
|
||||
|
||||
// TODO: replace with resource.Builder
|
||||
func ReadConfigDataFromLocation(location string) ([]byte, error) {
|
||||
// we look for http:// or https:// to determine if valid URL, otherwise do normal file IO
|
||||
if strings.Index(location, "http://") == 0 || strings.Index(location, "https://") == 0 {
|
||||
|
Reference in New Issue
Block a user