func (s *store) Get(name string, serial string) (*api.SecretRecord, error) {
	var loadedSecret *dao.SecretRecord
	var err error
	if serial == "" {
		loadedSecret, err = s.dao.GetLatestVersion(name)
	} else {
		serialInt, err := strconv.Atoi(serial)
		if err != nil {
			return nil, err
		}
		loadedSecret, err = s.dao.GetSecretRecord(name, int64(serialInt))
	}

	if err != nil {
		log.Errorf("Error getting secret record for: %s, %v", name, err)
		return nil, err
	}

	if loadedSecret == nil {
		return nil, fmt.Errorf("Secret with name '%s' not found", name)
	}

	secretRecord := &api.SecretRecord{
		Name:   loadedSecret.Name,
		Serial: loadedSecret.Serial,
		Active: loadedSecret.Active,
	}
	if !loadedSecret.Active {
		log.Debugf("Returning inactive secret; name: %s, serial: %d", secretRecord.Name, secretRecord.Serial)
		return secretRecord, nil
	}

	decryptedSecret, err := s.crypter.DecryptSecret(loadedSecret)
	if err != nil {
		log.Errorf("Error decrypting secret for: %s, %v", name, err)
		return nil, err
	}
	secretRecord.Payload = aws.StringValue(decryptedSecret)

	return secretRecord, nil
}
// Get gets a secret from the store
Get gets a secret from the store
// Get gets a secret from the store
func (s *store) Get(name string, serial string) (*api.SecretRecord, error) {
	var loadedSecret *dao.SecretRecord
	var err error
	if serial == "" {
		loadedSecret, err = s.dao.GetLatestVersion(name)
	} else {
		serialInt, err := strconv.Atoi(serial)
		if err != nil {
			return nil, err
		}
		loadedSecret, err = s.dao.GetSecretRecord(name, int64(serialInt))
	}
	if err != nil {
		log.Errorf("Error getting secret record for: %s, %v", name, err)
		return nil, err
	}
	if loadedSecret == nil {
		return nil, fmt.Errorf("Secret with name '%s' not found", name)
	}
	secretRecord := &api.SecretRecord{
		Name:   loadedSecret.Name,
		Serial: loadedSecret.Serial,
		Active: loadedSecret.Active,
	}
	if !loadedSecret.Active {
		log.Debugf("Returning inactive secret; name: %s, serial: %d", secretRecord.Name, secretRecord.Serial)
		return secretRecord, nil
	}
	decryptedSecret, err := s.crypter.DecryptSecret(loadedSecret)
	if err != nil {
		log.Errorf("Error decrypting secret for: %s, %v", name, err)
		return nil, err
	}
	secretRecord.Payload = aws.StringValue(decryptedSecret)
	return secretRecord, nil
}
func ( s * store ) Get ( name string , serial string ) ( * api . SecretRecord , error ) { var loadedSecret * dao . SecretRecord var err error if serial == " " { loadedSecret , err = s . dao . GetLatestVersion ( name ) } else { serialInt , err := strconv . Atoi ( serial ) if err != nil { return nil , err } loadedSecret , err = s . dao . GetSecretRecord ( name , int64 ( serialInt ) ) } if err != nil { log . Errorf ( " " , name , err ) return nil , err } if loadedSecret == nil { return nil , fmt . Errorf ( " " , name ) } secretRecord := & api . SecretRecord { Name : loadedSecret . Name , Serial : loadedSecret . Serial , Active : loadedSecret . Active , } if ! loadedSecret . Active { log . Debugf ( " " , secretRecord . Name , secretRecord . Serial ) return secretRecord , nil } decryptedSecret , err := s . crypter . DecryptSecret ( loadedSecret ) if err != nil { log . Errorf ( " " , name , err ) return nil , err } secretRecord . Payload = aws . StringValue ( decryptedSecret ) return secretRecord , nil }
Get gets a secret from the store
Get gets a secret from the store