-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(config): loads authorization from mounted configmap
- Loading branch information
1 parent
9446ae0
commit 164f7a7
Showing
15 changed files
with
139 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package spi | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// LoadableConfig is an interface that defines the strategy to load a configuration from a given path. | ||
type LoadableConfig[T any] interface { | ||
Load(configPath string) ([]T, error) | ||
} | ||
|
||
// LoadConfig loads the configuration from the given path using the strategy defined by the LoadableConfig implementation. | ||
func LoadConfig[T LoadableConfig[T]](instance T, configPath string) ([]T, error) { | ||
defs, err := instance.Load(configPath) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed loading config for: %w", err) | ||
} | ||
|
||
return defs, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package spi_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega/gstruct" | ||
"github.com/opendatahub-io/odh-platform/pkg/spi" | ||
"github.com/opendatahub-io/odh-platform/test/labels" | ||
) | ||
|
||
var _ = Describe("Loading capabilities", Label(labels.Unit), func() { | ||
|
||
Context("loading capabilities from files", func() { | ||
|
||
It("should load authorized resources", func() { | ||
authorizationComponents, err := spi.LoadConfig(spi.AuthorizationComponent{}, "../../test/data/config") | ||
Expect(err).To(Succeed()) | ||
Expect(authorizationComponents).To(ContainElement( | ||
MatchFields(IgnoreExtras, Fields{ | ||
"Ports": ContainElement("9192"), | ||
"HostPaths": ContainElement("status.url"), | ||
}))) | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package spi_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestSPI(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "SPI handling") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[ | ||
{ | ||
"schema": { | ||
"gvk": { | ||
"kind": "service", | ||
"version": "v1", | ||
"group": "core" | ||
}, | ||
"resources": "modelregistries" | ||
}, | ||
"workloadSelector": { | ||
"component": "predicator" | ||
}, | ||
"ports": [ | ||
"9192" | ||
], | ||
"hostPaths": [ | ||
"status.url" | ||
] | ||
} | ||
] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.