-
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 #3 from bristolgolang/step-end
begin end demo
- Loading branch information
Showing
9 changed files
with
118 additions
and
13 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 |
---|---|---|
@@ -1,11 +1,18 @@ | ||
load('ext://helm_resource', 'helm_resource', 'helm_repo') | ||
|
||
deployment = local("cue export deploy/kube.cue -e deployment --out yaml") | ||
service = local("cue export deploy/kube.cue -e service --out yaml") | ||
migration = local("cue export deploy/kube.cue -T -e migration --out yaml") | ||
|
||
docker_build( | ||
'rapid-go', | ||
context='.', | ||
dockerfile='./Dockerfile', | ||
) | ||
|
||
k8s_yaml([deployment, service]) | ||
k8s_resource(workload='api', port_forwards=32400) | ||
k8s_yaml([deployment, service, migration]) | ||
k8s_resource(workload='api', port_forwards=32400) | ||
|
||
helm_repo('bitnami', 'https://charts.bitnami.com/bitnami') | ||
helm_resource('postgresql', 'bitnami/postgresql', resource_deps=['bitnami'], flags=['--set=global.postgresql.auth.password=password']) | ||
k8s_resource(workload='postgresql', port_forwards=5432) |
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
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,30 @@ | ||
package server | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
type server struct { | ||
dbConn *sql.DB | ||
} | ||
|
||
func NewServer(dbConn *sql.DB) *server { | ||
return &server{ | ||
dbConn: dbConn, | ||
} | ||
} | ||
|
||
func (s *server) Greet(w http.ResponseWriter, r *http.Request) { | ||
name := r.PathValue("name") | ||
|
||
_, err := s.dbConn.ExecContext(r.Context(), "INSERT INTO users (name) VALUES ($1)", name) | ||
if err != nil { | ||
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
|
||
msg := fmt.Sprintf("Hello, %s!", name) | ||
w.Write([]byte(msg)) | ||
} |
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 users; |
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,4 @@ | ||
CREATE TABLE users ( | ||
id SERIAL PRIMARY KEY, | ||
name TEXT NOT NULL | ||
); |