Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
52deb65
CP-48666: initialize a skeleton project for Go SDK
duobei Mar 29, 2024
526bb8a
CP-47347: Add mustache template for Enum Types
duobei Mar 29, 2024
2aa4255
CP-47351: generate Record and Ref Type Golang code for all classes
duobei Mar 29, 2024
49a22b0
CP-47348: generate Golang code of Enum Type for all classes
duobei Mar 29, 2024
96d045c
CP-47362: generate file headers
duobei Mar 29, 2024
612b73b
CP-48666: collect api errors
duobei Apr 8, 2024
2039c12
CP-47364: generate api messages and errors of Golang code
duobei Apr 8, 2024
dfc46a7
refactor: create an `Alcotest.testable` to check structure of generat…
duobei Apr 9, 2024
6717121
refactor: move `objects` and `session_id` from `Gen_go_helper` to `Co…
duobei Apr 9, 2024
b98a102
CP-48666: use dune rule to get the destination dir for the generated …
duobei Apr 10, 2024
a564280
CP-48666: generate all enums to a file
duobei Apr 11, 2024
3563bf8
refactor the way of getting enums
duobei Apr 12, 2024
f9cb499
CP-48666: refactor the JSON schema checking
duobei Apr 18, 2024
1351856
CP-48666: refactor `render_template` with an optional newline parameter
duobei Apr 18, 2024
25df1a8
Merge pull request #5540 from duobei/private/fezhan/CP-48666
duobei Apr 18, 2024
259b1e0
CP-47361: generate mustache template for deserialize and serialize f…
duobei Apr 30, 2024
e6c911c
CP-47358: Generate convert functions Go code
duobei Apr 30, 2024
c18a5f3
CP-48855: update templates (APIErrors, APIMessages, Record)
duobei Apr 30, 2024
12fcb25
CP-48855: adjust generated json for templates changed
duobei Apr 30, 2024
2c6b09f
CP-48855: add templates for option and APIVersions
duobei Apr 30, 2024
925f2de
CP-48855: render options
duobei Apr 30, 2024
2f01d79
CP-47355, CP-47360: generate mustache template for xapi data module c…
xueqingz Apr 22, 2024
0acbe2a
CP-47354: Generate messages functions Golang code for all classes
duobei Apr 24, 2024
644ce45
CP-47354: add unit tests for `func_name_suffix` and `string_of_ty_wit…
duobei May 6, 2024
5aa929b
CP-48855: render APIVersion
duobei Apr 30, 2024
e6c5e65
CP-48855: fix go lint var-naming warnings
duobei May 6, 2024
d4b74fa
Merge pull request #5606 from duobei/private/fezhan/CP-48855
duobei May 7, 2024
7f9cd71
Merge branch 'feature/go_sdk' into private/CP-48667
duobei May 7, 2024
8c685e1
fix `StringOfTyWithEnumsTest` after merged
duobei May 7, 2024
77762f4
CP-48855: it should be only one empty line at end of Go file
duobei May 8, 2024
ba0efb4
Merge pull request #5591 from duobei/private/CP-48667
duobei May 9, 2024
becc9e0
CP-47356: expose `published_release_for_param` and `compare_versions`…
duobei May 8, 2024
438c36b
CP-47358: Add unit tests for generating convert functions
duobei Apr 30, 2024
6370b36
CP-47355, CP-47360: generate mustache template for xapi data module c…
xueqingz Apr 22, 2024
f2b241e
CP-47354: Generate messages functions Golang code for all classes
duobei Apr 24, 2024
51f2e94
CP-47354: add unit tests for `func_name_suffix` and `string_of_ty_wit…
duobei May 6, 2024
0676c3c
CP-48855: update templates (APIErrors, APIMessages, Record)
duobei Apr 30, 2024
327260c
CP-48855: adjust generated json for templates changed
duobei Apr 30, 2024
3527346
CP-48855: add templates for option and APIVersions
duobei Apr 30, 2024
420c076
CP-48855: render options
duobei Apr 30, 2024
181d49d
CP-48855: render APIVersion
duobei Apr 30, 2024
e2a4919
CP-48855: remove go lint var-naming warnings
duobei May 11, 2024
663e386
Merge branch 'feature/go_sdk' into private/fezhan/CP-47358
duobei May 11, 2024
f7f2c6a
Merge pull request #5603 from duobei/private/fezhan/CP-47358
duobei May 11, 2024
bc18f0e
CP-47356: Support backwards capability for Go SDK
duobei May 11, 2024
ed99de9
CP-47361: generate mustache template for deserialize and serialize f…
duobei Apr 30, 2024
90b9cfc
CP-47358: Generate convert functions Go code
duobei Apr 30, 2024
29a64d2
CP-47358: Add unit tests for generating convert functions
duobei Apr 30, 2024
041fc68
CP-47354: Generate messages functions Golang code for all classes
duobei Apr 24, 2024
2e871a1
CP-47354: add unit tests for `func_name_suffix` and `string_of_ty_wit…
duobei May 6, 2024
f2c02d8
CP-48855: render options
duobei Apr 30, 2024
2e5635f
CP-48855: render APIVersion
duobei Apr 30, 2024
0c47b36
Merge branch 'feature/go_sdk' into private/fezhan/CP-47356
duobei May 14, 2024
a41f264
Merge pull request #5620 from duobei/private/fezhan/CP-47356
duobei May 14, 2024
22e7ffa
CP-47357: Add a Go JSON-RPC client file
xueqingz May 6, 2024
890ae8d
CP-47357: fix review issues
xueqingz May 14, 2024
a20df67
Merge pull request #5615 from xueqingz/private/xueqingz/CP-47357
xueqingz May 14, 2024
9ea67da
CP-47367 Add type checking for generated SDK Go files
acefei Apr 11, 2024
28f4ad8
Merge pull request #5630 from acefei/private/feis/CP-47367
xueqingz May 15, 2024
a3bff49
CP-49350: fix variable naming in Go SDK
duobei May 15, 2024
b7c65dc
Merge branch 'feature/go_sdk' into private/fezhan/CP-49350
duobei May 15, 2024
ce89f1e
Merge pull request #5628 from duobei/private/fezhan/CP-49350
duobei May 16, 2024
9ee34d4
Merge branch 'master' into feature/go_sdk
duobei May 16, 2024
e205457
Merge pull request #5634 from duobei/feature/go_sdk
duobei May 16, 2024
9439b25
Set up Github Action for go SDK component test (#5588)
acefei May 21, 2024
b5a2f96
Merge branch 'master' into private/mingl/merge_master_to_feature
minglumlu May 31, 2024
19ff555
Merge pull request #5663 from minglumlu/private/mingl/merge_master_to…
minglumlu May 31, 2024
5042fd9
Go SDK: Misc fixes for on-going component tests (#5661)
minglumlu May 31, 2024
beaaf1c
CP-47928: Add component test for Go SDK
xihuan-citrix May 21, 2024
ad3c5d1
Merge pull request #5648 from xihuan-citrix/private/xihuany/component…
xihuan-citrix Jun 3, 2024
18d17c4
CP-49768: Update GO SDK README file (#5671)
xueqingz Jun 5, 2024
b816e00
Merge branch 'master' into private/mingl/merge_master_to_feature
minglumlu Jun 11, 2024
cda63f2
Merge pull request #5678 from minglumlu/private/mingl/merge_master_to…
minglumlu Jun 11, 2024
0bc1a12
CP-49858: Fix phrasing in readme
minglumlu Jun 12, 2024
5eb7889
CP-49858: Add licence text on top of Go source files
minglumlu Jun 12, 2024
50cbe0f
CP-49858: Unit test: licence template variable
minglumlu Jun 12, 2024
7ac6afa
CP-49858: Remove template variables 'first' and 'is_session_id'
minglumlu Jun 12, 2024
cca5a6e
CP-49858: Unit test: Update for changes on template variables
minglumlu Jun 12, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/generate-and-build-sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
shell: bash
run: opam exec -- make sdk

- name: Run CI for SDKs
uses: ./.github/workflows/sdk-ci

- name: Store C SDK source
uses: actions/upload-artifact@v4
with:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/go-ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Run CI for Go SDK'
runs:
using: 'composite'
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.2'

- name: Lint for Go SDK
uses: golangci/golangci-lint-action@v4
with:
version: v1.57.2
working-directory: ${{ github.workspace }}/_build/install/default/xapi/sdk/go/src
args: --config=${{ github.workspace }}/.golangci.yml

- name: Run CI for Go SDK
shell: bash
run: |
cd ./ocaml/sdk-gen/component-test/
cp -r ${{ github.workspace }}/_build/install/default/xapi/sdk/go/src jsonrpc-client/go/goSDK
bash run-tests.sh
20 changes: 20 additions & 0 deletions .github/workflows/sdk-ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Run CI for Go SDK'
runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '^3.12'

- name: Install dependencies for JsonRPC Server
shell: bash
run: |
python -m pip install --upgrade pip
cd ./ocaml/sdk-gen/component-test/jsonrpc-server
pip install -r requirements.txt

- name: Run CI for Go SDK
uses: ./.github/workflows/go-ci

# Run other tests here
142 changes: 142 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
run:
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 3m

linters:
disable-all: true
enable:
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
- gosimple # specializes in simplifying a code
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # detects when assignments to existing variables are not used
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
- unused # checks for unused constants, variables, functions and types
- asasalint # checks for pass []any as any in variadic func(...any)
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- copyloopvar # detects places where loop variables are copied
- durationcheck # checks for two durations multiplied together
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- execinquery # checks query string in Query function which reads your Go src files and warning it finds
- exhaustive # checks exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forbidigo # forbids identifiers
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
- gochecknoinits # checks that no init functions are present in Go code
- gochecksumtype # checks exhaustiveness on Go "sum types"
- gocritic # provides diagnostics that check for bugs, performance and style issues
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
- gomnd # detects magic numbers
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
- intrange # finds places where for loops could make use of an integer range
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
- makezero # finds slice declarations with non-zero initial length
- mirror # reports wrong mirror patterns of bytes/strings usage
- musttag # enforces field tags in (un)marshaled structs
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
- noctx # finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
- perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
- predeclared # finds code that shadows one of Go's predeclared identifiers
- promlinter # checks Prometheus metrics naming via promlint
- protogetter # reports direct reads from proto message fields when getters should be used
- reassign # checks that package variables are not reassigned
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
- rowserrcheck # checks whether Err of rows is checked successfully
- sloglint # ensure consistent code style when using log/slog
- spancheck # checks for mistakes with OpenTelemetry/Census spans
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace
- gosmopolitan # reports certain i18n/l10n anti-patterns in your Go codebase
- importas # enforces consistent import aliases
- testableexamples # checks if examples are testable (have an expected output)
- testifylint # checks usage of github.com/stretchr/testify
- testpackage # makes you use a separate _test package
- decorder # checks declaration order and count of types, constants, variables and functions
- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- godox # detects FIXME, TODO and other comment keywords
- gci # controls golang package import order and makes it always deterministic
- tagalign # checks that struct tags are well aligned
- wrapcheck # checks that errors returned from external packages are wrapped
- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())


## disabled
#- tagliatelle # checks the struct tags
#- goconst # finds repeated strings that could be replaced by a constant
#- gochecknoglobals # checks that no global variables exist
#- gocyclo # computes and checks the cyclomatic complexity of functions
#- nestif # reports deeply nested if statements
#- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed
#- funlen # tool for detection of long functions
#- godot # checks if comments end in a period
#- stylecheck # is a replacement for golint
#- gocognit # computes and checks the cognitive complexity of functions
#- nakedret # finds naked returns in functions greater than a specified function length
#- lll # reports long lines
#- nonamedreturns # reports all named returns
#- cyclop # checks function and package cyclomatic complexity
#- dupl # tool for code clone detection
#- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
#- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
#- goheader # checks is file header matches to pattern
#- inamedparam # [great idea, but too strict, need to ignore a lot of cases by default] reports interfaces with unnamed method parameters
#- interfacebloat # checks the number of methods inside an interface
#- ireturn # accept interfaces, return concrete types
#- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
#- zerologlint # detects the wrong usage of zerolog that a user forgets to dispatch zerolog.Event
#- containedctx # detects struct contained context.Context field
#- contextcheck # [too many false positives] checks the function whether use a non-inherited context
#- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages
#- dupword # [useless without config] checks for duplicate words in the source code
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
#- goerr113 # [too strict] checks the errors handling expressions
#- gofmt # [replaced by goimports] checks whether code was gofmt-ed
#- grouper # analyzes expression groups
#- maintidx # measures the maintainability index of each function
#- misspell # [useless] finds commonly misspelled English words in comments
#- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
#- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test
#- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines

output:
# Sort results by the order defined in `sort-order`.
# Default: false
sort-results: true
# Order to use when sorting results.
# Require `sort-results` to `true`.
# Possible values: `file`, `linter`, and `severity`.
#
# If the severity values are inside the following list, they are ordered in this order:
# 1. error
# 2. warning
# 3. high
# 4. medium
# 5. low
# Either they are sorted alphabetically.
#
# Default: ["file"]
sort-order:
- linter
- severity
- file # filepath, line, and column.
# Show statistics per linter.
# Default: false
show-stats: true
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,26 @@ sdk:
ocaml/sdk-gen/c/gen_c_binding.exe \
ocaml/sdk-gen/csharp/gen_csharp_binding.exe \
ocaml/sdk-gen/java/main.exe \
ocaml/sdk-gen/powershell/gen_powershell_binding.exe
ocaml/sdk-gen/powershell/gen_powershell_binding.exe \
ocaml/sdk-gen/go/gen_go_binding.exe
dune build --profile=$(PROFILE) -f\
@ocaml/sdk-gen/c/generate \
@ocaml/sdk-gen/csharp/generate \
@ocaml/sdk-gen/java/generate \
@ocaml/sdk-gen/powershell/generate
@ocaml/sdk-gen/powershell/generate \
@ocaml/sdk-gen/go/generate
rm -rf $(XAPISDK)
mkdir -p $(XAPISDK)/c
mkdir -p $(XAPISDK)/csharp
mkdir -p $(XAPISDK)/java
mkdir -p $(XAPISDK)/powershell
mkdir -p $(XAPISDK)/python
mkdir -p $(XAPISDK)/go
cp -r _build/default/ocaml/sdk-gen/c/autogen/* $(XAPISDK)/c
cp -r _build/default/ocaml/sdk-gen/csharp/autogen/* $(XAPISDK)/csharp
cp -r _build/default/ocaml/sdk-gen/java/autogen/* $(XAPISDK)/java
cp -r _build/default/ocaml/sdk-gen/powershell/autogen/* $(XAPISDK)/powershell
cp -r _build/default/ocaml/sdk-gen/go/autogen/* $(XAPISDK)/go
cp scripts/examples/python/XenAPI/XenAPI.py $(XAPISDK)/python
sh ocaml/sdk-gen/windows-line-endings.sh $(XAPISDK)/csharp
sh ocaml/sdk-gen/windows-line-endings.sh $(XAPISDK)/powershell
Expand Down
4 changes: 2 additions & 2 deletions ocaml/sdk-gen/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# XenAPI Software Development Kit (SDK)

The SDK consists of five components, one for each of C, C#, Java, PowerShell,
The SDK consists of six components, one for each of C, C#, Go, Java, PowerShell,
and Python, exposing the individual XenAPI calls as first-class functions in the
target language.

The source code for the C, C#, Java, and PowerShell SDK is autogenerated from the
The source code for the C, C#, Go, Java, and PowerShell SDK is autogenerated from the
XenAPI's datamodel. The generation code is written in OCaml and is contained in
this directory.

Expand Down
Loading