Use QL_DB_BUCKET_NAME in shell and go

This commit is contained in:
Michael Hohn
2024-07-08 14:23:25 -07:00
committed by =Michael Hohn
parent 3566f5169e
commit e3f4d9f012
2 changed files with 9 additions and 9 deletions

View File

@@ -12,7 +12,7 @@ import (
"github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/credentials"
) )
const bucketName = "qldb" const QL_DB_BUCKETNAME = "qldb"
type MinIOCodeQLDatabaseStore struct { type MinIOCodeQLDatabaseStore struct {
client *minio.Client client *minio.Client
@@ -30,14 +30,14 @@ func NewMinIOCodeQLDatabaseStore(endpoint, id, secret string) (*MinIOCodeQLDatab
slog.Info("Connected to MinIO CodeQL database store server") slog.Info("Connected to MinIO CodeQL database store server")
err = common.CreateMinIOBucketIfNotExists(minioClient, bucketName) err = common.CreateMinIOBucketIfNotExists(minioClient, QL_DB_BUCKETNAME)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not create bucket: %v", err) return nil, fmt.Errorf("could not create bucket: %v", err)
} }
return &MinIOCodeQLDatabaseStore{ return &MinIOCodeQLDatabaseStore{
client: minioClient, client: minioClient,
bucketName: bucketName, bucketName: QL_DB_BUCKETNAME,
}, nil }, nil
} }
@@ -90,8 +90,8 @@ func (store *MinIOCodeQLDatabaseStore) GetDatabaseLocationByNWO(nwo common.NameW
location := CodeQLDatabaseLocation{ location := CodeQLDatabaseLocation{
data: map[string]string{ data: map[string]string{
"bucket": store.bucketName, artifactstore.AF_KEY_BUCKET: store.bucketName,
"key": objectName, artifactstore.AF_KEY_KEY: objectName,
}, },
} }

View File

@@ -5,7 +5,7 @@ MINIO_ALIAS="qldbminio"
MINIO_URL="http://localhost:9000" MINIO_URL="http://localhost:9000"
MINIO_ROOT_USER="user" MINIO_ROOT_USER="user"
MINIO_ROOT_PASSWORD="mmusty8432" MINIO_ROOT_PASSWORD="mmusty8432"
BUCKET_NAME="qldb" QL_DB_BUCKET_NAME="qldb"
# Check for MinIO client # Check for MinIO client
if ! command -v mc &> /dev/null if ! command -v mc &> /dev/null
@@ -18,14 +18,14 @@ fi
mc alias set $MINIO_ALIAS $MINIO_URL $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD mc alias set $MINIO_ALIAS $MINIO_URL $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD
# Create qldb bucket # Create qldb bucket
mc mb $MINIO_ALIAS/$BUCKET_NAME mc mb $MINIO_ALIAS/$QL_DB_BUCKET_NAME
# Upload the two sample DBs with new names # Upload the two sample DBs with new names
mc cp cmd/server/codeql/dbs/google/flatbuffers/google_flatbuffers_db.zip \ mc cp cmd/server/codeql/dbs/google/flatbuffers/google_flatbuffers_db.zip \
$MINIO_ALIAS/$BUCKET_NAME/google\$flatbuffers.zip $MINIO_ALIAS/$QL_DB_BUCKET_NAME/google\$flatbuffers.zip
mc cp cmd/server/codeql/dbs/psycopg/psycopg2/psycopg_psycopg2_db.zip \ mc cp cmd/server/codeql/dbs/psycopg/psycopg2/psycopg_psycopg2_db.zip \
$MINIO_ALIAS/$BUCKET_NAME/psycopg\$psycopg2.zip $MINIO_ALIAS/$QL_DB_BUCKET_NAME/psycopg\$psycopg2.zip
# Check new disk use # Check new disk use
du -k dbstore-data du -k dbstore-data