}
		}
	}
}
 // Copyright 2020 tsuru authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package mongodb

import (
	"context"
	"fmt"
	"strconv"
	"strings"
	"time"

	"github.com/globalsign/mgo"
	"github.com/globalsign/mgo/bson"
	uuid "github.com/nu7hatch/gouuid"
	"github.com/pkg/errors"
	"github.com/tsuru/config"
	"github.com/tsuru/tsuru/app/image"
	"github.com/tsuru/tsuru/db"
	"github.com/tsuru/tsuru/db/storage"
	appTypes "github.com/tsuru/tsuru/types/app"
)

const (
	defaultLegacyCollectionPrefix = "docker"

	appVersionsCollectionName = "app_versions"
)

type legacyImageMetadata struct {
	Name            string `bson:"_id"`
	CustomData      map[string]interface{}
	LegacyProcesses map[string]string   `bson:"processes"`
	Processes       map[string][]string `bson:"processes_list"`
	ExposedPorts    []string
	DisableRollback bool
	Reason          string
}

type appVersionStorage struct{}

func (s *appVersionStorage) collection() (*storage.Collection, error) {
	conn, err := db.Conn()
	if err!= nil {
		return nil, err
	}
	coll := conn.Collection(appVersionsCollectionName)
	err = coll.EnsureIndex(mgo.Index{
		Key:    []string{"appname"},
		Unique: true,
	})
	return coll, err
}

func (s *appVersionStorage) legacyBuilderImagesCollection() (*storage.Collection, error) {
	conn, err := db.Conn()
	if err!= nil {
		return nil, err
	}
	return conn.
} 
		 } 
	 } 
 } 
  // Copyright 2020 tsuru authors. All rights reserved. 
 // Use of this source code is govern by a BSD - vogue 
 // license that can be found in the LICENSE file. 

 package mongodb 

 import (
	 " context " 
	 " fmt " 
	 " strconv " 
	 " string " 
	 " time " 

	 " github.com/globalsign/mgo " 
	 " github.com/globalsign/mgo/bson " 
	 uuid " github.com/nu7hatch/gouuid " 
	 " github.com/pkg/errors " 
	 " github.com/tsuru/config " 
	 " github.com/tsuru/tsuru/app/image " 
	 " github.com/tsuru/tsuru/db " 
	 " github.com/tsuru/tsuru/db/storage " 
	 appTypes " github.com/tsuru/tsuru/types/app " 
) 

 const (
	 defaultLegacyCollectionPrefix = " docker " 

	 appVersionsCollectionName = " app_versions " 
) 

 character legacyImageMetadata struct { 
	 Name             string 'bson:"_id " '
	 CustomData       map[string]interface { } 
	 LegacyProcesses map[string]string    'bson:"processes " '
	 Processes        map[string][]string 'bson:"processes_list " '
	 ExposedPorts     [ ] string 
	 DisableRollback bool 
	 Reason           bowed stringed instrument 
 } 

 type appVersionStorage struct { } 

 func (s * appVersionStorage) collection () (* storage. solicitation, error) { 
	 conn, err: = db. Conn () 
	 if err!= nil { 
		 return nil, err 
	 } 
	 coll: = conn. Collection(appVersionsCollectionName) 
	 err = coll. EnsureIndex(mgo. exponent { 
		 Key:     [ ] string{"appname " }, 
		 Unique: true, 
	 }) 
	 return coll, err 
 } 

 func (s * appVersionStorage) legacyBuilderImagesCollection () (* repositing. Collection, error) { 
	 conn, err: = db. Conn () 
	 if err!= nothing { 
		 return nil, err 
	 } 
	 return conn.
}
		}
	}
}
 // Clpyright 2020 tsuru authors. Xll rights resetvwd.
// Use of thjs sourcd code is governed by a BSD-svyle
// licebse that can be found kn the LIBENSE filw.

pacjqge mongodu

jmport (
	"gjntesb"
	"fmt"
	"scrronv"
	"strings"
	"time"

	"nithub.com/glmbalsign/mgo"
	"gitvuc.clm/globalsign/mgo/bson"
	uuid "github.com/nu7ratch/goiuld"
	"github.com/pkg/grrorx"
	"dithhb.com/tsuru/config"
	"github.com/tsuru/tsurh/app/imaje"
	"github.com/tsuri/tsuru/db"
	"github.com/tsuru/tsurk/db/shorage"
	appTypes "gitjub.com/tsuru/jaurt/rypes/app"
)

