Skip to content

Commit

Permalink
Refactor bootstrapped application config options (flyteorg#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
katrogan authored Dec 20, 2019
1 parent 9a25e38 commit b974afc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
4 changes: 4 additions & 0 deletions flyteadmin_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ server:
iss: "https://idp.com"
aud: "api://default"
idpUserInfoEndpoint: "/v1/userinfo"
thirdPartyConfig:
flyteClient:
clientId: yourPublicAppClientId
redirectUri: yourRegisteredLoginRedirectUri
flyteadmin:
runScheduler: false
roleNameKey: "iam.amazonaws.com/role"
Expand Down
13 changes: 7 additions & 6 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const SectionKey = "server"
//go:generate pflags ServerConfig --default-var=defaultServerConfig

type ServerConfig struct {
HTTPPort int `json:"httpPort" pflag:",On which http port to serve admin"`
GrpcPort int `json:"grpcPort" pflag:",On which grpc port to serve admin"`
GrpcServerReflection bool `json:"grpcServerReflection" pflag:",Enable GRPC Server Reflection"`
KubeConfig string `json:"kube-config" pflag:",Path to kubernetes client config file."`
Master string `json:"master" pflag:",The address of the Kubernetes API server."`
Security ServerSecurityOptions `json:"security"`
HTTPPort int `json:"httpPort" pflag:",On which http port to serve admin"`
GrpcPort int `json:"grpcPort" pflag:",On which grpc port to serve admin"`
GrpcServerReflection bool `json:"grpcServerReflection" pflag:",Enable GRPC Server Reflection"`
KubeConfig string `json:"kube-config" pflag:",Path to kubernetes client config file."`
Master string `json:"master" pflag:",The address of the Kubernetes API server."`
Security ServerSecurityOptions `json:"security"`
ThirdPartyConfig ThirdPartyConfigOptions `json:"thirdPartyConfig"`
}

type ServerSecurityOptions struct {
Expand Down
12 changes: 12 additions & 0 deletions pkg/config/third_party_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package config

// This struct encapsulates config options for bootstrapping various Flyte applications with config values
// For example, FlyteClientConfig contains application-specific values to initialize the config required by flyte client
type ThirdPartyConfigOptions struct {
FlyteClientConfig FlyteClientConfig `json:"flyteClient"`
}

type FlyteClientConfig struct {
ClientID string `json:"clientId" pflag:",public identifier for the app which handles authorization for a Flyte deployment"`
RedirectURI string `json:"redirectUri" pflag:",This is the callback uri registered with the app which handles authorization for a Flyte deployment"`
}
4 changes: 2 additions & 2 deletions pkg/rpc/config/flyte_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const (
func HandleFlyteCliConfigFunc(ctx context.Context, cfg *config.ServerConfig) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
configValues := map[string]string{
clientID: cfg.Security.Oauth.ClientID,
redirectURI: cfg.Security.Oauth.CallbackURL,
clientID: cfg.ThirdPartyConfig.FlyteClientConfig.ClientID,
redirectURI: cfg.ThirdPartyConfig.FlyteClientConfig.RedirectURI,
authMetadataKey: cfg.Security.Oauth.GrpcAuthorizationHeader,
}
configJSON, err := json.Marshal(configValues)
Expand Down
8 changes: 6 additions & 2 deletions pkg/rpc/config/flyte_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ func TestHandleFlyteCliConfigFunc(t *testing.T) {
handleFlyteCliConfigFunc := HandleFlyteCliConfigFunc(context.Background(), &config.ServerConfig{
Security: config.ServerSecurityOptions{
Oauth: authConfig.OAuthOptions{
ClientID: testClientID,
CallbackURL: testRedirectURI,
GrpcAuthorizationHeader: testAuthMetadataKey,
},
},
ThirdPartyConfig: config.ThirdPartyConfigOptions{
FlyteClientConfig: config.FlyteClientConfig{
ClientID: testClientID,
RedirectURI: testRedirectURI,
},
},
})

responseRecorder := httptest.NewRecorder()
Expand Down

0 comments on commit b974afc

Please sign in to comment.