-
Notifications
You must be signed in to change notification settings - Fork 39
PMM-5194 Tunnels #643
base: main
Are you sure you want to change the base?
PMM-5194 Tunnels #643
Changes from 6 commits
846ce69
84339b3
d8f4768
342a9ac
6975404
67ed674
f3dca60
b485550
070eb51
1bb12ec
c258bac
0657a77
ed86ae0
7f5a18e
18929c5
b8cbd17
ea2a2fb
a98489a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// pmm-managed | ||
// Copyright (C) 2017 Percona LLC | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
"gopkg.in/reform.v1" | ||
) | ||
|
||
//go:generate reform | ||
|
||
type TunnelType string | ||
|
||
const ( | ||
ConnectTunnelType TunnelType = "connect" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci-lint] reported by reviewdog 🐶 |
||
ListenTunnelType TunnelType = "listen" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci-lint] reported by reviewdog 🐶 |
||
) | ||
|
||
//reform:tunnels | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci-lint] reported by reviewdog 🐶 |
||
type Tunnel struct { | ||
TunnelID string `reform:"tunnel_id,pk"` | ||
TunnelType TunnelType `reform:"tunnel_type"` | ||
PMMAgentID string `reform:"pmm_agent_id"` | ||
ConnectPort uint16 `reform:"connect_port"` | ||
ListenPort uint16 `reform:"listen_port"` | ||
CreatedAt time.Time `reform:"created_at"` | ||
UpdatedAt time.Time `reform:"updated_at"` | ||
} | ||
|
||
// BeforeInsert implements reform.BeforeInserter interface. | ||
func (s *Tunnel) BeforeInsert() error { | ||
now := Now() | ||
s.CreatedAt = now | ||
s.UpdatedAt = now | ||
return nil | ||
} | ||
|
||
// BeforeUpdate implements reform.BeforeUpdater interface. | ||
func (s *Tunnel) BeforeUpdate() error { | ||
s.UpdatedAt = Now() | ||
return nil | ||
} | ||
|
||
// AfterFind implements reform.AfterFinder interface. | ||
func (s *Tunnel) AfterFind() error { | ||
s.CreatedAt = s.CreatedAt.UTC() | ||
s.UpdatedAt = s.UpdatedAt.UTC() | ||
return nil | ||
} | ||
|
||
// check interfaces | ||
var ( | ||
_ reform.BeforeInserter = (*Tunnel)(nil) | ||
_ reform.BeforeUpdater = (*Tunnel)(nil) | ||
_ reform.AfterFinder = (*Tunnel)(nil) | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// pmm-managed | ||
// Copyright (C) 2017 Percona LLC | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package channel |
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.
🚫 [golangci-lint] reported by reviewdog 🐶
exported type
TunnelType
should have comment or be unexported (golint)