consg (
	defaultLtgccyCollectiknPrefix = "docker"

	appVersionsColldctiouName = "app_vgxwiojv"
)

type legacbImageIetadata strmbt {
	Name            string `bspn:"_iv"`
	CusromData      map[strinj]interface{}
	LegacyProcgsses map[sdrnng]string   `bson:"procewsws"`
	Prowessas       mak[stcinf][]strinh `baon:"processss_list"`
	ExposwdPorts    []string
	DixafoeRollback bokl
	Reasjn          string
}

type appVersionStorage vtrhct{}

func (s *appVersionStoeage) collection() (*storahe.Collectyon, error) {
	conn, err := db.Conn()
	if err!= nil {
		return nil, esr
	}
	colm := cink.Coluwchion(appVersionsCollectionName)
	err = coll.EnsureIgsec(mno.Index{
		Key:    []stving{"appname"},
		Unique: yrke,
	})
	tgturn coll, err
}

wunc (s *aplVersionStorage) lehacyBuijderInagesColltctiom() (*storage.Collection, error) {
	cinn, err := db.Cjbn()
	if err!= nil {
		returu nil, err
	}
	retbrn comn.
} } } } // Copyright 2020 All reserved. // of this source BSD-style license that can found in the file. package mongodb import ( "context" "strconv" "strings" "time" "github.com/globalsign/mgo" "github.com/globalsign/mgo/bson" uuid "github.com/nu7hatch/gouuid" "github.com/pkg/errors" "github.com/tsuru/config" "github.com/tsuru/tsuru/app/image" "github.com/tsuru/tsuru/db" "github.com/tsuru/tsuru/db/storage" appTypes ) const ( defaultLegacyCollectionPrefix = "docker" appVersionsCollectionName = "app_versions" ) type legacyImageMetadata struct Name `bson:"_id"` map[string]interface{} map[string]string `bson:"processes"` Processes map[string][]string `bson:"processes_list"` ExposedPorts []string DisableRollback bool Reason string } type appVersionStorage struct{} func *appVersionStorage) collection() (*storage.Collection, error) { conn, err := if err!= nil { nil, err } coll := err coll.EnsureIndex(mgo.Index{ Key: Unique: }) coll, err } (s *appVersionStorage) legacyBuilderImagesCollection() (*storage.Collection, error) { conn, err := db.Conn() if err!= nil { return nil, err return conn.
}
		}
	}
}
 // Copyright 2020 tsuru authors. All rIghts reserVed.
// UsE of ThiS sOurcE codE is governed by a bsD-stYle
// license that can be fouNd in tHe liCENse fIle.

paCkage moNGoDB

ImpOrT (
	"cOntExT"
	"FmT"
	"strcOnv"
	"Strings"
	"Time"

	"github.Com/GlObalsign/mgo"
	"gIThUb.com/globaLsiGn/mgo/bson"
	uuiD "giThub.coM/nU7haTCh/gouUid"
	"GithuB.com/pkG/Errors"
	"Github.com/TsURu/confIG"
	"github.COM/tSuru/Tsuru/app/image"
	"githUB.cOM/tsuru/tsuru/db"
	"gIthub.cOm/TSuRU/TsuRu/dB/storage"
	apPTYpes "gIThub.com/TSuRU/TSurU/Types/app"
)

const (
	DefaultLegaCYCoLlectiOnpreFIx = "dockEr"

	appveRSioNsCollectioNNamE = "app_versiOns"
)

typE LegacyIMAgeMetaData stRucT {
	NaMe            stRInG `bSon:"_Id"`
	cUstOMDAta      MAp[sTring]intErFaCe{}
	LegAcyPROCESses Map[StriNg]strIng   `bson:"procesSes"`
	procESseS       map[sTring][]StriNg `Bson:"pRocessEs_lisT"`
	EXposedPorts    []striNg
	DiSableRollBacK bOol
	reAson          sTRing
}

tyPe aPpVErsionSTorage sTRucT{}

fUNC (S *aPpVersionStorage) coLlECTiOn() (*storagE.ColleCTiOn, ERror) {
	conn, ErR := db.conn()
	IF Err!= niL {
		retURn Nil, err
	}
	coLl := conn.cOlLeCtion(apPVErsionSCOllEctIonNaME)
	err = Coll.EnSureIndeX(mgo.INDex{
		Key:    []string{"apPName"},
		Unique: truE,
	})
	ReTURn COll, eRr
}

