-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GET ClusterFederatedTrustDomain API (#542)
* removed handlers Signed-off-by: Maia Iyer <[email protected]> * nit spacing fixes Signed-off-by: Maia Iyer <[email protected]> * Nits Signed-off-by: Maia Iyer <[email protected]> * added plugin config parsing Signed-off-by: Maia Iyer <[email protected]> * Nits Signed-off-by: Maia Iyer <[email protected]> * Initialize Package Signed-off-by: Maia Iyer <[email protected]> * added documentation Signed-off-by: Maia Iyer <[email protected]> * nit lint Signed-off-by: Maia Iyer <[email protected]> * nit Signed-off-by: Maia Iyer <[email protected]> * nit lints Signed-off-by: Maia Iyer <[email protected]> * fix key length check Signed-off-by: Maia Iyer <[email protected]> * add list federation function to crd pkg Signed-off-by: Maia Iyer <[email protected]> * initial function handlers added Signed-off-by: Maia Iyer <[email protected]> * nit Signed-off-by: Maia Iyer <[email protected]> * move types to pkg Signed-off-by: Maia Iyer <[email protected]> * initial crd list attempt Signed-off-by: Maia Iyer <[email protected]> * nit case Signed-off-by: Maia Iyer <[email protected]> * try printing individual crds Signed-off-by: Maia Iyer <[email protected]> * Indexing into spec Signed-off-by: Maia Iyer <[email protected]> * Added parsing code and refactored Signed-off-by: Maia Iyer <[email protected]> * return result value Signed-off-by: Maia Iyer <[email protected]> * Adding API documentation Signed-off-by: Maia Iyer <[email protected]> * Removing print statements Signed-off-by: Maia Iyer <[email protected]> * Added Documentation Signed-off-by: Maia Iyer <[email protected]> * Linted Markdown Signed-off-by: Maia Iyer <[email protected]> * nits Signed-off-by: Maia Iyer <[email protected]> --------- Signed-off-by: Maia Iyer <[email protected]>
- Loading branch information
Showing
12 changed files
with
575 additions
and
102 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
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,59 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"net/http" | ||
"strings" | ||
|
||
crdmanager "github.com/spiffe/tornjak/pkg/agent/spirecrd" | ||
) | ||
|
||
func (s *Server) CRDFederationList(w http.ResponseWriter, r *http.Request) { | ||
// if CRD management not configured | ||
if s.CRDManager == nil { | ||
emsg := "Error: CRD Manager not configured on Tornjak." | ||
retError(w, emsg, http.StatusBadRequest) | ||
return | ||
} | ||
// if CRD management is configured | ||
var input crdmanager.ListFederationRelationshipsRequest | ||
buf := new(strings.Builder) | ||
|
||
n, err := io.Copy(buf, r.Body) | ||
if err != nil { | ||
emsg := fmt.Sprintf("Error parsing data: %v", err.Error()) | ||
retError(w, emsg, http.StatusBadRequest) | ||
return | ||
} | ||
data := buf.String() | ||
|
||
if n == 0 { | ||
input = crdmanager.ListFederationRelationshipsRequest{} | ||
} else { | ||
err := json.Unmarshal([]byte(data), &input) | ||
if err != nil { | ||
emsg := fmt.Sprintf("Error parsing data: %v", err.Error()) | ||
retError(w, emsg, http.StatusBadRequest) | ||
return | ||
} | ||
} | ||
|
||
ret, err := s.CRDManager.ListClusterFederatedTrustDomains(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet | ||
if err != nil { | ||
emsg := fmt.Sprintf("Error: %v", err.Error()) | ||
retError(w, emsg, http.StatusInternalServerError) | ||
return | ||
} | ||
|
||
cors(w, r) | ||
je := json.NewEncoder(w) | ||
err = je.Encode(ret) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet | ||
if err != nil { | ||
emsg := fmt.Sprintf("Error: %v", err.Error()) | ||
retError(w, emsg, http.StatusBadRequest) | ||
return | ||
} | ||
|
||
} |
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
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
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
Oops, something went wrong.