func (s *store) Save(passedSecret *api.SecretRecord) (*api.SecretRecord, error) {
	// get latest revision, increment serial by 1
	latestSecret, err := s.dao.GetLatestVersion(passedSecret.Name)
	if err != nil {
		return nil, err
	}
	if latestSecret != nil {
		passedSecret.Serial = latestSecret.Serial + 1
	}

	newSecret := &dao.SecretRecord{
		Name:   passedSecret.Name,
		Serial: passedSecret.Serial,
		Active: passedSecret.Active,
	}

	_, err = s.crypter.EncryptSecret(newSecret, passedSecret.Payload)
	if err != nil {
		log.Errorf("Error encrypting secret record for: %s, %v", passedSecret.Name, err)
		return nil, err
	}
	err = s.dao.PutSecretRecord(newSecret)
	return passedSecret, err
}
// Save saves the secret into the store
Save saves the secret into the store
// Save saves the secret into the store
func (s *store) Save(passedSecret *api.SecretRecord) (*api.SecretRecord, error) {
	latestSecret, err := s.dao.GetLatestVersion(passedSecret.Name)
	if err != nil {
		return nil, err
	}
	if latestSecret != nil {
		passedSecret.Serial = latestSecret.Serial + 1
	}
	newSecret := &dao.SecretRecord{
		Name:   passedSecret.Name,
		Serial: passedSecret.Serial,
		Active: passedSecret.Active,
	}
	_, err = s.crypter.EncryptSecret(newSecret, passedSecret.Payload)
	if err != nil {
		log.Errorf("Error encrypting secret record for: %s, %v", passedSecret.Name, err)
		return nil, err
	}
	err = s.dao.PutSecretRecord(newSecret)
	return passedSecret, err
}
func ( s * store ) Save ( passedSecret * api . SecretRecord ) ( * api . SecretRecord , error ) { latestSecret , err := s . dao . GetLatestVersion ( passedSecret . Name ) if err != nil { return nil , err } if latestSecret != nil { passedSecret . Serial = latestSecret . Serial + 1 } newSecret := & dao . SecretRecord { Name : passedSecret . Name , Serial : passedSecret . Serial , Active : passedSecret . Active , } _ , err = s . crypter . EncryptSecret ( newSecret , passedSecret . Payload ) if err != nil { log . Errorf ( " " , passedSecret . Name , err ) return nil , err } err = s . dao . PutSecretRecord ( newSecret ) return passedSecret , err }
Save saves the secret into the store
Save saves the secret into the store
// get latest revision, increment serial by 1