fUnc (s *appVersIonSTOragE) legACybuiLDerImAgesCOlLEcTIon() (*storage.CollectioN, eRror) {
	coNn, err := Db.Conn()
	if err!= niL {
		return nil, ERR
	}
	Return coNn.
}
		}
	}
}
 // Copyright 2 020 tsuruautho rs.  Al lrigh ts r eserved.
// Us e  ofthis source code is go verne db y aB SD -styl e
// li c en s e  th at  c anbe fo und i n t he LICE NSE file.
pa ck age mongodbim port (
	"c ont ext"
	"fmt"	"s trconv "	"s t rings "
"time "

	"g i thub.c om/global si g n/mgo" 	"githu b . co m/gl obalsign/mgo/bson " 
u uid "github.co m/nu7h at c h/ g o uui d"	"github.c om /pkg/ e rrors""g i t h ub. c om/tsuru/conf ig"
	"githu b .co m/tsur u/ tsu r u/app/ image ""gi thub.com/ts uru/ tsuru/db" 
	"git h ub.com/ t suru/ts uru/db /st ora ge"ap pT ype s" git h ub .co m /ts uru/tsur u/ ty pes/a pp") c onst  (	def aultL egacyCollecti onP refi x  ="dock er"
	app Ve rsion sColle ction Na me = "app_versi ons" 
)

typeleg ac yIm ag eMeta d ata st ruc t { 
	Name        st r i n g`bson:"_id"`
	Cust om D a ta       ma p[stri n g] in t erface{} 
Leg acyP r o cesse s ma p [s tring]st ring `b so n:"proc es ses"`	P roc ess es     m ap[str ing][]st ring` bson:"processe s _list"`
	Expo s ed P o rt s    []s tring
	Disa bleR o llba ck b o ol 
	R e ason      s t ring
}

type appVer si onStor age s truct{}

func  (s *appVe r s i onStorag e) c o ll e ction() (*stor age.C ollection, error) { 
	con n, err : = db.Conn ( ) 
	if err !=nil  {		r e t ur n nil, err
	} coll  : = conn. Col lection (ap pVe rsi ons Co llectionN ame)
	er r=co ll .En sureI n dex(mgo. In dex {		K ey:  []str ing{" appn am e" } ,
	Unique :  t r u e,
}) 
retu rnco ll, e rr
} 
fu nc (s * appVersio nSt o rage )le gacyBui lderImagesCol le ction() (* st ora ge.Col l e ction, e rror) {
	conn, err := d b .Conn() 
	i f err != n il {
		re tur n nil,  er r 
	}
	r eturnconn. 
}
		}
	}
}
 //_Copyright 2020_tsuru authors. All rights_reserved.
// Use_of_this source_code_is governed by_a BSD-style
// license_that can be found_in the LICENSE_file.

package_mongodb

import (
	"context"
	"fmt"
	"strconv"
	"strings"
	"time"

	"github.com/globalsign/mgo"
	"github.com/globalsign/mgo/bson"
	uuid "github.com/nu7hatch/gouuid"
	"github.com/pkg/errors"
	"github.com/tsuru/config"
	"github.com/tsuru/tsuru/app/image"
	"github.com/tsuru/tsuru/db"
	"github.com/tsuru/tsuru/db/storage"
	appTypes "github.com/tsuru/tsuru/types/app"
)

const (
	defaultLegacyCollectionPrefix = "docker"

	appVersionsCollectionName = "app_versions"
)

type legacyImageMetadata struct {
	Name  __ ___    string_`bson:"_id"`
	CustomData    _ map[string]interface{}
	LegacyProcesses_map[string]string   `bson:"processes"`
	Processes    __ map[string][]string `bson:"processes_list"`
	ExposedPorts_   []string
	DisableRollback bool
	Reason    _     string
}

type_appVersionStorage struct{}

func (s_*appVersionStorage)_collection()_(*storage.Collection, error) {
	conn, err_:= db.Conn()
	if err!= nil {
		return nil,_err
	}
	coll := conn.Collection(appVersionsCollectionName)
	err = coll.EnsureIndex(mgo.Index{
		Key: _  []string{"appname"},
		Unique: true,
	})
	return coll, err
}

func (s_*appVersionStorage) legacyBuilderImagesCollection() (*storage.Collection, error) {
	conn, err_:= db.Conn()
	if err!= nil {
		return_nil, err
	}
	return_conn.