Skip to content

Commit

Permalink
Merge pull request #86 from spiffe/feature/cleanup
Browse files Browse the repository at this point in the history
Mostly code cleanup

Landing this: More to come.
  • Loading branch information
v0lkan authored Jan 18, 2025
2 parents a1cd33e + c25c550 commit f088270
Show file tree
Hide file tree
Showing 59 changed files with 1,495 additions and 1,597 deletions.
103 changes: 0 additions & 103 deletions app/keeper/internal/env/config.go

This file was deleted.

109 changes: 0 additions & 109 deletions app/keeper/internal/env/config_test.go

This file was deleted.

7 changes: 1 addition & 6 deletions app/keeper/internal/route/store/contribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/spiffe/spike-sdk-go/api/entity/data"
"github.com/spiffe/spike-sdk-go/api/entity/v1/reqres"
"github.com/spiffe/spike-sdk-go/api/errors"

"github.com/spiffe/spike/app/keeper/internal/state"
"github.com/spiffe/spike/internal/log"
"github.com/spiffe/spike/internal/net"
Expand Down Expand Up @@ -39,10 +40,6 @@ func RouteContribute(
shard := request.Shard
id := request.KeeperId

// TODO: maybe sanitize these.
// keeper id should be an integer
// shard should have a certain size, etc.

// Decode shard content from Base64 encoding.
decodedShard, err := base64.StdEncoding.DecodeString(shard)
if err != nil {
Expand All @@ -51,8 +48,6 @@ func RouteContribute(
return errors.ErrParseFailure
}

// Store decoded shard in the map.
//state.Shards.Store(id, decodedShard) // TODO: we don't need this map.
state.SetShard(decodedShard)
log.Log().Info(fName, "msg", "Shard stored", "id", id)

Expand Down
3 changes: 0 additions & 3 deletions app/keeper/internal/route/store/contribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ func RouteShard(
return errors.ErrReadFailure
}

// TODO: access control; only nexus can request shard, not keeper, not
// anyone else.

request := net.HandleRequest[
reqres.ShardRequest, reqres.ShardResponse](
requestBody, w,
Expand Down
21 changes: 0 additions & 21 deletions app/keeper/internal/route/store/status.go

This file was deleted.

48 changes: 0 additions & 48 deletions app/keeper/internal/state/state.go

This file was deleted.

22 changes: 6 additions & 16 deletions app/nexus/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ package main
import (
"context"
"fmt"
"time"

"github.com/spiffe/spike-sdk-go/net"
"github.com/spiffe/spike-sdk-go/spiffe"

"github.com/spiffe/spike/app/nexus/internal/env"
"github.com/spiffe/spike/app/nexus/internal/poll"
"github.com/spiffe/spike/app/nexus/internal/initialization"
"github.com/spiffe/spike/app/nexus/internal/route/handle"
"github.com/spiffe/spike/app/nexus/internal/trust"
"github.com/spiffe/spike/internal/config"
Expand All @@ -36,21 +35,12 @@ func main() {

trust.Authenticate(spiffeid)

ticker := time.NewTicker(env.PollInterval())
defer ticker.Stop()
initialization.Initialize(source)

// Waits until SPIKE Nexus fetches adequate trust material from
// SPIKE Keepers to compute a root key for the backing store.

// TODO: since this is not polling anymore, `Tick` is not the right name
// for it.
poll.Tick(source)
// TODO: Later: for in-memory backing store, we can bypass this poll and
// initialize the backing store with some dummy 32byte random data.

log.Log().Info(appName,
"msg", fmt.Sprintf("Started service: %s v%s",
appName, config.NexusVersion))
log.Log().Info(appName, "msg", fmt.Sprintf(
"Started service: %s v%s",
appName, config.NexusVersion),
)

if err := net.Serve(
source, handle.InitializeRoutes,
Expand Down
9 changes: 0 additions & 9 deletions app/nexus/internal/config/config.go

This file was deleted.

4 changes: 0 additions & 4 deletions app/nexus/internal/env/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ const (
Memory StoreType = "memory"
)

// TODO: add to docs, backing stores are considered untrusted as per the
// security model of SPIKE; so even if you store it on a public place, you
// don't lose much; but still, it's important to limit access to them.

// BackendStoreType determines which storage backend type to use based on the
// SPIKE_NEXUS_BACKEND_STORE environment variable. The value is
// case-insensitive.
Expand Down
Loading

0 comments on commit f088270

Please sign in to comment.