Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Mar 5, 2025
1 parent 0796782 commit 5c0bec1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions internal/buildengine/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ import (
)

type AdminClient interface {
ApplyChangeset(context.Context, *connect.Request[ftlv1.ApplyChangesetRequest]) (*connect.ServerStreamForClient[ftlv1.ApplyChangesetResponse], error)
ApplyChangeset(ctx context.Context, req *connect.Request[ftlv1.ApplyChangesetRequest]) (*connect.ServerStreamForClient[ftlv1.ApplyChangesetResponse], error)
ClusterInfo(ctx context.Context, req *connect.Request[ftlv1.ClusterInfoRequest]) (*connect.Response[ftlv1.ClusterInfoResponse], error)
GetArtefactDiffs(ctx context.Context, req *connect.Request[ftlv1.GetArtefactDiffsRequest]) (*connect.Response[ftlv1.GetArtefactDiffsResponse], error)
UploadArtefact(ctx context.Context) *connect.ClientStreamForClient[ftlv1.UploadArtefactRequest, ftlv1.UploadArtefactResponse]
Ping(ctx context.Context, req *connect.Request[ftlv1.PingRequest]) (*connect.Response[ftlv1.PingResponse], error)
}

type DependencyGrapher interface {
Graph(...string) (map[string][]string, error)
Graph(moduleNames ...string) (map[string][]string, error)
}

type pendingModule struct {
Expand Down Expand Up @@ -237,7 +237,7 @@ func (c *DeployCoordinator) processEvents(ctx context.Context) {
toDeploy = append(toDeploy, deployment)
}
if deployment.publishInSchema {
c.publishUpdatedSchema(ctx, maps.Keys(deployment.modules), toDeploy, deploying)
c.publishUpdatedSchema(ctx, maps.Keys(deployment.modules), toDeploy, deploying) //nolint:exptostd
}
case notification := <-events:
var key key.Changeset
Expand Down Expand Up @@ -346,7 +346,7 @@ func (c *DeployCoordinator) tryDeployFromQueue(ctx context.Context, deployment *

keyChan := make(chan result.Result[key.Changeset], 1)
go func() {
err := deploy(ctx, slices.Map(maps.Values(deployment.modules), func(m *pendingModule) *schema.Module { return m.schema }), deployment.replicas, c.adminClient, keyChan)
err := deploy(ctx, slices.Map(maps.Values(deployment.modules), func(m *pendingModule) *schema.Module { return m.schema }), deployment.replicas, c.adminClient, keyChan) //nolint:exptostd
if err != nil {
// Handle deployment failure
for _, module := range deployment.modules {
Expand Down Expand Up @@ -386,7 +386,7 @@ func (c *DeployCoordinator) tryDeployFromQueue(ctx context.Context, deployment *

func (c *DeployCoordinator) mergePendingDeployment(d *pendingDeploy, old *pendingDeploy) (*pendingDeploy, error) {
if d.replicas != old.replicas {
return nil, fmt.Errorf("could not deploy %v with pending deployment of %v: replicas were different %d != %d", maps.Keys(d.modules), maps.Keys(old.modules), d.replicas, old.replicas)
return nil, fmt.Errorf("could not deploy %v with pending deployment of %v: replicas were different %d != %d", maps.Keys(d.modules), maps.Keys(old.modules), d.replicas, old.replicas) //nolint:exptostd
}
out := reflect.DeepCopy(d)
addedModules := []string{}
Expand All @@ -399,12 +399,12 @@ func (c *DeployCoordinator) mergePendingDeployment(d *pendingDeploy, old *pendin
}
if len(addedModules) > 0 {
if invalid := c.invalidModulesForDeployment(c.schemaSource.CanonicalView(), out, addedModules); len(invalid) > 0 {
return nil, fmt.Errorf("could not deploy %v with pending deployment of %v: modules were incompatible %v", maps.Keys(d.modules), maps.Keys(old.modules), maps.Keys(invalid))
return nil, fmt.Errorf("could not deploy %v with pending deployment of %v: modules were incompatible %v", maps.Keys(d.modules), maps.Keys(old.modules), maps.Keys(invalid)) //nolint:exptostd
}
}
out.publishInSchema = out.publishInSchema || old.publishInSchema
out.supercededModules = append(d.supercededModules, old)
out.supercededModules = append(d.supercededModules, old.supercededModules...)
out.supercededModules = append(d.supercededModules, old) //nolint:gocritic
out.supercededModules = append(d.supercededModules, old.supercededModules...) //nolint:gocritic
return out, nil
}

Expand Down Expand Up @@ -498,18 +498,18 @@ func (c *DeployCoordinator) publishUpdatedSchema(ctx context.Context, updatedMod
}
}

func (d *DeployCoordinator) terminateModuleDeployment(ctx context.Context, module string) error {
func (c *DeployCoordinator) terminateModuleDeployment(ctx context.Context, module string) error {
logger := log.FromContext(ctx).Module(module).Scope("terminate")

mod, ok := d.schemaSource.CanonicalView().Module(module).Get()
mod, ok := c.schemaSource.CanonicalView().Module(module).Get()

if !ok {
return fmt.Errorf("deployment for module %s not found", module)
}
key := mod.Runtime.Deployment.DeploymentKey

logger.Infof("Terminating deployment %s", key)
stream, err := d.adminClient.ApplyChangeset(ctx, connect.NewRequest(&ftlv1.ApplyChangesetRequest{
logger.Infof("Terminating deployment %s", key) //nolint:forbidigo
stream, err := c.adminClient.ApplyChangeset(ctx, connect.NewRequest(&ftlv1.ApplyChangesetRequest{
ToRemove: []string{key.String()},
}))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/buildengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration
return !event.updatedModules[name]
})
if len(dependentModuleNames) > 0 {
logger.Infof("%s's schema changed; processing %s", module.Name, strings.Join(dependentModuleNames, ", "))
_ = e.BuildAndDeploy(ctx, 1, false, false, dependentModuleNames...) //nolint:errcheck
logger.Infof("%s's schema changed; processing %s", module.Name, strings.Join(dependentModuleNames, ", ")) //nolint:forbidigo
_ = e.BuildAndDeploy(ctx, 1, false, false, dependentModuleNames...) //nolint:errcheck
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/buildengine/engine_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func updateVerb(module, old, new string) in.Action {
}
assert.NotEqual(t, "", file, "unsupported language: %s", ic.Language)

in.Exec("sed", "-i", "", "s/"+old+"/"+new+"/g", file)(t, ic)
in.Exec("sed", "-i", "", "s/"+strcase.ToUpperCamel(old)+"/"+strcase.ToUpperCamel(new)+"/g", file)(t, ic)
in.Exec("sed", "-i.bak", "s/"+old+"/"+new+"/g", file)(t, ic)
in.Exec("sed", "-i.bak", "s/"+strcase.ToUpperCamel(old)+"/"+strcase.ToUpperCamel(new)+"/g", file)(t, ic)
}
}

0 comments on commit 5c0bec1

Please sign in to comment.