cloudfoundry/go-cfclient

Unable to set instances to 0 in app manifest

Closed this issue · 0 comments

Sometimes one would like to stop the app temporarily thereby setting instances to 0 in app manifest. However, since instances is of type uint with omit empty, setting to 0 excludes the attribute when sending to the V3 API.

type AppManifestProcess struct {
	Type                             AppProcessType     `yaml:"type,omitempty"`
	Command                          string             `yaml:"command,omitempty"`
	DiskQuota                        string             `yaml:"disk_quota,omitempty"`
	HealthCheckType                  AppHealthCheckType `yaml:"health-check-type,omitempty"`
	HealthCheckHTTPEndpoint          string             `yaml:"health-check-http-endpoint,omitempty"`
	HealthCheckInvocationTimeout     uint               `yaml:"health-check-invocation-timeout,omitempty"`
	Instances                        uint               `yaml:"instances,omitempty"`
	LogRateLimitPerSecond            string             `yaml:"log-rate-limit-per-second,omitempty"`
	Memory                           string             `yaml:"memory,omitempty"`
	Timeout                          uint               `yaml:"timeout,omitempty"`
	HealthCheckInterval              uint               `yaml:"health-check-interval,omitempty"`
	ReadinessHealthCheckType         string             `yaml:"readiness-health-check-type,omitempty"`
	ReadinessHealthCheckHttpEndpoint string             `yaml:"readiness-health-check-http-endpoint,omitempty"`
	ReadinessHealthInvocationTimeout uint               `yaml:"readiness-health-invocation-timeout,omitempty"`
	ReadinessHealthCheckInterval     uint               `yaml:"readiness-health-check-interval,omitempty"`
}

Better solution would be to remove omitempty or change it to a pointer. Changing it to a pointer would be preferred as removing omit empty would set the value to 0 every time if empty, when in fact the default value returned from the V3 API is 1 generally if no value is provided