func (s *setup) update(bucketName []byte) {
	if s.err != nil {
		return
	}
	c := func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists(bucketName)
		if err != nil {
			return fmt.Errorf("create bucket: %s", err)
		}
		return nil
	}
	s.err = s.bs.db.Update(c)
}
Create bucket if not exists function
package store
import (
	"encoding/binary"
	"fmt"
	"path/filepath"
	"time"
	"github.com/casbin/casbin/v2/persist"
	"github.com/speza/casbin-bolt-adapter"
	bolt "go.etcd.io/bbolt"
	"github.com/gaia-pipeline/gaia"
	"github.com/gaia-pipeline/gaia/helper/assethelper"
	"github.com/gaia-pipeline/gaia/security"
)
var (
	userBucket = []byte("Users")
	userPermsBucket = []byte("UserPermissions")
	pipelineBucket = []byte("Pipelines")
	createPipelineBucket = []byte("CreatePipelines")
	pipelineRunBucket = []byte("PipelineRun")
	settingsBucket = []byte("Settings")
	workerBucket = []byte("Worker")
	shaPairBucket = []byte("SHAPair")
)
const (
	adminUsername = "admin"
	adminPassword = "admin"
	autoUsername  = "auto"
	autoPassword  = "auto"
	boltDBFileName = "gaia.db"
)
type BoltStore struct {
	db            *bolt.DB
	casbinAdapter persist.BatchAdapter
}
type SettingsStore interface {
	SettingsPut(config *gaia.StoreConfig) error
	SettingsGet() (*gaia.StoreConfig, error)
}
type GaiaStore interface {
	SettingsStore
	Init(dataPath string) error
	Close() error
	CreatePipelinePut(createPipeline *gaia.CreatePipeline) error
	CreatePipelineGet() (listOfPipelines []gaia.CreatePipeline, err error)
	PipelinePut(pipeline *gaia.Pipeline) error
	PipelineGet(id int) (pipeline *gaia.Pipeline, err error)
	PipelineGetByName(name string) (pipline *gaia.Pipeline, err error)
	PipelineGetRunHighestID(pipeline *gaia.Pipeline) (id int, err error)
	PipelinePutRun(r *gaia.PipelineRun) error
	PipelineGetScheduled(limit int) ([]*gaia.PipelineRun, error)
	PipelineGetRunByPipelineIDAndID(pipelineid int, runid int) (*gaia.PipelineRun, error)
	PipelineGetAllRuns() ([]gaia.PipelineRun, error)
	PipelineGetAllRunsByPipelineID(pipelineID int) ([]gaia.PipelineRun, error)
	PipelineGetLatestRun(pipelineID int) (*gaia.PipelineRun, error)
	PipelineGetRunByID(runID string) (*gaia.PipelineRun, error)
	PipelineDelete(id int) error
	PipelineRunDelete(uniqueID string) error
	UserPut(u *gaia.User, encryptPassword bool) error
	UserAuth(u *gaia.User, updateLastLogin bool) (*gaia.User, error)
	UserGet(username string) (*gaia.User, error)
	UserGetAll() ([]gaia.User, error)
	UserDelete(u string) error
	UserPermissionsPut(perms *gaia.UserPermission) error
	UserPermissionsGet(username string) (*gaia.UserPermission, error)
	UserPermissionsDelete(username string) error
	WorkerPut(w *gaia.Worker) error
	WorkerGetAll() ([]*gaia.Worker, error)
	WorkerDelete(id string) error
	WorkerDeleteAll() error
	WorkerGet(id string) (*gaia.Worker, error)
	UpsertSHAPair(pair gaia.SHAPair) error
	GetSHAPair(pipelineID int) (bool, gaia.SHAPair, error)
	CasbinStore() persist.BatchAdapter
}
var _ GaiaStore = (*BoltStore)(nil)
func NewBoltStore() *BoltStore {
	s := &BoltStore{}
	return s
}
func (s *BoltStore) Init(dataPath string) error {
	path := filepath.Join(dataPath, boltDBFileName)
	db, err := bolt.Open(path, gaia.Cfg.Bolt.Mode, &bolt.Options{Timeout: 5 * time.Second})
	if err != nil {
		return err
	}
	s.db = db
	builtinPolicy, _ := assethelper.LoadRBACBuiltinPolicy()
	casbinAdapter, err := boltadapter.NewAdapter(db, "casbin-policies", builtinPolicy)
	if err != nil {
		return err
	}
	s.casbinAdapter = casbinAdapter
	return s.setupDatabase()
}
func (s *BoltStore) Close() error {
	return s.db.Close()
}
type setup struct {
	bs  *BoltStore
	err error
}