Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Omnit value should be not included not be 0 #474

Closed
xrn opened this issue Jul 12, 2022 · 2 comments
Closed

Omnit value should be not included not be 0 #474

xrn opened this issue Jul 12, 2022 · 2 comments
Labels

Comments

@xrn
Copy link
Contributor

xrn commented Jul 12, 2022

My code for &opensearchservice.Domain{} do not sets

type Domain_SnapshotOptions struct {

	// AutomatedSnapshotStartHour AWS CloudFormation Property
	// Required: false
	// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-opensearchservice-domain-snapshotoptions.html#cfn-opensearchservice-domain-snapshotoptions-automatedsnapshotstarthour
	AutomatedSnapshotStartHour *int `json:"AutomatedSnapshotStartHour,omitempty"`

But generated yaml contains

SnapshotOptions:
        AutomatedSnapshotStartHour: 0

Which is incorrect

@rubenfonseca
Copy link
Contributor

Hi @xrn I tried to reproduce your code but with no success. Here's what I've tried:

package main

import (
	"fmt"

	"github.com/awslabs/goformation/v6/cloudformation"
	"github.com/awslabs/goformation/v6/cloudformation/opensearchservice"
)

func main() {
	template := cloudformation.NewTemplate()
	template.Resources["MyResource"] = &opensearchservice.Domain{
		SnapshotOptions: &opensearchservice.Domain_SnapshotOptions{},
	}

	result, err := template.YAML()
	if err != nil {
		panic(err)
	}

	fmt.Println(string(result))
}
AWSTemplateFormatVersion: 2010-09-09
Resources:
  MyResource:
    Properties:
      SnapshotOptions: {}
    Type: AWS::OpenSearchService::Domain

Can you please help us understand how to reproduce the bug?

@xrn
Copy link
Contributor Author

xrn commented Jul 18, 2022

It is my mistake, in a code I had

SnapshotOptions: &opensearchservice.Domain_SnapshotOptions{
			AutomatedSnapshotStartHour: cloudformation.Int(0),
		},

Look like in v5 0 was unnecessary omnited and in v6 is correctly added (I made compare between v5 and v6 results and got that this is added)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants