-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving folders around so structure is more readable
Signed-off-by: tyler-ball <[email protected]>
- Loading branch information
1 parent
3d9cf8f
commit e12d853
Showing
97 changed files
with
433 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'll add some doc about testing and development. I'll take the request as a really good suggestion. | ||
Thanks | ||
|
||
Basic ideas for adding an endpoint, assume you will repeat this process and each step multiple times: | ||
|
||
Design the data structures for a new end point | ||
|
||
Create go tests for each func. | ||
|
||
Write the go code. | ||
|
||
Add examples to exercise the functions in the chefapi_examples cookbook. | ||
|
||
Create go code to call the functions. See the files in go-chef/chef/examples/cmd. Many times extra setup is required. | ||
Create a shell script to call the go code. See the files in go-chef/chef/examples/bin. | ||
Write Inspec tests to verify the output. Be aware that go map output does not alway have consistent ordering. The matching regex structures are rarely fun to write. | ||
Commit the go-chef/chef (api client go code at least) changes to a branch and push to GitHub. The chefapi.rb recipe would need to be updated to pull from the correct repo. | ||
kitchen converge. - installs the code, spins up a chef server to test against | ||
kitchen login - run the /bin commands and iterate on fixing the code. Both cmd code and chef client code. kitchen converge will install cmd and bin file changes without committing and pushing to GitHub. Changes to the chef api client code need to be committed, pushed and kitchen converge run again to get the changes installed. | ||
While logged in to the virtual box image try adding "-tags" debug the bin command. Example | ||
go run -tags debug ${BASE}/../cmd/client/clients.go ${CHEFUSER} ${KEYFILE} ${CHEFORGANIZATIONURL} ${SSLBYPASS} will produce output that shows the real request body returned from the chef server. Note what you passed in and what you got back. Send updates for the documentation to https://github.com/chef/chef-web-docs | ||
After things work ok. Create an inspec test for the endpoint that calls the bin command for the endpoint. Run kitchen verify to run the full set of integration tests. | ||
Run cookstyle -a in the go-chef/chef/examples/chefapi_examples directory | ||
|
||
Run go fmt in the go-chef/chef directory | ||
|
||
See if any documentation needs to be updated, check to see if any of the scattered TODOs are now now. | ||
|
||
Commit and PR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
./chefapi_examples/files/default/go/src/chefapi_test/bin | ||
./chefapi_test/bin/ |
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
examples/chefapi_examples/files/default/go/src/chefapi_test/Testing.md
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...chefapi_examples/files/default/go/src/chefapi_test/cmd/association/association_cleanup.go
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
...s/chefapi_examples/files/default/go/src/chefapi_test/cmd/association/association_setup.go
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Global | ||
https://testhost | ||
|
||
## Organization specific | ||
https://testhost/organization/test/* |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
examples/chefapi_test/cmd/association/association_cleanup.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Test the go-chef/chef chef server api /organization/:org/user and /organization/:org/association_requests | ||
// endpoints against a live server | ||
// | ||
package main | ||
|
||
import ( | ||
"chefapi_test/testapi" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/go-chef/chef" | ||
) | ||
|
||
// main Exercise the chef server api | ||
func main() { | ||
client := testapi.Client() | ||
deleteUser(client, "usrinvite") | ||
deleteUser(client, "usr2invite") | ||
deleteUser(client, "usradd") | ||
} | ||
|
||
// deleteUser uses the chef server api to delete a single user | ||
func deleteUser(client *chef.Client, name string) (err error) { | ||
err = client.Users.Delete(name) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "Issue deleting org:", err) | ||
} | ||
return | ||
} |
56 changes: 56 additions & 0 deletions
56
examples/chefapi_test/cmd/association/association_setup.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// Test the go-chef/chef chef server api /organization/:org/user and /organization/:org/association_requests | ||
// endpoints against a live server | ||
// | ||
package main | ||
|
||
import ( | ||
"chefapi_test/testapi" | ||
"fmt" | ||
"github.com/go-chef/chef" | ||
"os" | ||
) | ||
|
||
// main Exercise the chef server api | ||
func main() { | ||
client := testapi.Client() | ||
|
||
// Create a user | ||
var usr chef.User | ||
usr = chef.User{UserName: "usrinvite", | ||
Email: "[email protected]", | ||
FirstName: "usr", | ||
LastName: "invite", | ||
DisplayName: "Userauth Fullname", | ||
Password: "Logn12ComplexPwd#", | ||
} | ||
createUser(client, usr) | ||
|
||
usr = chef.User{UserName: "usr2invite", | ||
Email: "[email protected]", | ||
FirstName: "usr22", | ||
LastName: "invite", | ||
DisplayName: "User22auth Fullname", | ||
Password: "Logn12ComplexPwd#", | ||
} | ||
createUser(client, usr) | ||
|
||
usr = chef.User{UserName: "usradd", | ||
Email: "[email protected]", | ||
FirstName: "usr", | ||
LastName: "add", | ||
DisplayName: "UserAdd Fullname", | ||
Password: "Logn12ComplexPwd#", | ||
} | ||
createUser(client, usr) | ||
|
||
} | ||
|
||
// createUser uses the chef server api to create a single user | ||
func createUser(client *chef.Client, user chef.User) chef.UserResult { | ||
usrResult, err := client.Users.Create(user) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "Issue creating user:", err) | ||
} | ||
return usrResult | ||
} |
Oops, something went wrong.