Skip to content

Unify receiver types #2004

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

Merged
merged 5 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cmd/generate-database/db/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func (f *Field) Stmt() string {

// IsScalar returns true if the field is a scalar column value from a joined table.
func (f *Field) IsScalar() bool {
return f.JoinConfig() != ""
return f.joinConfig() != ""
}

// IsIndirect returns true if the field is a scalar column value from a joined
Expand All @@ -318,7 +318,7 @@ func (f *Field) Column() string {

column := lex.SnakeCase(f.Name)

join := f.JoinConfig()
join := f.joinConfig()
if join != "" {
column = fmt.Sprintf("%s AS %s", join, column)
}
Expand Down Expand Up @@ -353,7 +353,7 @@ func (f *Field) SelectColumn(mapping *Mapping, primaryTable string) (string, err
}

var column string
join := f.JoinConfig()
join := f.joinConfig()
if join != "" {
column = join
} else {
Expand Down Expand Up @@ -419,7 +419,7 @@ func (f *Field) JoinClause(mapping *Mapping, table string) (string, error) {
return "", fmt.Errorf("Cannot join and leftjoin at the same time for field %q of struct %q", f.Name, mapping.Name)
}

join := f.JoinConfig()
join := f.joinConfig()
if f.Config.Get("leftjoin") != "" {
joinTemplate = strings.ReplaceAll(joinTemplate, "JOIN", "LEFT JOIN")
}
Expand Down Expand Up @@ -484,7 +484,7 @@ func (f *Field) InsertColumn(mapping *Mapping, primaryTable string, defs map[*as
}
}

table, _, ok := strings.Cut(f.JoinConfig(), ".")
table, _, ok := strings.Cut(f.joinConfig(), ".")
if !ok {
return "", "", fmt.Errorf("'join' tag of field %q of struct %q must be of form <table>.<column>", f.Name, mapping.Name)
}
Expand Down Expand Up @@ -523,7 +523,7 @@ func (f *Field) InsertColumn(mapping *Mapping, primaryTable string, defs map[*as
return column, value, nil
}

func (f Field) JoinConfig() string {
func (f *Field) joinConfig() string {
join := f.Config.Get("join")
if join == "" {
join = f.Config.Get("leftjoin")
Expand All @@ -533,7 +533,7 @@ func (f Field) JoinConfig() string {
}

// SQLConfig returns the table and column specified by the 'sql' config key, if present.
func (f Field) SQLConfig() (string, string, error) {
func (f *Field) SQLConfig() (string, string, error) {
where := f.Config.Get("sql")

if where == "" {
Expand All @@ -549,8 +549,8 @@ func (f Field) SQLConfig() (string, string, error) {
}

// ScalarTableColumn gets the table and column from the join configuration.
func (f Field) ScalarTableColumn() (string, string, error) {
join := f.JoinConfig()
func (f *Field) ScalarTableColumn() (string, string, error) {
join := f.joinConfig()

if join == "" {
return "", "", fmt.Errorf("Missing join config for field %q", f.Name)
Expand Down
4 changes: 2 additions & 2 deletions cmd/generate-database/db/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (s *Stmt) namesBy(buf *file.Buffer) error {
}

joins = append(joins, join)
column = field.JoinConfig()
column = field.joinConfig()
} else {
column = mapping.FieldColumnName(field.Name, tableName)
}
Expand Down Expand Up @@ -403,7 +403,7 @@ func (s *Stmt) id(buf *file.Buffer) error {

var column string
if field.IsScalar() {
column = field.JoinConfig()
column = field.joinConfig()

join, err := field.JoinClause(mapping, table)
joins = append(joins, join)
Expand Down
4 changes: 2 additions & 2 deletions internal/server/dns/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (d dnsHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
}

// Check access.
if !d.isAllowed(zone.Info, ip, r.IsTsig(), w.TsigStatus() == nil) {
if !isAllowed(zone.Info, ip, r.IsTsig(), w.TsigStatus() == nil) {
// On auth failure, return NXDOMAIN to avoid information leaks.
m := &dns.Msg{}
m.SetRcode(r, dns.RcodeNameError)
Expand Down Expand Up @@ -138,7 +138,7 @@ func (d dnsHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
}
}

func (d *dnsHandler) isAllowed(zone api.NetworkZone, ip string, tsig *dns.TSIG, tsigStatus bool) bool {
func isAllowed(zone api.NetworkZone, ip string, tsig *dns.TSIG, tsigStatus bool) bool {
type peer struct {
address string
key string
Expand Down
2 changes: 1 addition & 1 deletion internal/server/storage/drivers/driver_zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (d *zfs) Info() Info {
// ensureInitialDatasets creates missing initial datasets or configures existing ones with current policy.
// Accepts warnOnExistingPolicyApplyError argument, if true will warn rather than fail if applying current policy
// to an existing dataset fails.
func (d zfs) ensureInitialDatasets(warnOnExistingPolicyApplyError bool) error {
func (d *zfs) ensureInitialDatasets(warnOnExistingPolicyApplyError bool) error {
// Build the list of datasets to query.
datasets := []string{d.config["zfs.pool_name"]}
for _, entry := range d.initialDatasets() {
Expand Down
2 changes: 1 addition & 1 deletion shared/api/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (c *Instance) Writable() InstancePut {
// IsActive checks whether the instance state indicates the instance is active.
//
// API extension: instances.
func (c Instance) IsActive() bool {
func (c *Instance) IsActive() bool {
switch c.StatusCode {
case Stopped:
return false
Expand Down