func (a *Analyzer) FindDatabases() (*common.Lister, error) { dbs := common.NewLister() settings, err := ioutil.ReadFile(a.SettingsPy) if err != nil { return nil, err } dbNames := map[string]string{ "mysql": "mysql", // Django built-in "postgresql_psycopg2": "postgresql", // Django built-in "RedisCache": "redis", // https://github.com/niwinz/django-redis or https://github.com/sebleier/django-redis-cache "django_mongodb_engine": "mongodb", // https://github.com/django-nonrel/mongodb-engine "mongodb": "mongodb", // https://github.com/peterbe/django-mongokit } databaseDictionaryPattern := regexp.MustCompile(`(?m)^[[:blank:]]*(?:DATABASES|CACHES)[[:blank:]]*=[[:blank:]]*{(?:.|\n)*?^}`) databasePattern := regexp.MustCompile(`(?m)^[[:blank:]]*['"](?:ENGINE|BACKEND)['"][[:blank:]]*:[[:blank:]]*['"](?:[[:word:]]*\.)*([[:word:]]*)['"]`) for _, dictionary := range databaseDictionaryPattern.FindAllString(string(settings), -1) { for _, match := range databasePattern.FindAllStringSubmatch(dictionary, -1) { pythonDbName := match[1] if pythonDbName == "sqlite3" { continue } db := dbNames[pythonDbName] if db == "" { return nil, fmt.Errorf("Found not supported database backend %s, aborting", pythonDbName) } dbs.Add(db) } } return dbs, nil }
func (a *Analyzer) GuessPackages() *common.Lister { packages := common.NewLister() if runsExpress, _ := common.GetDependencyVersion(a.PackageJSON, "express"); runsExpress { common.PrintlnL2("Found Express") } if hasScript, script := common.GetScriptsStart(a.PackageJSON); hasScript { common.PrintlnL2("Found Script: %s", script) } return packages }
func (a *Analyzer) GuessPackages() *common.Lister { packages := common.NewLister() common.PrintlnL2("Analyzing dependencies") if hasRmagick, _ := common.GetGemVersion(a.Gemfile, "rmagick", "refile-mini_magick", "mini_magick"); hasRmagick { packages.Add("imagemagick", "libmagickwand-dev") common.PrintlnL2("Found Image Magick") } if hasSqlite, _ := common.GetGemVersion(a.Gemfile, "sqlite"); hasSqlite { packages.Add("libsqlite3-dev") common.PrintlnL2("Found sqlite") } if hasMemcache, _ := common.GetGemVersion(a.Gemfile, "dalli"); hasMemcache { packages.Add("memcached") common.PrintlnL2("Found Memcache") } return packages }
func (a *Analyzer) FindDatabases() *common.Lister { dbs := common.NewLister() if hasMysql, _ := common.GetGemVersion(a.Gemfile, "mysql2"); hasMysql { dbs.Add("mysql") } if hasPg, _ := common.GetGemVersion(a.Gemfile, "pg"); hasPg { dbs.Add("postgresql") } if hasRedis, _ := common.GetGemVersion(a.Gemfile, "redis", "redis-rails"); hasRedis { dbs.Add("redis") } if hasMongoDB, _ := common.GetGemVersion(a.Gemfile, "mongo", "mongo_mapper", "dm-mongo-adapter", "mongoid"); hasMongoDB { dbs.Add("mongodb") } if hasElasticsearch, _ := common.GetGemVersion(a.Gemfile, "elasticsearch", "tire", "flex", "chewy"); hasElasticsearch { dbs.Add("elasticsearch") } if hasDatabaseYaml := common.FileExists("config/database.yml"); hasDatabaseYaml { common.PrintlnL2("Found config/database.yml") a.Messages.Add( fmt.Sprintf("%s %s-> %s", "database.yml: Make sure you are using environment variables.", common.MsgReset, "http://help.cloud66.com/deployment/environment-variables")) } if hasMongoIdYaml := common.FileExists("config/mongoid.yml"); hasMongoIdYaml { common.PrintlnL2("Found config/mongoid.yml") a.Messages.Add( fmt.Sprintf("%s %s-> %s", "mongoid.yml: Make sure you are using environment variables.", common.MsgReset, "http://help.cloud66.com/deployment/environment-variables")) } return dbs }
func (a *Analyzer) FindDatabases() *common.Lister { dbs := common.NewLister() return dbs }
func (a *Analyzer) GuessPackages() *common.Lister { packages := common.NewLister() return packages }