Skip to content

Commit

Permalink
remove obsolete functions
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Feb 20, 2025
1 parent 84b7d5a commit 8631181
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
41 changes: 0 additions & 41 deletions loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,6 @@ func WithProfiles(profiles []string) func(*Options) {
}
}

// ParseYAML reads the bytes from a file, parses the bytes into a mapping
// structure, and returns it.
func ParseYAML(source []byte) (map[string]interface{}, error) {
r := bytes.NewReader(source)
decoder := yaml.NewDecoder(r)
m, _, err := parseYAML(decoder)
return m, err
}

// PostProcessor is used to tweak compose model based on metadata extracted during yaml Unmarshal phase
// that hardly can be implemented using go-yaml and mapstructure
type PostProcessor interface {
Expand All @@ -275,32 +266,6 @@ type PostProcessor interface {
Apply(interface{}) error
}

func parseYAML(decoder *yaml.Decoder) (map[string]interface{}, PostProcessor, error) {
var cfg interface{}
processor := ResetProcessor{target: &cfg}

if err := decoder.Decode(&processor); err != nil {
return nil, nil, err
}
stringMap, ok := cfg.(map[string]interface{})
if ok {
converted, err := convertToStringKeysRecursive(stringMap, "")
if err != nil {
return nil, nil, err
}
return converted.(map[string]interface{}), &processor, nil
}
cfgMap, ok := cfg.(map[interface{}]interface{})
if !ok {
return nil, nil, errors.New("Top-level object must be a mapping")
}
converted, err := convertToStringKeysRecursive(cfgMap, "")
if err != nil {
return nil, nil, err
}
return converted.(map[string]interface{}), &processor, nil
}

// LoadConfigFiles ingests config files with ResourceLoader and returns config details with paths to local copies
func LoadConfigFiles(ctx context.Context, configFiles []string, workingDir string, options ...func(*Options)) (*types.ConfigDetails, error) {
if len(configFiles) < 1 {
Expand Down Expand Up @@ -353,12 +318,6 @@ func LoadConfigFiles(ctx context.Context, configFiles []string, workingDir strin
return config, nil
}

// Load reads a ConfigDetails and returns a fully loaded configuration.
// Deprecated: use LoadWithContext.
func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types.Project, error) {
return LoadWithContext(context.Background(), configDetails, options...)
}

// LoadWithContext reads a ConfigDetails and returns a fully loaded configuration as a compose-go Project
func LoadWithContext(ctx context.Context, configDetails types.ConfigDetails, options ...func(*Options)) (*types.Project, error) {
opts := toOptions(&configDetails, options)
Expand Down
6 changes: 0 additions & 6 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,6 @@ var sampleConfig = types.Config{
},
}

func TestParseYAML(t *testing.T) {
dict, err := ParseYAML([]byte(sampleYAML))
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(sampleDict, dict))
}

func TestLoad(t *testing.T) {
actual, err := Load(buildConfigDetails(sampleYAML, nil), func(options *Options) {

Check failure on line 265 in loader/loader_test.go

View workflow job for this annotation

GitHub Actions / test (1.21, macos-latest)

undefined: Load
options.SkipNormalization = true
Expand Down

0 comments on commit 8631181

Please sign in to comment.