func ToJSON(reader models.TagReader, tag *models.Tag) (*jsonschema.Tag, error) {
	newTagJSON := jsonschema.Tag{
		Name:          tag.Name,
		IgnoreAutoTag: tag.IgnoreAutoTag,
		CreatedAt:     json.JSONTime{Time: tag.CreatedAt.Timestamp},
		UpdatedAt:     json.JSONTime{Time: tag.UpdatedAt.Timestamp},
	}

	aliases, err := reader.GetAliases(tag.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting tag aliases: %v", err)
	}

	newTagJSON.Aliases = aliases

	image, err := reader.GetImage(tag.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting tag image: %v", err)
	}

	if len(image) > 0 {
		newTagJSON.Image = utils.GetBase64StringFromData(image)
	}

	parents, err := reader.FindByChildTagID(tag.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting parents: %v", err)
	}

	newTagJSON.Parents = GetNames(parents)

	return &newTagJSON, nil
}
// ToJSON converts a Tag object into its JSON equivalent.
ToJSON converts a Tag object into its JSON equivalent.
// ToJSON converts a Tag object into its JSON equivalent .
func ToJSON(reader models.TagReader, tag *models.Tag) (*jsonschema.Tag, error) {
	newTagJSON := jsonschema.Tag{
		Name:          tag.Name,
		IgnoreAutoTag: tag.IgnoreAutoTag,
		CreatedAt:     json.JSONTime{Time: tag.CreatedAt.Timestamp},
		UpdatedAt:     json.JSONTime{Time: tag.UpdatedAt.Timestamp},
	}
	aliases, err := reader.GetAliases(tag.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting tag aliases: %v", err)
	}
	newTagJSON.Aliases = aliases
	image, err := reader.GetImage(tag.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting tag image: %v", err)
	}
	if len(image) > 0 {
		newTagJSON.Image = utils.GetBase64StringFromData(image)
	}
	parents, err := reader.FindByChildTagID(tag.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting parents: %v", err)
	}
	newTagJSON.Parents = GetNames(parents)
	return &newTagJSON, nil
}
func ToJSON ( reader models . TagReader , tag * models . Tag ) ( * jsonschema . Tag , error ) { newTagJSON := jsonschema . Tag { Name : tag . Name , IgnoreAutoTag : tag . IgnoreAutoTag , CreatedAt : json . JSONTime { Time : tag . CreatedAt . Timestamp } , UpdatedAt : json . JSONTime { Time : tag . UpdatedAt . Timestamp } , } aliases , err := reader . GetAliases ( tag . ID ) if err != nil { return nil , fmt . Errorf ( " " , err ) } newTagJSON . Aliases = aliases image , err := reader . GetImage ( tag . ID ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if len ( image ) > 0 { newTagJSON . Image = utils . GetBase64StringFromData ( image ) } parents , err := reader . FindByChildTagID ( tag . ID ) if err != nil { return nil , fmt . Errorf ( " " , err ) } newTagJSON . Parents = GetNames ( parents ) return & newTagJSON , nil }
ToJSON converts a Tag object into its JSON equivalent.
ToJSON converts a Tag object into its JSON equivalent .