Skip to content

Commit

Permalink
refactor: dns/server package is now dns package
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed Dec 12, 2024
1 parent 30dd945 commit 004936b
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gowindows

import (
"github.com/d-strobel/gowindows/connection"
"github.com/d-strobel/gowindows/windows/dns/server"
"github.com/d-strobel/gowindows/windows/dns"
"github.com/d-strobel/gowindows/windows/local/accounts"
)

Expand All @@ -15,7 +15,7 @@ import (
type Client struct {
Connection connection.Connection
LocalAccounts *accounts.Client
DnsServer *server.Client
Dns *dns.Client
}

// NewClient returns a new instance of the Client object, initialized with the provided configuration.
Expand All @@ -28,7 +28,7 @@ func NewClient(conn connection.Connection) *Client {

// Build the client with the subpackages.
c.LocalAccounts = accounts.NewClient(c.Connection)
c.DnsServer = server.NewClient(c.Connection)
c.Dns = dns.NewClient(c.Connection)

return c
}
Expand Down
12 changes: 6 additions & 6 deletions windows/dns/server/server.go → windows/dns/dns.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package server provides a Go library for handling Windows DNS Server.
// Package dns provides a Go library for handling Windows DNS Server.
// The functions are related to the Powershell dns server cmdlets provided by Windows.
// https://learn.microsoft.com/en-us/powershell/module/dnsserver/?view=windowsserver2022-ps
package server
package dns

import (
"context"
Expand All @@ -14,8 +14,8 @@ import (
"github.com/d-strobel/gowindows/parsing"
)

// server is a type constraint for the run function, ensuring it works with specific types.
type server interface {
// dns is a type constraint for the run function, ensuring it works with specific types.
type dns interface {
Zone | []Zone | recordObject | []recordObject
}

Expand Down Expand Up @@ -59,7 +59,7 @@ func NewClientWithParser(conn connection.Connection, parsing func(string) (strin

// run runs a PowerShell command against a Windows system, handles the command results,
// and unmarshals the output into a local object type.
func run[T server](ctx context.Context, c *Client, cmd string, l *T) error {
func run[T dns](ctx context.Context, c *Client, cmd string, d *T) error {
// Run the command
result, err := c.Connection.RunWithPowershell(ctx, cmd)
if err != nil {
Expand All @@ -81,7 +81,7 @@ func run[T server](ctx context.Context, c *Client, cmd string, l *T) error {
}

// Unmarshal stdout
if err = json.Unmarshal([]byte(result.StdOut), &l); err != nil {
if err = json.Unmarshal([]byte(result.StdOut), &d); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion windows/dns/server/record_a.go → windows/dns/record_a.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion windows/dns/server/zone.go → windows/dns/zone.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package dns

import (
"context"
Expand Down

0 comments on commit 004936b

Please sign in to comment.