-
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 #4 from arngrimur/kubernetes
Kubernetes
- Loading branch information
Showing
22 changed files
with
1,597 additions
and
63 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
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 |
---|---|---|
|
@@ -2,9 +2,7 @@ name: Go | |
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package db | ||
package database_test_helper | ||
|
||
import ( | ||
"database/sql" | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package db | ||
package database_test_helper | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
|
File renamed without changes.
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,40 @@ | ||
package db | ||
|
||
import ( | ||
"database/sql" | ||
"github.com/golang-migrate/migrate/v4" | ||
"github.com/golang-migrate/migrate/v4/database/postgres" | ||
_ "github.com/golang-migrate/migrate/v4/source/file" | ||
_ "github.com/lib/pq" | ||
"log" | ||
) | ||
|
||
func InitDatabase() (*sql.DB, error) { | ||
connString := createConnectionString() | ||
db, openErr := sql.Open("postgres", connString) | ||
if openErr != nil { | ||
log.Fatalf("Can create connection with database at '%s'", connString) | ||
return nil, openErr | ||
} | ||
driver, driverErr := postgres.WithInstance(db, &postgres.Config{}) | ||
if driverErr != nil { | ||
log.Fatalf("Can insatnciate database") | ||
return nil, driverErr | ||
} | ||
m, migrateErr := migrate.NewWithDatabaseInstance( | ||
"file:///migrations", | ||
"csn_db", driver) | ||
if migrateErr != nil { | ||
log.Fatalf("Can not migrate datbase.") | ||
return nil, migrateErr | ||
} | ||
upErr := m.Up() | ||
if upErr != nil { | ||
return nil, upErr | ||
} // or m.Step(2) if you want to explicitly set the number of migrations to run | ||
return db, nil | ||
} | ||
|
||
func createConnectionString() string { | ||
panic("Implement me!!! Grab from kubenetes secets") | ||
} |
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 @@ | ||
DROP TABLE IF EXISTS hits; |
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 @@ | ||
CREATE TABLE IF NOT EXISTS hits (ip varchar(15) PRIMARY KEY , hit_count smallint); |
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
Oops, something went wrong.