Skip to content

Commit

Permalink
omitempty on some fields
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Sep 20, 2023
1 parent 850c994 commit 05ebd4f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions manifest/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
)

type ManifestInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Modules []ModulesInfo `json:"modules"`
ProtoFiles []*ProtoFileInfo `json:"proto_files"`
Name string `json:"name"`
Version string `json:"version"`
Modules []ModulesInfo `json:"modules"`
ProtoFiles []ProtoFileInfo `json:"proto_files"`
}

type ProtoFileInfo struct {
Expand All @@ -31,7 +31,7 @@ type ModulesInfo struct {
OutputType string `json:"output_type"`
UpdatePolicy *string `json:"update_policy,omitempty"`
InitialBlock uint64 `json:"initial_block"`
Documentation string `json:"documentation"`
Documentation *string `json:"documentation,omitempty"`
Hash string `json:"hash"`
}

Expand Down Expand Up @@ -80,11 +80,12 @@ func Info(manifestPath string) (*ManifestInfo, error) {
modInfo.UpdatePolicy = strPtr(v.KindStore.UpdatePolicy.Pretty())
default:
modInfo.Kind = "unknown"
modInfo.OutputType = "unknown"
}

modMeta := pkg.ModuleMeta[ix]
if modMeta != nil && modMeta.Doc != "" {
modInfo.Documentation = strings.Replace(modMeta.Doc, "\n", "\n ", -1)
modInfo.Documentation = strPtr(strings.Replace(modMeta.Doc, "\n", "\n ", -1))
}

inputs := make([]ModuleInput, 0, len(mod.Inputs))
Expand All @@ -104,6 +105,9 @@ func Info(manifestPath string) (*ManifestInfo, error) {
if v.Store.Mode > 0 {
inputInfo.Mode = strPtr(v.Store.Mode.Pretty())
}
default:
inputInfo.Type = "unknown"
inputInfo.Name = "unknown"
}

inputs = append(inputs, inputInfo)
Expand All @@ -113,9 +117,9 @@ func Info(manifestPath string) (*ManifestInfo, error) {
modules = append(modules, modInfo)
}

protoFiles := make([]*ProtoFileInfo, 0, len(pkg.ProtoFiles))
protoFiles := make([]ProtoFileInfo, 0, len(pkg.ProtoFiles))
for _, protoFile := range pkg.ProtoFiles {
protoFiles = append(protoFiles, &ProtoFileInfo{
protoFiles = append(protoFiles, ProtoFileInfo{
Name: protoFile.Name,
Package: protoFile.Package,
Dependencies: protoFile.Dependency,
Expand Down

0 comments on commit 05ebd4f

Please sign in to comment.