func main()

in cmd/util/vfs-gen/main.go [39:149]


func main() {
	var rootDir string
	var destDir string

	wd, err := os.Getwd()
	if err != nil {
		log.Fatalln(err)
	}

	flag.StringVar(&rootDir, "root", base.GoModDirectory, "The absolute path from were the directories can be found (camel-k module directory by default)")
	flag.StringVar(&destDir, "dest", wd, "The destination directory of the generated file (working directory by default)")
	flag.Parse()

	if len(flag.Args()) < 1 {
		println("usage: vfs-gen [-root <absolute root parent path>] [-dest <directory>] directory1 [directory2 ... ...]")
		os.Exit(1)
	}

	err = checkDir(rootDir)
	if err != nil {
		log.Fatalln(err)
	}

	dirNames := flag.Args()
	for _, dirName := range dirNames {
		absDir := filepath.Join(rootDir, dirName)
		err := checkDir(absDir)
		if err != nil {
			log.Fatalln(err)
		}
	}

	exclusions := calcExclusions(rootDir, dirNames)

	//
	// Destination file for the generated resources
	//
	resourceFile := path.Join(destDir, "resources.go")

	mfs, err := multifs.New(rootDir, dirNames, exclusions)
	if err != nil {
		log.Fatalln(err)
	}

	var fs http.FileSystem = modTimeFS{
		fs: mfs,
	}

	//
	// Filter un-interesting files
	//
	fs = filter.Skip(fs, filter.FilesWithExtensions(".go"))
	fs = filter.Skip(fs, func(path string, fi os.FileInfo) bool {
		return strings.HasSuffix(path, ".gen.yaml") || strings.HasSuffix(path, ".gen.json")
	})
	fs = filter.Skip(fs, NamedFilesFilter("kustomization.yaml"))
	fs = filter.Skip(fs, NamedFilesFilter("Makefile"))
	fs = filter.Skip(fs, NamedFilesFilter("auto-generated.txt"))
	fs = filter.Skip(fs, BigFilesFilter(1048576)) // 1M
	fs = filter.Skip(fs, func(path string, fi os.FileInfo) bool {
		for _, ex := range exclusions {
			if strings.HasPrefix(path, ex) {
				return true
			}
		}
		return false
	})

	//
	// Generate the assets
	//
	err = vfsgen.Generate(fs, vfsgen.Options{
		Filename:    resourceFile,
		PackageName: filepath.Base(destDir),
	})
	if err != nil {
		log.Fatalln(err)
	}

	//
	// Post-process the final resource file
	//
	header := `/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

`
	content, err := util.ReadFile(resourceFile)
	if err != nil {
		log.Fatalln(err)
	}
	var finalContent []byte
	finalContent = append(finalContent, []byte(header)...)
	finalContent = append(finalContent, content...)
	if err := os.WriteFile(resourceFile, finalContent, 0o600); err != nil {
		log.Fatalln(err)
	}
}