Merge pull request #578 from samson4649/main
This commit is contained in:
commit
0d31ea08c3
|
@ -10,6 +10,7 @@
|
||||||
- Fixed spurious calls to setLastStateChangeToNow from ephemeral nodes [#566](https://github.com/juanfont/headscale/pull/566)
|
- Fixed spurious calls to setLastStateChangeToNow from ephemeral nodes [#566](https://github.com/juanfont/headscale/pull/566)
|
||||||
- Add command for moving nodes between namespaces [#362](https://github.com/juanfont/headscale/issues/362)
|
- Add command for moving nodes between namespaces [#362](https://github.com/juanfont/headscale/issues/362)
|
||||||
- Added more configuration parameters for OpenID Connect (scopes, free-form paramters, domain and user allowlist)
|
- Added more configuration parameters for OpenID Connect (scopes, free-form paramters, domain and user allowlist)
|
||||||
|
- Add --all (-a) flag to enable routes command [#360](https://github.com/juanfont/headscale/issues/360)
|
||||||
|
|
||||||
## 0.15.0 (2022-03-20)
|
## 0.15.0 (2022-03-20)
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ func init() {
|
||||||
enableRouteCmd.Flags().
|
enableRouteCmd.Flags().
|
||||||
StringSliceP("route", "r", []string{}, "List (or repeated flags) of routes to enable")
|
StringSliceP("route", "r", []string{}, "List (or repeated flags) of routes to enable")
|
||||||
enableRouteCmd.Flags().Uint64P("identifier", "i", 0, "Node identifier (ID)")
|
enableRouteCmd.Flags().Uint64P("identifier", "i", 0, "Node identifier (ID)")
|
||||||
|
enableRouteCmd.Flags().BoolP("all", "a", false, "All routes from host")
|
||||||
|
|
||||||
err = enableRouteCmd.MarkFlagRequired("identifier")
|
err = enableRouteCmd.MarkFlagRequired("identifier")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf(err.Error())
|
log.Fatalf(err.Error())
|
||||||
|
@ -125,7 +127,32 @@ omit the route you do not want to enable.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
routes, err := cmd.Flags().GetStringSlice("route")
|
ctx, client, conn, cancel := getHeadscaleCLIClient()
|
||||||
|
defer cancel()
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
var routes []string
|
||||||
|
|
||||||
|
isAll, _ := cmd.Flags().GetBool("all")
|
||||||
|
if isAll {
|
||||||
|
response, err := client.GetMachineRoute(ctx, &v1.GetMachineRouteRequest{
|
||||||
|
MachineId: machineID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
ErrorOutput(
|
||||||
|
err,
|
||||||
|
fmt.Sprintf(
|
||||||
|
"Cannot get machine routes: %s\n",
|
||||||
|
status.Convert(err).Message(),
|
||||||
|
),
|
||||||
|
output,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
routes = response.GetRoutes().GetAdvertisedRoutes()
|
||||||
|
} else {
|
||||||
|
routes, err = cmd.Flags().GetStringSlice("route")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrorOutput(
|
ErrorOutput(
|
||||||
err,
|
err,
|
||||||
|
@ -135,10 +162,7 @@ omit the route you do not want to enable.
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx, client, conn, cancel := getHeadscaleCLIClient()
|
|
||||||
defer cancel()
|
|
||||||
defer conn.Close()
|
|
||||||
|
|
||||||
request := &v1.EnableMachineRoutesRequest{
|
request := &v1.EnableMachineRoutesRequest{
|
||||||
MachineId: machineID,
|
MachineId: machineID,
|
||||||
|
|
|
@ -1076,6 +1076,35 @@ func (s *IntegrationCLITestSuite) TestRouteCommand() {
|
||||||
string(failEnableNonAdvertisedRoute),
|
string(failEnableNonAdvertisedRoute),
|
||||||
"route (route-machine) is not available on node",
|
"route (route-machine) is not available on node",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Enable all routes on host
|
||||||
|
enableAllRouteResult, err := ExecuteCommand(
|
||||||
|
&s.headscale,
|
||||||
|
[]string{
|
||||||
|
"headscale",
|
||||||
|
"routes",
|
||||||
|
"enable",
|
||||||
|
"--output",
|
||||||
|
"json",
|
||||||
|
"--identifier",
|
||||||
|
"0",
|
||||||
|
"--all",
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
var enableAllRoute v1.Routes
|
||||||
|
err = json.Unmarshal([]byte(enableAllRouteResult), &enableAllRoute)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
assert.Len(s.T(), enableAllRoute.AdvertisedRoutes, 2)
|
||||||
|
assert.Contains(s.T(), enableAllRoute.AdvertisedRoutes, "10.0.0.0/8")
|
||||||
|
assert.Contains(s.T(), enableAllRoute.AdvertisedRoutes, "192.168.1.0/24")
|
||||||
|
|
||||||
|
assert.Len(s.T(), enableAllRoute.EnabledRoutes, 2)
|
||||||
|
assert.Contains(s.T(), enableAllRoute.EnabledRoutes, "10.0.0.0/8")
|
||||||
|
assert.Contains(s.T(), enableAllRoute.EnabledRoutes, "192.168.1.0/24")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationCLITestSuite) TestApiKeyCommand() {
|
func (s *IntegrationCLITestSuite) TestApiKeyCommand() {
|
||||||
|
|
Loading…
Reference in New Issue