-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/migrate fga to seco #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simontesar
wants to merge
66
commits into
main
Choose a base branch
from
feat/migrate-fga-to-seco
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
14bd268
feat: add separate reconciler to initialize account workspaces of typ…
simontesar 03cac88
fix: correct accounttype predicate
simontesar 0e1bd75
feat: use openfga SDK
simontesar 572a88b
Merge remote-tracking branch 'origin/main' into feat/migrate-fga-to-seco
simontesar 97f1bbf
Merge remote-tracking branch 'origin/main' into feat/migrate-fga-to-seco
simontesar f5b771c
fix: org predicate checks owner not path
simontesar 1d23cd7
fix: have account initializer also use remove-initializer subroutine
simontesar f00315a
refactor: consistent file naming
simontesar 464faf8
feat: implement account initializer using Store resource
simontesar 56ae52c
feat: add note about not checking condition
simontesar 85a5534
fix: rework org account type predicate
simontesar 341aeb4
fix: invite: clearer and non-duplicate error messages
simontesar 1b4bb23
feat: introduce client package
simontesar f18194a
feat: account-initializer: check tuples in status
simontesar ac4d5ed
chore: account-initializer: reordering and comments
simontesar 642d28a
refactor: rename org initalization controller
simontesar 4ca56ae
feat: add internal fga package
simontesar d3a5350
fix: logicalclusterclient: remove bogus print
simontesar 4fe4960
feat: account-tuples: check for change
simontesar ae12f7b
feat: org-initializer: create tuples
simontesar e650fb1
refactor: make fga package importable
simontesar f4cc794
fix: remove bogus print
simontesar 4c13c3a
refactor: remove constant dependencies on account operator
simontesar 519c56c
chore: some comments
simontesar 6fadcce
chore: go mod tidy
simontesar b42e6a2
chore: comment about requeueing and updating
simontesar 63fd1df
Merge remote-tracking branch 'origin/main' into feat/migrate-fga-to-seco
simontesar 046b7e8
fga: dont check for k8s SA but always replace colons with dots
simontesar 23bf1b1
chore: formatting for linter
simontesar ec189a4
fix: config: correct FGA mapstructure paths
simontesar cbfe46a
feat: org-initalization: check store readiness on tuple change
simontesar 8a35ddf
fix: account-initializer: get AccountInfo from parent Account's
simontesar a16a400
Merge remote-tracking branch 'origin/main' into feat/migrate-fga-to-seco
simontesar 4beb6b2
chore: clarifying comments
simontesar 72e72a4
Merge remote-tracking branch 'origin/main' into feat/migrate-fga-to-seco
simontesar 1eaee22
fix: fga: check tuple building input for errors
simontesar 45f4b9c
fix: remove now unused parentRelation from org initalizer
simontesar 7a2d408
fix: client: check APIExportEndpointSlice length
simontesar 13af20e
fix: predicates: check slice length
simontesar f52e0ba
fix: remove now unused parentRelation from org initalizer
simontesar 9195391
fix: account-tuples: remove unused finalizer and check context cluster
simontesar a47af51
chore: fix typo in comment
simontesar ad0fc3d
fix: typo in error message
simontesar e405a78
fix: org-initalizer: remove pointless logger
simontesar 37709cd
fix: initializer: use correct config
simontesar 3c4ceaa
Merge remote-tracking branch 'origin/main' into feat/migrate-fga-to-seco
simontesar 3483a52
feat: add tuple manager
simontesar 189ca8a
feat: tuple manager: add latest store constant
simontesar d9c17f7
feat: account-initializer: directly speak to openfga
simontesar ec8e6e4
feat: add terminatingworkspaces provider
simontesar 5270bff
fix: pin k8s dependencies to 0.34.0
simontesar 0e9fc65
fix: correct bogus command
simontesar 28c234d
feat: add terminator command
simontesar 8eb7faf
feat: add terminator controller and subroutine skaffolding
simontesar fa9493a
Merge remote-tracking branch 'origin/main' into feat/migrate-fga-to-seco
simontesar 7882db0
chore: regenerate mocks
simontesar 62030d3
feat: delete tuples in terminator
simontesar ca1f5e0
Merge remote-tracking branch 'origin/main' into feat/migrate-fga-to-seco
simontesar 8307219
feat: implement terminator interface
simontesar 1f00145
feat: split docker kind tasks
simontesar 466cb2f
feat: tuples: implement initializer and terminator interfaces in a si…
simontesar 47f8d56
refactor: unify account init and term controllers/subroutines
simontesar a618566
initializer: implement initalizer interface in all subroutines
simontesar 385605e
refactor: break comment
simontesar ed43936
fix: remove now unused removeInitializer subroutine
simontesar 600a72f
fix: change error wrt not found
simontesar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,147 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "crypto/tls" | ||
| "os" | ||
| "strings" | ||
|
|
||
| openfgav1 "github.com/openfga/api/proto/openfga/v1" | ||
| platformeshconfig "github.com/platform-mesh/golang-commons/config" | ||
| iclient "github.com/platform-mesh/security-operator/internal/client" | ||
| "github.com/platform-mesh/security-operator/internal/terminatingworkspaces" | ||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/credentials/insecure" | ||
|
|
||
| "github.com/platform-mesh/security-operator/internal/config" | ||
| "github.com/platform-mesh/security-operator/internal/controller" | ||
| "github.com/platform-mesh/security-operator/internal/predicates" | ||
| "github.com/spf13/cobra" | ||
| "github.com/spf13/viper" | ||
| ctrl "sigs.k8s.io/controller-runtime" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| "sigs.k8s.io/controller-runtime/pkg/healthz" | ||
| "sigs.k8s.io/controller-runtime/pkg/metrics/server" | ||
| "sigs.k8s.io/controller-runtime/pkg/predicate" | ||
| mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager" | ||
|
|
||
| "k8s.io/client-go/rest" | ||
|
|
||
| "github.com/kcp-dev/logicalcluster/v3" | ||
| kcptenancyv1alphav1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" | ||
|
|
||
| mcclient "github.com/kcp-dev/multicluster-provider/client" | ||
| ) | ||
|
|
||
| var terminatorCfg config.Config | ||
|
|
||
| var terminatorCmd = &cobra.Command{ | ||
| Use: "terminator", | ||
| Short: "FGA terminator for account workspaces", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| kcpCfg, err := getKubeconfigFromPath(terminatorCfg.KCP.Kubeconfig) | ||
| if err != nil { | ||
| log.Error().Err(err).Msg("unable to get KCP kubeconfig") | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| mgrOpts := ctrl.Options{ | ||
| Scheme: scheme, | ||
| LeaderElection: defaultCfg.LeaderElection.Enabled, | ||
| LeaderElectionID: "security-operator-terminator.platform-mesh.io", | ||
| HealthProbeBindAddress: defaultCfg.HealthProbeBindAddress, | ||
| Metrics: server.Options{ | ||
| BindAddress: defaultCfg.Metrics.BindAddress, | ||
| TLSOpts: []func(*tls.Config){ | ||
| func(c *tls.Config) { | ||
| log.Info().Msg("disabling http/2") | ||
| c.NextProtos = []string{"http/1.1"} | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| if defaultCfg.LeaderElection.Enabled { | ||
| inClusterCfg, err := rest.InClusterConfig() | ||
| if err != nil { | ||
| log.Error().Err(err).Msg("unable to create in-cluster config") | ||
| return err | ||
| } | ||
| mgrOpts.LeaderElectionConfig = inClusterCfg | ||
| } | ||
|
|
||
| mcc, err := mcclient.New(kcpCfg, client.Options{Scheme: scheme}) | ||
| if err != nil { | ||
| log.Error().Err(err).Msg("Failed to create multicluster client") | ||
| os.Exit(1) | ||
| } | ||
| rootClient, err := iclient.NewForLogicalCluster(kcpCfg, scheme, logicalcluster.Name("root")) | ||
| if err != nil { | ||
| log.Error().Err(err).Msgf("Failed to get root client") | ||
| os.Exit(1) | ||
| } | ||
| var wt kcptenancyv1alphav1.WorkspaceType | ||
| if err := rootClient.Get(cmd.Context(), client.ObjectKey{ | ||
| Name: terminatorCfg.WorkspaceTypeName, | ||
| }, &wt); err != nil { | ||
| log.Error().Err(err).Msgf("Failed to get WorkspaceType %s", terminatorCfg.WorkspaceTypeName) | ||
| os.Exit(1) | ||
| } | ||
| if len(wt.Status.VirtualWorkspaces) == 0 { | ||
| log.Error().Err(err).Msgf("No VirtualWorkspaces found in WorkspaceType %s", terminatorCfg.WorkspaceTypeName) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| virtualWorkspaceCfg := rest.CopyConfig(kcpCfg) | ||
| virtualWorkspaceCfg.Host = wt.Status.VirtualWorkspaces[0].URL | ||
| log.Info().Msgf("Created config with %s host", virtualWorkspaceCfg.Host) | ||
|
|
||
| provider, err := terminatingworkspaces.New(kcpCfg, initializerCfg.WorkspaceTypeName, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have a terminatorCfg? or do the initializer / terminator share the same config structure, possibly then rename it to avoid confusion |
||
| terminatingworkspaces.Options{ | ||
| Scheme: mgrOpts.Scheme, | ||
| }, | ||
| ) | ||
|
|
||
| mgr, err := mcmanager.New(kcpCfg, provider, mgrOpts) | ||
| if err != nil { | ||
| log.Error().Err(err).Msg("Failed to create manager") | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| conn, err := grpc.NewClient(terminatorCfg.FGA.Target, grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
| if err != nil { | ||
| log.Error().Err(err).Msg("unable to create grpc client") | ||
| os.Exit(1) | ||
| } | ||
| fga := openfgav1.NewOpenFGAServiceClient(conn) | ||
|
|
||
| if err := controller.NewAccountLogicalClusterReconciler(log, terminatorCfg, fga, mcc, mgr). | ||
| SetupWithManager(mgr, defaultCfg, predicate.Not(predicates.LogicalClusterIsAccountTypeOrg())); err != nil { | ||
| log.Error().Err(err).Msg("Unable to create AccountLogicalClusterTerminator") | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { | ||
| log.Error().Err(err).Msg("unable to set up health check") | ||
| os.Exit(1) | ||
| } | ||
| if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { | ||
| log.Error().Err(err).Msg("unable to set up ready check") | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| setupLog.Info("starting manager") | ||
|
|
||
| return mgr.Start(ctrl.SetupSignalHandler()) | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| rootCmd.AddCommand(terminatorCmd) | ||
|
|
||
| terminatorV := viper.NewWithOptions( | ||
| viper.EnvKeyReplacer(strings.NewReplacer("-", "_")), | ||
| ) | ||
| terminatorV.AutomaticEnv() | ||
| if err := platformeshconfig.BindConfigToFlags(terminatorV, terminatorCmd, &terminatorCfg); err != nil { | ||
| panic(err) | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed, the terminatingWorkspaceProvider should determine the vws url based on the workspace type name