-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from PSNAppz/develop
Release v1.2
- Loading branch information
Showing
13 changed files
with
375 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,5 @@ override.tf.json | |
|
||
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc | ||
terraform.rc | ||
tfplan |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package main | ||
|
||
import ( | ||
"math/rand" | ||
"os" | ||
"strings" | ||
|
||
"github.com/PSNAppz/Fold-ELK/db" | ||
"github.com/PSNAppz/Fold-ELK/models" | ||
"github.com/bxcodec/faker/v3" | ||
"github.com/rs/zerolog" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
func main() { | ||
logger := zerolog.New(os.Stderr).With().Timestamp().Logger() | ||
dbConfig := db.Config{ | ||
// hard-coding db connection info since we only have to seed on the dev machine | ||
Host: "localhost", | ||
Port: 5432, | ||
Username: "fold-elk", | ||
Password: "password", | ||
DbName: "fold_elk", | ||
} | ||
|
||
dbInstance, err := db.Init(dbConfig) | ||
if err != nil { | ||
logger.Err(err).Msg("Connection failed") | ||
os.Exit(1) | ||
} | ||
logger.Info().Msg("Connected to Database") | ||
|
||
// Seed dummy users | ||
logger.Info().Msg("Seeding Users to Database") | ||
for i := 0; i < 15; i++ { | ||
user := &models.User{ | ||
Name: faker.Name(), | ||
} | ||
err = dbInstance.CreateUser(user) | ||
if err != nil { | ||
log.Err(err).Msg("failed to save record") | ||
} | ||
} | ||
logger.Info().Msg("Completed Seeding Users to Database") | ||
|
||
// Create Hashtags | ||
logger.Info().Msg("Seeding Hashtags to Database") | ||
for i := 0; i < 15; i++ { | ||
ht := &models.Hashtag{ | ||
Name: faker.Word(), | ||
} | ||
err = dbInstance.CreateHashtag(ht) | ||
if err != nil { | ||
log.Err(err).Msg("failed to save record") | ||
} | ||
} | ||
logger.Info().Msg("Completed Seeding Hashtags to Database") | ||
|
||
// Seed dummy projects | ||
logger.Info().Msg("Seeding Projects to Database") | ||
for i := 0; i < 10; i++ { | ||
name := faker.Sentence() | ||
project := &models.Project{ | ||
Name: name, | ||
Slug: strings.ReplaceAll(strings.ToLower(name), " ", "-"), | ||
Description: faker.Paragraph(), | ||
} | ||
|
||
// get random user | ||
user, err := dbInstance.GetUserById(rand.Intn(15) + 1) | ||
if err != nil { | ||
log.Err(err).Msg("failed to get user") | ||
} | ||
|
||
// get random hashtags | ||
hashtagIds := make([]models.Hashtag, 0) | ||
for i := 0; i < 3; i++ { | ||
hashtagIds, err = dbInstance.GetHashtags() | ||
if err != nil { | ||
log.Err(err).Msg("failed to get hashtags") | ||
} | ||
} | ||
// create project | ||
err = dbInstance.CreateProject(project, &user, &hashtagIds) | ||
if err != nil { | ||
log.Err(err).Msg("failed to save record") | ||
} | ||
} | ||
logger.Info().Msg("Completed Seeding Projects to Database") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
sudo apt update -y | ||
sudo apt install docker.io -y | ||
sudo apt install git -y | ||
sudo service docker start | ||
sudo systemctl enable docker | ||
|
||
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} | ||
mkdir -p $DOCKER_CONFIG/cli-plugins | ||
curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose | ||
sudo chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose | ||
|
Oops, something went wrong.