package cmd import ( "log" "github.com/spf13/cobra" "libre.sh/scim/pkg/supplier" ) var applyCmd = &cobra.Command{ Use: "apply", Short: "Wire everything according to the config", Run: func(cmd *cobra.Command, args []string) { ctx := cmd.Context() config, err := GetConfig() CheckErr(err) kc := supplier.NewKeycloakSupplier(config.Client.Host, config.Client.Realm, config.Client.Username, config.Client.Password) sp, err := supplier.NewServiceProviderSupplier(string(config.Provider.Type), config.Provider.ServiceProviderConfig) CheckErr(err) err = supplier.Reconcile(ctx, sp, kc) CheckErr(err) log.Println("service provider is ready") // managers := []manager.Manager{} // if viper.IsSet("rocketchat") { // m := manager.NewRocketChat(viper.GetString("rocketchat.host"), viper.GetString("rocketchat.username"), viper.GetString("rocketchat.password")) // managers = append(managers, m) // } // for _, m := range managers { // } // end := make(chan struct{}) // go func() { // println("ctx start") // i := 0 // for { // select { // case <-ctx.Done(): // println("ctx done") // end <- struct{}{} // return // default: // if i == 20 { // println("finished") // end <- struct{}{} // return // } // println(i) // i++ // time.Sleep(time.Second) // } // } // }() // <-end }, } func init() { rootCmd.AddCommand(applyCmd) }