Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SetupKey auto-groups property #460

Merged
merged 23 commits into from
Sep 11, 2022
Merged

Conversation

braginini
Copy link
Contributor

@braginini braginini commented Sep 9, 2022

Extend Management API to add support for setup keys auto-tagging feature that allows automatic groups assignment to peers that used the key.
This PR just adds the property to the setup key.

Works as the first feature MVP for this request #458 (comment)

@braginini braginini changed the title Add SetupKey auto-tagging Add SetupKey auto-groups property Sep 10, 2022
@braginini braginini marked this pull request as ready for review September 10, 2022 19:57
@braginini
Copy link
Contributor Author

Relates to
netbirdio/dashboard#75


func (h *SetupKeys) GetKeys(w http.ResponseWriter, r *http.Request) {
writeSuccess(w, key)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should call toResponseBody function before responding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeSuccess function does toResponseBody

func writeSuccess(w http.ResponseWriter, key *server.SetupKey) {
	w.WriteHeader(200)
	w.Header().Set("Content-Type", "application/json")
	err := json.NewEncoder(w).Encode(toResponseBody(key))
	if err != nil {
		http.Error(w, "failed handling request", http.StatusInternalServerError)
		return
	}
}


func (h *SetupKeys) GetKeys(w http.ResponseWriter, r *http.Request) {
writeSuccess(w, key)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should call toResponseBody function before responding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeSuccess function does toResponseBody

func writeSuccess(w http.ResponseWriter, key *server.SetupKey) {
	w.WriteHeader(200)
	w.Header().Set("Content-Type", "application/json")
	err := json.NewEncoder(w).Encode(toResponseBody(key))
	if err != nil {
		http.Error(w, "failed handling request", http.StatusInternalServerError)
		return
	}
}

management/server/http/setupkeys.go Show resolved Hide resolved
management/server/http/setupkeys.go Outdated Show resolved Hide resolved
management/server/http/setupkeys.go Outdated Show resolved Hide resolved
management/server/setupkey.go Show resolved Hide resolved
UsedTimes: key.UsedTimes,
LastUsed: key.LastUsed,
State: state,
AutoGroups: key.AutoGroups,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we consider returning []api.GroupMinimum?

@braginini braginini merged commit be7d829 into main Sep 11, 2022
@braginini braginini deleted the feature/setupkey-autotagging branch September 11, 2022 21:16
pulsastrix pushed a commit to pulsastrix/netbird that referenced this pull request Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants