Skip to content

Commit

Permalink
Allow use of localhost registry for limited testing
Browse files Browse the repository at this point in the history
Limited testing is permitted within the EULA using private
images so long as they are published to a registry on localhost.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Dec 17, 2024
1 parent 7751713 commit 39feb0e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/handlers/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ package handlers
import (
"context"
"fmt"
"net"
"regexp"
"strconv"
"strings"

"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
Expand Down Expand Up @@ -98,6 +100,10 @@ func validateScalingLabels(request *types.FunctionDeployment) error {
return nil
}

// OpenFaaS CE license
// This code is licensed under the OpenFaaS Community Edition (CE) EULA
// A license is required to use public images, however a registry on localhost is supported
// for local testing within the terms of the EULA.
func isAnonymous(image string) error {
// Use context to cancel or timeout requests
ctx := context.Background()
Expand All @@ -111,6 +117,15 @@ func isAnonymous(image string) error {
return fmt.Errorf("unable to parse image reference: %s", err.Error())
}

registryServer := ref.Context().Registry.Name()

if strings.HasPrefix(registryServer, "localhost") {
host, _, err := net.SplitHostPort(registryServer)
if err == nil && host == "localhost" {
return nil
}
}

if _, err := remote.Head(ref, remote.WithAuth(auth), remote.WithContext(ctx)); err != nil {
return fmt.Errorf("the Community Edition license agreement only supports public images")
}
Expand Down

0 comments on commit 39feb0e

Please sign in to comment.