-
Notifications
You must be signed in to change notification settings - Fork 0
Development Patterns
Some notes on evolving development patterns
- the
cmdpackage contains all the commands - these should just be CLI interface behavior (although there are still some that have CLI and implementation mixed in) - the
ce-go/cepackage/library has all the implementations of calling CE Platform APIs as well as helper functions (including output helper functions)
To make a call to a CE Platform API from a command, this is the method signature to use:
// Get element instances
bodybytes, statuscode, curlcmd, err := ce.GetElementInstances(profilemap["base"], profilemap["auth"], args[0])
The Platform API implementation (in ce-go/ce repo) takes in information to create an HTTP call - the base URL + the Authorization Header, and any args necessary.
It returns the undecoded bytes of the HTTP call, the status code, the string that is the curl command, and any errors.
The cmd (in this repository) will do the unmarshaling of the raw bytes, using the status code to determine whether to show an error or continue output processing.
Implementing the API should be done in the ce-go/ce repo. Please also add a _test.go file or a test method to the existing file. Once implemented and committed, then the API method can be used within this repo.
To use the API in this cli repo, update the dependencies via dep to keep the external dependencies in sync: dep ensure -update
Use dep-style changelog as an example for adding to changelog, i.e. refer to issue or pr and categorize addition as a New Feature, Bug Fix, or Improvement