-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: add entrypoints to services and targets
- Loading branch information
Showing
61 changed files
with
3,332 additions
and
1,876 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
examples | ||
Makefile | ||
Dockerfile | ||
compose.yml | ||
docs | ||
|
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,2 +1,3 @@ | ||
Makefile | ||
Dockerfile | ||
compose.yml |
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,3 @@ | ||
archive: | ||
rm -rf multiple-ports.tar.gz | ||
tar czf multiple-ports.tar.gz * |
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,11 @@ | ||
services: | ||
app: | ||
build: . | ||
command: -web 8080,8081 -tcp 8082,8083 -udp 8084,8085 | ||
command: -web 8080,8081,8082 -tcp 8083,8084,8085 -udp 8086,8087,8088 | ||
ports: | ||
- "8080:8080" | ||
- "8081:8081" | ||
- "8082:8082/tcp" | ||
- "8081-8082:8081-8082" | ||
- "8083:8083/tcp" | ||
- "8084:8084/udp" | ||
- "8085:8085/udp" | ||
- "8084-8085:8084-8085/tcp" | ||
- "8086:8086/udp" | ||
- "8087-8088:8087-8088/udp" |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Makefile | ||
Dockerfile | ||
compose.yml | ||
node_modules |
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
46 changes: 46 additions & 0 deletions
46
internal/deployment/app/configure_target/on_app_cleanup_requested.go
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,46 @@ | ||
package configure_target | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/YuukanOO/seelf/internal/deployment/domain" | ||
"github.com/YuukanOO/seelf/pkg/bus" | ||
) | ||
|
||
// When an application cleanup has been requested, unexpose the application from all targets. | ||
func OnAppCleanupRequestedHandler( | ||
reader domain.TargetsReader, | ||
writer domain.TargetsWriter, | ||
) bus.SignalHandler[domain.AppCleanupRequested] { | ||
return func(ctx context.Context, evt domain.AppCleanupRequested) error { | ||
if evt.ProductionConfig.Target() == evt.StagingConfig.Target() { | ||
target, err := reader.GetByID(ctx, evt.ProductionConfig.Target()) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
target.UnExposeEntrypoints(evt.ID) | ||
|
||
return writer.Write(ctx, &target) | ||
} | ||
|
||
productionTarget, err := reader.GetByID(ctx, evt.ProductionConfig.Target()) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
productionTarget.UnExposeEntrypoints(evt.ID, domain.Production) | ||
|
||
stagingTarget, err := reader.GetByID(ctx, evt.StagingConfig.Target()) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
stagingTarget.UnExposeEntrypoints(evt.ID, domain.Staging) | ||
|
||
return writer.Write(ctx, &productionTarget, &stagingTarget) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
internal/deployment/app/configure_target/on_app_env_changed.go
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,32 @@ | ||
package configure_target | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/YuukanOO/seelf/internal/deployment/domain" | ||
"github.com/YuukanOO/seelf/pkg/bus" | ||
) | ||
|
||
// When an application environment has changed and only if the target has changed, | ||
// unexpose the application from the old target. | ||
func OnAppEnvChangedHandler( | ||
reader domain.TargetsReader, | ||
writer domain.TargetsWriter, | ||
) bus.SignalHandler[domain.AppEnvChanged] { | ||
return func(ctx context.Context, evt domain.AppEnvChanged) error { | ||
// No target change, nothing to do | ||
if evt.Config.Target() == evt.OldConfig.Target() { | ||
return nil | ||
} | ||
|
||
target, err := reader.GetByID(ctx, evt.OldConfig.Target()) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
target.UnExposeEntrypoints(evt.ID, evt.Environment) | ||
|
||
return writer.Write(ctx, &target) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
internal/deployment/app/configure_target/on_deployment_state_changed.go
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,29 @@ | ||
package configure_target | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/YuukanOO/seelf/internal/deployment/domain" | ||
"github.com/YuukanOO/seelf/pkg/bus" | ||
) | ||
|
||
func OnDeploymentStateChangedHandler( | ||
reader domain.TargetsReader, | ||
writer domain.TargetsWriter, | ||
) bus.SignalHandler[domain.DeploymentStateChanged] { | ||
return func(ctx context.Context, evt domain.DeploymentStateChanged) error { | ||
if evt.State.Status() != domain.DeploymentStatusSucceeded { | ||
return nil | ||
} | ||
|
||
target, err := reader.GetByID(ctx, evt.Config.Target()) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
target.ExposeEntrypoints(evt.ID.AppID(), evt.Config.Environment(), evt.State.Services().Get(domain.Services{})) | ||
|
||
return writer.Write(ctx, &target) | ||
} | ||
} |
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
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
43 changes: 36 additions & 7 deletions
43
internal/deployment/app/get_app_deployments/get_app_deployments.go
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,19 +1,48 @@ | ||
package get_app_deployments | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/YuukanOO/seelf/internal/deployment/app" | ||
"github.com/YuukanOO/seelf/internal/deployment/app/get_deployment" | ||
"github.com/YuukanOO/seelf/pkg/bus" | ||
"github.com/YuukanOO/seelf/pkg/monad" | ||
"github.com/YuukanOO/seelf/pkg/storage" | ||
) | ||
|
||
// Retrieve all deployments for an app. | ||
type Query struct { | ||
bus.Query[storage.Paginated[get_deployment.Deployment]] | ||
type ( | ||
Query struct { | ||
// Retrieve all deployments for an app. | ||
bus.Query[storage.Paginated[Deployment]] | ||
|
||
AppID string `json:"-"` | ||
Page monad.Maybe[int] `form:"page"` | ||
Environment monad.Maybe[string] `form:"environment"` | ||
} | ||
|
||
Deployment struct { | ||
AppID string `json:"app_id"` | ||
DeploymentNumber int `json:"deployment_number"` | ||
Environment string `json:"environment"` | ||
Target TargetSummary `json:"target"` | ||
Source get_deployment.Source `json:"source"` | ||
State State `json:"state"` | ||
RequestedAt time.Time `json:"requested_at"` | ||
RequestedBy app.UserSummary `json:"requested_by"` | ||
} | ||
|
||
AppID string `json:"-"` | ||
Page monad.Maybe[int] `form:"page"` | ||
Environment monad.Maybe[string] `form:"environment"` | ||
} | ||
TargetSummary struct { | ||
ID string `json:"id"` | ||
Name monad.Maybe[string] `json:"name"` // Since the target could have been deleted, the name is nullable here. | ||
Url monad.Maybe[string] `json:"url"` | ||
} | ||
|
||
State struct { | ||
Status uint8 `json:"status"` | ||
ErrCode monad.Maybe[string] `json:"error_code"` | ||
StartedAt monad.Maybe[time.Time] `json:"started_at"` | ||
FinishedAt monad.Maybe[time.Time] `json:"finished_at"` | ||
} | ||
) | ||
|
||
func (Query) Name_() string { return "deployment.query.get_app_deployments" } |
Oops, something went wrong.