Skip to content

Commit

Permalink
make project optional for CD
Browse files Browse the repository at this point in the history
  • Loading branch information
lionello committed Jun 26, 2024
1 parent b940a9c commit 0d8395e
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/pkg/cli/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
func BootstrapCommand(ctx context.Context, client client.Client, command string) error {
projectName, err := client.LoadProjectName(ctx)
if err != nil {
return err
term.Debug("Failed to load project name:", err)
}

term.Debug("Running CD command", command, "in project", projectName)
term.Debugf("Running CD command %s in project %q", command, projectName)
if DoDryRun {
return ErrDryRun
}
Expand All @@ -26,7 +26,7 @@ func BootstrapCommand(ctx context.Context, client client.Client, command string)
return err
}

return Tail(ctx, client, TailOptions{Etag: etag, Since: since})
return tail(ctx, client, TailOptions{Etag: etag, Since: since})
}

func BootstrapLocalList(ctx context.Context, client client.Client) error {
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func GenerateLetsEncryptCert(ctx context.Context, client cliClient.Client) error
if err != nil {
return err
}
term.Debug("Generating TLS cert for project", projectName)
term.Debugf("Generating TLS cert for project %q", projectName)

services, err := client.GetServices(ctx)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/client/byoc/aws/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (b *ByocAws) Tail(ctx context.Context, req *defangv1.TailRequest) (client.S
term.Debug("Tailing task", etag)
etag = "" // no need to filter by etag
} else {
// Tail CD, kaniko, and all services
// Tail CD, kaniko, and all services (this requires PulumiProject to be set)
kanikoTail := ecs.LogGroupInput{LogGroupARN: b.driver.MakeARN("logs", "log-group:"+b.stackDir("builds"))} // must match logic in ecs/common.ts
term.Debug("Tailing kaniko logs", kanikoTail.LogGroupARN)
servicesTail := ecs.LogGroupInput{LogGroupARN: b.driver.MakeARN("logs", "log-group:"+b.stackDir("logs"))} // must match logic in ecs/common.ts
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/composeDown.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func ComposeDown(ctx context.Context, client client.Client) (types.ETag, error)
if err != nil {
return "", err
}
term.Debug("Destroying project", projectName)
term.Debugf("Destroying project %q", projectName)

if DoDryRun {
return "", ErrDryRun
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/configDelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func ConfigDelete(ctx context.Context, client client.Client, names ...string) er
if err != nil {
return err
}
term.Debug("Deleting config", names, "in project", projectName)
term.Debugf("Deleting config %v in project %q", names, projectName)

if DoDryRun {
return ErrDryRun
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/configList.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func ConfigList(ctx context.Context, client client.Client) error {
if err != nil {
return err
}
term.Debug("Listing config in project", projectName)
term.Debugf("Listing config in project %q", projectName)

config, err := client.ListConfig(ctx)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/configSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func ConfigSet(ctx context.Context, client client.Client, name string, value str
if err != nil {
return err
}
term.Debug("Setting config", name, "in project", projectName)
term.Debugf("Setting config %q in project %q", name, projectName)

if DoDryRun {
return ErrDryRun
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/getServices.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func GetServices(ctx context.Context, client client.Client, long bool) error {
if err != nil {
return err
}
term.Debug("Listing services in project", projectName)
term.Debugf("Listing services in project %q", projectName)

serviceList, err := client.GetServices(ctx)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion src/pkg/cli/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func Tail(ctx context.Context, client client.Client, params TailOptions) error {
if err != nil {
return err
}
term.Debug("Tailing logs in project", projectName)
term.Debugf("Tailing logs in project %q", projectName)

if len(params.Services) > 0 {
for _, service := range params.Services {
Expand All @@ -164,6 +164,10 @@ func Tail(ctx context.Context, client client.Client, params TailOptions) error {
return ErrDryRun
}

return tail(ctx, client, params)
}

func tail(ctx context.Context, client client.Client, params TailOptions) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()

Expand Down
28 changes: 28 additions & 0 deletions src/tests/sanity/compose.yaml.convert
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"name": "nginx",
"image": "nginx",
"platform": 2,
"internal": true,
"deploy": {
"replicas": 1,
"resources": {
"reservations": {
"memory": 256
}
}
},
"ports": [
{
"target": 80,
"mode": 1
}
],
"secrets": [
{
"source": "dummy"
}
],
"networks": 1
}
]
19 changes: 19 additions & 0 deletions src/tests/sanity/compose.yaml.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: sanity
services:
nginx:
deploy:
resources:
reservations:
memory: "268435456"
environment:
dummy: null
image: nginx
networks:
default: null
ports:
- mode: ingress
target: 80
restart: unless-stopped
networks:
default:
name: sanity_default
1 change: 1 addition & 0 deletions src/tests/sanity/compose.yaml.warnings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
level=warning msg="service \"nginx\": ingress port without healthcheck defaults to GET / HTTP/1.1"

0 comments on commit 0d8395e

Please sign in to comment.