-
Notifications
You must be signed in to change notification settings - Fork 542
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
feat: support return the manager api's git hash and version #1408
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4e813bb
feat: support feat info (#1404)
starsz 696ba5d
update: feat info
starsz b61a3b9
update: fix ci
starsz b22303d
update: change the api to /version
starsz 28d44bd
Merge branch 'fork_master' into feat_info
starsz b4b2d8f
update: dockerfile
starsz 5f3b9d1
update: ci
starsz fce0446
Merge branch 'fork_master' into feat_info
starsz 92b2a40
Merge branch 'fork_master' into feat_info
starsz 4eb7171
Merge branch 'fork_master' into feat_info
starsz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package tool | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/shiningrush/droplet" | ||
wgin "github.com/shiningrush/droplet/wrapper/gin" | ||
|
||
"github.com/apisix/manager-api/internal/handler" | ||
"github.com/apisix/manager-api/internal/utils" | ||
) | ||
|
||
type Handler struct { | ||
} | ||
|
||
type InfoOutput struct { | ||
Hash string `json:"commit_hash"` | ||
Version string `json:"version"` | ||
} | ||
|
||
func NewHandler() (handler.RouteRegister, error) { | ||
return &Handler{}, nil | ||
} | ||
|
||
func (h *Handler) ApplyRoute(r *gin.Engine) { | ||
r.GET("/version", wgin.Wraps(h.Version)) | ||
} | ||
|
||
func (h *Handler) Version(_ droplet.Context) (interface{}, error) { | ||
hash, version := utils.GetHashAndVersion() | ||
return &InfoOutput{ | ||
Hash: hash, | ||
Version: version, | ||
juzhiyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, nil | ||
} |
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,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package tool | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/shiningrush/droplet" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/apisix/manager-api/internal/utils" | ||
) | ||
|
||
func TestInfo_Get(t *testing.T) { | ||
h := Handler{} | ||
ctx := droplet.NewContext() | ||
|
||
hash, version := utils.GetHashAndVersion() | ||
|
||
ret, err := h.Version(ctx) | ||
assert.Nil(t, err) | ||
assert.Equal(t, &InfoOutput{ | ||
Hash: hash, | ||
Version: version, | ||
}, ret) | ||
} |
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,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package utils | ||
|
||
var ( | ||
gitHash string | ||
starsz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
version string | ||
) | ||
|
||
// get the hash and version | ||
func GetHashAndVersion() (string, string) { | ||
return gitHash, version | ||
} |
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,39 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package e2e | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestInfo(t *testing.T) { | ||
tests := []HttpTestCase{ | ||
{ | ||
Desc: "get info", | ||
Object: ManagerApiExpect(t), | ||
Method: http.MethodGet, | ||
Path: "/version", | ||
ExpectStatus: http.StatusOK, | ||
ExpectBody: []string{"commit_hash", "\"version\""}, | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
testCaseCheck(tc, t) | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@starsz @nic-chen
This will lead to 2 kinds of APIs:
/apisix/admin/xxx
/version
When we deprecate
admin-api
in V3, we will have to omit that prefixapisix/admin
either, to have ManagerAPIs.Now FE meets one issue: because HTTP call is handled by UmiJS, which only supports one prefix,
/apisix/admin
or/
, then FE has to make hack codes to be compatible with those 2 kinds of APIs.I know it's wired to have something like
/apisix/admin/version
, but could we add a prefix for this API first? with some description about this hacking case. In V3, we may omit that prefix from all APIs.cc @LiteSun
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.Got it.
I will add the prefix and ignore this API's auth checking in the next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need to omit the prefix, but unification is appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!!