func processAuthConfigs()

in internal/cmd/integrations/apply.go [235:272]


func processAuthConfigs(authconfigFolder string) (err error) {
	var stat fs.FileInfo
	rJSONFiles := regexp.MustCompile(`(\S*)\.json`)

	if stat, err = os.Stat(authconfigFolder); err == nil && stat.IsDir() {
		// create any authconfigs
		err = filepath.Walk(authconfigFolder, func(path string, info os.FileInfo, err error) error {
			if err != nil {
				return err
			}
			if !info.IsDir() {
				authConfigFile := filepath.Base(path)
				if rJSONFiles.MatchString(authConfigFile) {
					clilog.Info.Printf("Found configuration for authconfig: %s\n", authConfigFile)
					version, _ := authconfigs.Find(getFilenameWithoutExtension(authConfigFile), "")
					// create the authconfig only if the version was not found
					if version == "" {
						authConfigBytes, err := utils.ReadFile(path)
						if err != nil {
							return err
						}
						clilog.Info.Printf("Creating authconfig: %s\n", authConfigFile)
						if _, err = authconfigs.Create(authConfigBytes); err != nil {
							return err
						}
					} else {
						clilog.Info.Printf("Authconfig %s already exists\n", authConfigFile)
					}
				}
			}
			return nil
		})
		if err != nil {
			return err
		}
	}
	return nil
}