package tools

import (
	"fmt"
	"gitea.pena/PenaSide/common/privilege"
	"time"
)

func PublishPrivilege(privilegeController *privilege.Controller, count int, interval time.Duration) {
	for try := 0; try < count; try++ {
		err := privilegeController.PublishPrivileges()
		if err == nil {
			fmt.Println("Privileges published success")
			return
		}

		fmt.Printf("Failed to publish privileges (try %d): %v\n", try, err)

		time.Sleep(interval)
	}

	fmt.Println("Failed to publish privileges after all trys")
}
