Skip to content

Commit 39feb0e

Browse files
committed
Allow use of localhost registry for limited testing
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]>
1 parent 7751713 commit 39feb0e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/handlers/validate.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ package handlers
99
import (
1010
"context"
1111
"fmt"
12+
"net"
1213
"regexp"
1314
"strconv"
15+
"strings"
1416

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

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

120+
registryServer := ref.Context().Registry.Name()
121+
122+
if strings.HasPrefix(registryServer, "localhost") {
123+
host, _, err := net.SplitHostPort(registryServer)
124+
if err == nil && host == "localhost" {
125+
return nil
126+
}
127+
}
128+
114129
if _, err := remote.Head(ref, remote.WithAuth(auth), remote.WithContext(ctx)); err != nil {
115130
return fmt.Errorf("the Community Edition license agreement only supports public images")
116131
}

0 commit comments

Comments
 (0)