// GetMissingResources returns a collection of resources that exist in the directory
// but are not defined in the given kustomization file
GetMissingResources returns a collection of resources that exist in the directory
but are not defined in the given kustomization file
// GetMissingResources returns a collection of resources that exist in the directory // but are not defined in the given kustomization file
func (k *kustomizationFileContext) GetMissingResources(directoryPath string, kustomizationFile *KustomizationFile) ([]string, error) {
	definedResources := []string{}
	definedResources = append(definedResources, kustomizationFile.Resources...)
	definedResources = append(definedResources, kustomizationFile.Patches...)
	definedResources = append(definedResources, kustomizationFile.PatchesStrategicMerge...)
	fileUtility := &afero.Afero{Fs: k.fileSystem}
	directoryInfo, err := fileUtility.ReadDir(directoryPath)
	if err != nil {
		return nil, errors.Wrapf(err, "Could not read directory %s", directoryPath)
	}
	missingResources := []string{}
	for _, info := range directoryInfo {
		if info.IsDir() {
			continue
		}
		if filepath.Ext(info.Name()) != ".yaml" {
			continue
		}
		if existsInSlice(KustomizationFileNames, info.Name()) {
			continue
		}
		if !existsInSlice(definedResources, info.Name()) {
			missingResources = append(missingResources, info.Name())
		}
	}
	return missingResources, nil
}
func ( k * kustomizationFileContext ) GetMissingResources ( directoryPath string , kustomizationFile * KustomizationFile ) ( [ ] string , error ) { definedResources := [ ] string { } definedResources = append ( definedResources , kustomizationFile . Resources ... ) definedResources = append ( definedResources , kustomizationFile . Patches ... ) definedResources = append ( definedResources , kustomizationFile . PatchesStrategicMerge ... ) fileUtility := & afero . Afero { Fs : k . fileSystem } directoryInfo , err := fileUtility . ReadDir ( directoryPath ) if err != nil { return nil , errors . Wrapf ( err , " " , directoryPath ) } missingResources := [ ] string { } for _ , info := range directoryInfo { if info . IsDir ( ) { continue } if filepath . Ext ( info . Name ( ) ) != " " { continue } if existsInSlice ( KustomizationFileNames , info . Name ( ) ) { continue } if ! existsInSlice ( definedResources , info . Name ( ) ) { missingResources = append ( missingResources , info . Name ( ) ) } } return missingResources , nil }
GetMissingResources returns a collection of resources that exist in the directory
but are not defined in the given kustomization file
GetMissingResources returns a collection of resources that exist in the directory but are not defined in the given kustomization file
// Only consider the resource missing if it is a yaml file // Ignore the kustomization files