Allow encoders/decoders to terminate for impossible scenarios
This commit is contained in:
+6
@@ -9,6 +9,7 @@ package envoy
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/automation/types"
|
||||
"github.com/cortezaproject/corteza/server/pkg/dal"
|
||||
@@ -53,6 +54,11 @@ func (d StoreDecoder) decode(ctx context.Context, s store.Storer, dl dal.FullSer
|
||||
)
|
||||
wrappedFilters := make([]filterWrap, 0, len(p.Filter))
|
||||
for rt, f := range p.Filter {
|
||||
// Handle resources that don't belong to this decoder
|
||||
if !strings.HasPrefix(rt, "corteza::automation") {
|
||||
continue
|
||||
}
|
||||
|
||||
wrappedFilters = append(wrappedFilters, filterWrap{rt: rt, f: f})
|
||||
}
|
||||
|
||||
|
||||
+14
@@ -10,6 +10,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/automation/types"
|
||||
@@ -34,6 +35,19 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (d YamlDecoder) CanFile(f *os.File) (ok bool) {
|
||||
// @todo improve/expand
|
||||
return d.canExt(f.Name())
|
||||
}
|
||||
|
||||
func (d YamlDecoder) canExt(name string) (ok bool) {
|
||||
var (
|
||||
pt = strings.Split(name, ".")
|
||||
ext = strings.TrimSpace(pt[len(pt)-1])
|
||||
)
|
||||
return ext == "yaml" || ext == "yml"
|
||||
}
|
||||
|
||||
// Decode returns a set of envoy nodes based on the provided params
|
||||
//
|
||||
// YamlDecoder expects the DecodeParam of `stream` which conforms
|
||||
|
||||
@@ -5,6 +5,7 @@ package {{ .package }}
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/dal"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoyx"
|
||||
@@ -52,6 +53,11 @@ func (d StoreDecoder) decode(ctx context.Context, s store.Storer, dl dal.FullSer
|
||||
)
|
||||
wrappedFilters := make([]filterWrap, 0, len(p.Filter))
|
||||
for rt, f := range p.Filter {
|
||||
// Handle resources that don't belong to this decoder
|
||||
if !strings.HasPrefix(rt, "corteza::{{.componentIdent}}") {
|
||||
continue
|
||||
}
|
||||
|
||||
wrappedFilters = append(wrappedFilters, filterWrap{rt: rt, f: f})
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
systemTypes "github.com/cortezaproject/corteza/server/system/types"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoyx"
|
||||
@@ -35,6 +36,19 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (d YamlDecoder) CanFile(f *os.File) (ok bool) {
|
||||
// @todo improve/expand
|
||||
return d.canExt(f.Name())
|
||||
}
|
||||
|
||||
func (d YamlDecoder) canExt(name string) (ok bool) {
|
||||
var (
|
||||
pt = strings.Split(name, ".")
|
||||
ext = strings.TrimSpace(pt[len(pt)-1])
|
||||
)
|
||||
return ext == "yaml" || ext == "yml"
|
||||
}
|
||||
|
||||
// Decode returns a set of envoy nodes based on the provided params
|
||||
//
|
||||
// YamlDecoder expects the DecodeParam of `stream` which conforms
|
||||
|
||||
Generated
+6
@@ -9,6 +9,7 @@ package envoy
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/compose/types"
|
||||
"github.com/cortezaproject/corteza/server/pkg/dal"
|
||||
@@ -53,6 +54,11 @@ func (d StoreDecoder) decode(ctx context.Context, s store.Storer, dl dal.FullSer
|
||||
)
|
||||
wrappedFilters := make([]filterWrap, 0, len(p.Filter))
|
||||
for rt, f := range p.Filter {
|
||||
// Handle resources that don't belong to this decoder
|
||||
if !strings.HasPrefix(rt, "corteza::compose") {
|
||||
continue
|
||||
}
|
||||
|
||||
wrappedFilters = append(wrappedFilters, filterWrap{rt: rt, f: f})
|
||||
}
|
||||
|
||||
|
||||
Generated
+14
@@ -10,6 +10,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/compose/types"
|
||||
@@ -34,6 +35,19 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (d YamlDecoder) CanFile(f *os.File) (ok bool) {
|
||||
// @todo improve/expand
|
||||
return d.canExt(f.Name())
|
||||
}
|
||||
|
||||
func (d YamlDecoder) canExt(name string) (ok bool) {
|
||||
var (
|
||||
pt = strings.Split(name, ".")
|
||||
ext = strings.TrimSpace(pt[len(pt)-1])
|
||||
)
|
||||
return ext == "yaml" || ext == "yml"
|
||||
}
|
||||
|
||||
// Decode returns a set of envoy nodes based on the provided params
|
||||
//
|
||||
// YamlDecoder expects the DecodeParam of `stream` which conforms
|
||||
|
||||
Generated
+6
@@ -9,6 +9,7 @@ package envoy
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/dal"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoyx"
|
||||
@@ -53,6 +54,11 @@ func (d StoreDecoder) decode(ctx context.Context, s store.Storer, dl dal.FullSer
|
||||
)
|
||||
wrappedFilters := make([]filterWrap, 0, len(p.Filter))
|
||||
for rt, f := range p.Filter {
|
||||
// Handle resources that don't belong to this decoder
|
||||
if !strings.HasPrefix(rt, "corteza::system") {
|
||||
continue
|
||||
}
|
||||
|
||||
wrappedFilters = append(wrappedFilters, filterWrap{rt: rt, f: f})
|
||||
}
|
||||
|
||||
|
||||
Generated
+14
@@ -10,6 +10,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoyx"
|
||||
@@ -34,6 +35,19 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (d YamlDecoder) CanFile(f *os.File) (ok bool) {
|
||||
// @todo improve/expand
|
||||
return d.canExt(f.Name())
|
||||
}
|
||||
|
||||
func (d YamlDecoder) canExt(name string) (ok bool) {
|
||||
var (
|
||||
pt = strings.Split(name, ".")
|
||||
ext = strings.TrimSpace(pt[len(pt)-1])
|
||||
)
|
||||
return ext == "yaml" || ext == "yml"
|
||||
}
|
||||
|
||||
// Decode returns a set of envoy nodes based on the provided params
|
||||
//
|
||||
// YamlDecoder expects the DecodeParam of `stream` which conforms
|
||||
|
||||
Reference in New Issue
Block a user