Skip to content

Commit

Permalink
Clean-up old code, and update Go version to 1.21
Browse files Browse the repository at this point in the history
* Cleans-up unused code to reduce size used in memory, during CI
and at deployment time.
* Updates Go version to 1.21

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Oct 19, 2023
1 parent 8992092 commit ff4f40b
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 1,692 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ghcr.io/openfaas/license-check:0.4.2 as license-check

FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.20 as build
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 as build

ARG TARGETPLATFORM
ARG BUILDPLATFORM
Expand Down
20 changes: 8 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
informers "github.com/openfaas/faas-netes/pkg/client/informers/externalversions"
v1 "github.com/openfaas/faas-netes/pkg/client/informers/externalversions/openfaas/v1"
"github.com/openfaas/faas-netes/pkg/config"
"github.com/openfaas/faas-netes/pkg/controller"
"github.com/openfaas/faas-netes/pkg/handlers"
"github.com/openfaas/faas-netes/pkg/k8s"
"github.com/openfaas/faas-netes/pkg/signals"
Expand All @@ -42,6 +41,8 @@ import (
// _ "sigs.k8s.io/controller-tools/cmd/controller-gen"
)

const defaultResync = time.Hour * 10

func main() {
var kubeconfig string
var masterURL string
Expand Down Expand Up @@ -118,10 +119,6 @@ func main() {
ProfilesNamespace: config.ProfilesNamespace,
}

// the sync interval does not affect the scale to/from zero feature
// auto-scaling is does via the HTTP API that acts on the deployment Spec.Replicas
defaultResync := time.Minute * 5

namespaceScope := config.DefaultFunctionNamespace

if namespaceScope == "" {
Expand All @@ -146,7 +143,6 @@ func main() {
}

runController(setup)

}

type customInformers struct {
Expand Down Expand Up @@ -197,16 +193,17 @@ func runController(setup serverSetup) {
stopCh := signals.SetupSignalHandler()
operator := false
listers := startInformers(setup, stopCh, operator)
controller.RegisterEventHandlers(listers.DeploymentInformer, kubeClient, config.DefaultFunctionNamespace)

handlers.RegisterEventHandlers(listers.DeploymentInformer, kubeClient, config.DefaultFunctionNamespace)
deployLister := listers.DeploymentInformer.Lister()
functionLookup := k8s.NewFunctionLookup(config.DefaultFunctionNamespace, listers.EndpointsInformer.Lister())
functionList := k8s.NewFunctionList(config.DefaultFunctionNamespace, deployLister)

bootstrapHandlers := providertypes.FaaSHandlers{
FunctionProxy: proxy.NewHandlerFunc(config.FaaSConfig, functionLookup),
DeleteHandler: handlers.MakeDeleteHandler(config.DefaultFunctionNamespace, kubeClient),
DeployHandler: handlers.MakeDeployHandler(config.DefaultFunctionNamespace, factory),
FunctionReader: handlers.MakeFunctionReader(config.DefaultFunctionNamespace, listers.DeploymentInformer.Lister()),
ReplicaReader: handlers.MakeReplicaReader(config.DefaultFunctionNamespace, listers.DeploymentInformer.Lister()),
DeployHandler: handlers.MakeDeployHandler(config.DefaultFunctionNamespace, factory, functionList),
FunctionReader: handlers.MakeFunctionReader(config.DefaultFunctionNamespace, deployLister),
ReplicaReader: handlers.MakeReplicaReader(config.DefaultFunctionNamespace, deployLister),
ReplicaUpdater: handlers.MakeReplicaUpdater(config.DefaultFunctionNamespace, kubeClient),
UpdateHandler: handlers.MakeUpdateHandler(config.DefaultFunctionNamespace, factory),
HealthHandler: handlers.MakeHealthHandler(),
Expand All @@ -217,7 +214,6 @@ func runController(setup serverSetup) {
}

faasProvider.Serve(&bootstrapHandlers, &config.FaaSConfig)

}

// serverSetup is a container for the config and clients needed to start the
Expand Down
106 changes: 0 additions & 106 deletions pkg/controller/annotations_test.go

This file was deleted.

Loading

0 comments on commit ff4f40b

Please sign in to comment.