nginxinc/nginx-go-crossplane

False positive cyclic detection for some configurations

CodeMonkeyF5 opened this issue · 1 comments

Is your feature request related to a problem? Please describe

Unable to use XP to parse partial files from existing NGINX configurations due to cyclical check failing. Need to be able to parse file by file (not entirety of config). Cannot bypass the "configs contain include cycle" error returned even when the config is valid.

Describe the solution you'd like

Fix the logic for isAcyclic function to only check the current file being parsed (ignore others).

Describe alternatives you've considered

Creating a custom lib that utilizes the exported nginx-go-crossplane structs with it's own Parse function with new option to perform acyclic check only for the target file being parsed.

Additional context

Resolved issue by setting the parse open to get the files from in-memory (not disk).

    args.Open = func(path string) (io.Reader, error) {
		if config, found := myFileMap[path]; found {
			return strings.NewReader(config), nil
		}

        return os.Open(path)
    }