Skip to content

Commit

Permalink
Add PKI placeholder code
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-heilbron committed Apr 4, 2023
1 parent 2cef001 commit d7a41ce
Show file tree
Hide file tree
Showing 23 changed files with 159 additions and 70 deletions.
1 change: 1 addition & 0 deletions ci/tools.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

/*
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/external/envoy/api/v2/core/base.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pkg/api/v1/apiserver/api_server.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
. "github.com/onsi/gomega"
)

//TODO: fix tests
// TODO: fix tests
func TestVersioned(t *testing.T) {

log.Printf("Skipping Versioned Suite. Tests are currently failing and need to be fixed.")
Expand Down
91 changes: 91 additions & 0 deletions pkg/api/v1/clients/vault/pki_resource_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package vault

import (
"time"

"github.com/solo-io/solo-kit/pkg/api/shared"
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
"github.com/solo-io/solo-kit/pkg/api/v1/resources"
)

var _ clients.ResourceClient = new(PkiResourceClient)

type PkiResourceClient struct {
//vault *api.Client

resourceType resources.VersionedResource
}

func (p PkiResourceClient) Kind() string {
return resources.Kind(p.resourceType)
}

func (p PkiResourceClient) NewResource() resources.Resource {
return resources.Clone(p.resourceType)
}

func (p PkiResourceClient) Register() error {
return nil
}

func (p PkiResourceClient) Read(namespace, name string, opts clients.ReadOpts) (resources.Resource, error) {
//TODO implement me
panic("implement me")
}

func (p PkiResourceClient) Write(resource resources.Resource, opts clients.WriteOpts) (resources.Resource, error) {
//TODO implement me
panic("implement me")
}

func (p PkiResourceClient) Delete(namespace, name string, opts clients.DeleteOpts) error {
//TODO implement me
panic("implement me")
}

func (p PkiResourceClient) List(namespace string, opts clients.ListOpts) (resources.ResourceList, error) {
//TODO implement me
panic("implement me")
}

func (p PkiResourceClient) ApplyStatus(statusClient resources.StatusClient, inputResource resources.InputResource, opts clients.ApplyStatusOpts) (resources.Resource, error) {
return shared.ApplyStatus(p, statusClient, inputResource, opts)
}

func (p PkiResourceClient) Watch(namespace string, opts clients.WatchOpts) (<-chan resources.ResourceList, <-chan error, error) {
opts = opts.WithDefaults()
resourcesChan := make(chan resources.ResourceList)
errs := make(chan error)

listOpts := clients.ListOpts{
Ctx: opts.Ctx,
Selector: opts.Selector,
ExpressionSelector: opts.ExpressionSelector,
}

go func() {
// watch should open up with an initial read
initialResourceList, initialResourceListErr := p.List(namespace, listOpts)
if initialResourceListErr != nil {
errs <- initialResourceListErr
return
}
resourcesChan <- initialResourceList
for {
select {
case <-time.After(opts.RefreshRate):
resourceList, resourceListErr := p.List(namespace, listOpts)
if resourceListErr != nil {
errs <- resourceListErr
}
resourcesChan <- resourceList
case <-opts.Ctx.Done():
close(resourcesChan)
close(errs)
return
}
}
}()

return resourcesChan, errs, nil
}
11 changes: 6 additions & 5 deletions pkg/api/v1/control-plane/cache/prioritylist.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ type PriorityValue interface {
// If a priority does not exist for an added element, it is added to the lowest priority.
//
// The below 1, 2, 4 go first, 10 second, and 17 third. Anything else is processed last
// {
// 0: {item1, item2, item4}
// 1: {item10}
// 2: {item17}
// }
//
// {
// 0: {item1, item2, item4}
// 1: {item10}
// 2: {item17}
// }
type PrioritySortedStruct struct {
// priorityMap maps the value to the priority.
priorityMap map[string]int
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1/resources/core/metadata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/api/v1/resources/core/status.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/code-generator/collector/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ type ImportsExtractor interface {
// thread-safe
// The synchronizedImportsExtractor provides synchronized access to imports for a given proto file.
// It provides 2 useful features for tree traversal:
// 1. Imports for each file are cached, ensuring that if we attempt to access that file
// during traversal again, we do not need to duplicate work.
// 2. If imports for a file are unknown, and simultaneous go routines attempt to load
// the imports, only 1 will execute and the other will block, waiting for the result.
// This reduces the number of times we open and parse files.
// 1. Imports for each file are cached, ensuring that if we attempt to access that file
// during traversal again, we do not need to duplicate work.
// 2. If imports for a file are unknown, and simultaneous go routines attempt to load
// the imports, only 1 will execute and the other will block, waiting for the result.
// This reduces the number of times we open and parse files.
type synchronizedImportsExtractor struct {
// cachedImports contains a map of fileImports, each indexed by their file name
cachedImports sync.Map
Expand Down
3 changes: 2 additions & 1 deletion pkg/code-generator/docgen/cross_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func WriteCrossProjectDocsHugo(
}

// util for populating the Hugo ProtoMap to enable allows lookup by
// somepkg.solo.io or somepkg.solo.io.SomeMessage
//
// somepkg.solo.io or somepkg.solo.io.SomeMessage
func getApiSummaryKV(apiDir, filename, packageName, fieldName string) (string, datafile.ApiSummary) {
key := packageName
hashPath := ""
Expand Down
1 change: 1 addition & 0 deletions pkg/code-generator/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func Flush(writer io.Writer) error {

// This is a primitive implementation for compiling performance measurements of code-gen
// If we need it, we could substitute this with something more heavy handed like:
//
// https://github.com/armon/go-metrics
type metricAggregator struct {
metricsMu sync.Mutex
Expand Down
9 changes: 5 additions & 4 deletions pkg/code-generator/schemagen/cue.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
// packages to translate protobuf definitions into OpenAPI schemas with structural constraints
// It is modeled after the istio tool: https://github.com/istio/tools/tree/master/cmd/cue-gen
// TODO (sam-heilbron) This tool has a known flaw that makes it unusable with Gloo Edge protos
// There are open issues to track this and a GitHub discussion with more context:
// https://github.com/cuelang/cue/discussions/944. We would like to move towards this
// implementation and have added it now to compare schemas generated with this implementation
// to schemas generated with other implementations to ensure consistency.
//
// There are open issues to track this and a GitHub discussion with more context:
// https://github.com/cuelang/cue/discussions/944. We would like to move towards this
// implementation and have added it now to compare schemas generated with this implementation
// to schemas generated with other implementations to ensure consistency.
type cueGenerator struct {
// The Collector used to extract imports for proto files
importsCollector collector.Collector
Expand Down
12 changes: 6 additions & 6 deletions pkg/utils/modutils/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ var (
)

/*
Returns the current go mod package name from the go.mod file.
Use the function below to get the filename
Ex: github.com/solo-io/solo-kit
Returns the current go mod package name from the go.mod file.
Use the function below to get the filename
Ex: github.com/solo-io/solo-kit
*/
func GetCurrentModPackageName(module string) (string, error) {
f, err := os.Open(module)
Expand All @@ -44,10 +44,10 @@ func GetCurrentModPackageName(module string) (string, error) {
}

/*
Returns the current go mod package
Ex: /path/to/solo-kit/go.mod
Returns the current go mod package
Ex: /path/to/solo-kit/go.mod
Will return /dev/null on unix if not in a go.mod package
Will return /dev/null on unix if not in a go.mod package
*/
func GetCurrentModPackageFile() (string, error) {
cmd := exec.Command("go", "env", "GOMOD")
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/statusutils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (s *NamespacedStatusesClient) SetStatus(resource resources.InputResource, s
type NoOpStatusClient struct {
}

//noinspection GoUnusedExportedFunction
// noinspection GoUnusedExportedFunction
func NewNoOpStatusClient() *NoOpStatusClient {
return &NoOpStatusClient{}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/statusutils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// to associate a resource status with the appropriate controller statusReporterNamespace
const PodNamespaceEnvName = "POD_NAMESPACE"

//noinspection GoUnusedExportedFunction
// noinspection GoUnusedExportedFunction
func GetStatusReporterNamespaceFromEnv() (string, error) {
podNamespace := os.Getenv(PodNamespaceEnvName)
if podNamespace == "" {
Expand Down
12 changes: 5 additions & 7 deletions test/mocks/v1/mock_resources.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions test/mocks/v1/more_mock_resources.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions test/mocks/v1/simple_mock_resources.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions test/mocks/v1alpha1/mock_resources.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d7a41ce

Please sign in to comment.