예제 #1
0
// WatchIAM will receive notifications for changes in IAM files and update credentials when a read signal is received.
func WatchIAM(rf *roles_files.RolesFiles, watch_err_chan chan error) {
	err_chan := make(chan error)
	read_signal := make(chan bool)
	go rf.RolesWatch(err_chan, read_signal)
	e := "IAM watching set to true, waiting..."
	slog.SLog(syslog.LOG_NOTICE, e, true)
	for {
		select {
		case roles_watch_err := <-err_chan:
			watch_err_chan <- roles_watch_err
		case <-read_signal:
			e := "WatchIAM received a read signal"
			slog.SLog(syslog.LOG_NOTICE, e, true)
			assign_err := AssignCredentials(rf)
			if assign_err != nil {
				watch_err_chan <- assign_err
			}
		}
	}
}
예제 #2
0
// WatchIAMToConf will begin rf's RolesWatch method and wait to receive signals that new credentials
// are available to be assigned, which will then be safely copied to conf c.
func WatchIAMToConf(rf *roles_files.RolesFiles, c *conf.AWS_Conf, watch_err_chan chan error) {
	if rf == nil || c == nil {
		watch_err_chan <- errors.New("conf_iam.WatchIAMToConf: rf or c is nil")
		return
	}
	err_chan := make(chan error)
	read_signal := make(chan bool)
	go rf.RolesWatch(err_chan, read_signal)
	e := "IAM watching set to true, waiting..."
	log.Printf(e)
	for {
		select {
		case roles_watch_err := <-err_chan:
			watch_err_chan <- roles_watch_err
		case <-read_signal:
			e := "WatchIAM received a read signal"
			log.Printf(e)
			assign_err := AssignCredentialsToConf(rf, c)
			if assign_err != nil {
				watch_err_chan <- assign_err
			}
		}
	}
}