Skip to content

Commit

Permalink
Refactor into pkg and cmd dirs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgiles committed May 29, 2018
1 parent 0c3a4c5 commit 7dcd14b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion main.go → cmd/vault-plugin-secrets-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/hashicorp/vault/helper/pluginutil"
"github.com/hashicorp/vault/logical/plugin"
"github.com/paxos-bankchain/vault-plugin-secrets-kubernetes/pkg/backend"
)

func main() {
Expand All @@ -17,7 +18,7 @@ func main() {
tlsProviderFunc := pluginutil.VaultPluginTLSProvider(tlsConfig)

if err := plugin.Serve(&plugin.ServeOpts{
BackendFactoryFunc: Factory,
BackendFactoryFunc: backend.Factory,
TLSProviderFunc: tlsProviderFunc,
}); err != nil {
log.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion backend.go → pkg/backend/backend.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package backend

import (
"context"
Expand Down
4 changes: 1 addition & 3 deletions backend_test.go → pkg/backend/backend_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package backend

import (
"bytes"
Expand Down Expand Up @@ -79,7 +79,6 @@ func reviewToken(t *testing.T, url, token, bearer string) (int, authv1.TokenRevi
},
})
require.NoError(t, err, "err encoding json")
// fmt.Println("sending request: ", string(buf))
req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(buf))
require.NoError(t, err, "err creating http request")
req.Header.Add("Content-Type", "application/json")
Expand All @@ -93,7 +92,6 @@ func reviewToken(t *testing.T, url, token, bearer string) (int, authv1.TokenRevi
require.NoError(t, err, "err making http request")
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
// fmt.Println("received response: ", string(body))
var respReview authv1.TokenReview
decodeErr := json.Unmarshal(body, &respReview)
return resp.StatusCode, respReview.Status, decodeErr
Expand Down
2 changes: 1 addition & 1 deletion path_roles.go → pkg/backend/path_roles.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package backend

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion path_token.go → pkg/backend/path_token.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package backend

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions path_tokenreviews.go → pkg/backend/path_tokenreviews.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package backend

import (
"context"
Expand Down Expand Up @@ -94,7 +94,7 @@ func reviewResponseErr(code int, err string) (*logical.Response, error) {
})
}

// reviewResponseDeny packages an error response for Kubernetes.
// reviewResponseDeny packages a deny response for Kubernetes.
func reviewResponseDeny(reason string) (*logical.Response, error) {
// Deny. HTTP code is OK, because we're not actually denying the review request -
// just saying that the apiserver should deny the client.
Expand Down
2 changes: 1 addition & 1 deletion secret_token.go → pkg/backend/secret_token.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package backend

import (
"context"
Expand Down

0 comments on commit 7dcd14b

Please sign in to comment.