Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code generator for Go #249

Merged
merged 4 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ All notable changes to this project will be documented in this file based on the
* Add fields `source.address`, `destination.address`, `client.address`, and
`server.address`. #247
* Add `os.full` to capture full OS name, including version. #259
* Add generated source code for Go. #249

### Improvements
* Improved the definition of the file fields #196
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ clean:
# Clean all markdown files for use-cases
find ./use-cases -type f -name '*.md' -not -name 'README.md' -print0 | xargs -0 rm --

# Alias to generate source code for all languages.
.PHONY: codegen
codegen: gocodegen

# Build schema.csv from schema files.
.PHONY: csv
csv: ve
Expand Down Expand Up @@ -66,7 +70,17 @@ fmt: ve

# Alias to generate everything.
.PHONY: generate
generate: csv readme template fields
generate: csv readme template fields codegen

# Generate Go code from the schema.
.PHONY: gocodegen
gocodegen:
find code/go/ecs -name '*.go' -not -name 'doc.go' | xargs rm
cd scripts \
&& $(FORCE_GO_MODULES) go run cmd/gocodegen/gocodegen.go \
-version=$(VERSION) \
-schema=../schemas \
-out=../code/go/ecs

# Check Makefile format.
.PHONY: makelint
Expand Down
6 changes: 6 additions & 0 deletions code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated Source Code

This directory contains source code that is generated from the Elastic Common
Schema (ECS).

- [Go](go/ecs/)
8 changes: 8 additions & 0 deletions code/go/ecs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Go - Generated Source Code

[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs]

[godocs]: http://godoc.org/github.com/elastic/ecs/code/go/ecs

This package contains Go source code that is generated from the Elastic Common
Schema (ECS).
52 changes: 52 additions & 0 deletions code/go/ecs/agent.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions code/go/ecs/base.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions code/go/ecs/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions code/go/ecs/cloud.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions code/go/ecs/container.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions code/go/ecs/destination.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions code/go/ecs/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

// Package ecs contains source code that is generated from the Elastic Common
// Schema (ECS).
//
// https://github.com/elastic/ecs#elastic-common-schema-ecs
package ecs
Loading