Skip to content

Commit

Permalink
Rename optional to option (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogaca-dd authored Dec 31, 2024
1 parent 658f6c4 commit 3711109
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions components/datadog/agent/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"path"

"github.com/DataDog/datadog-agent/pkg/util/optional"
"github.com/DataDog/datadog-agent/pkg/util/option"
"github.com/DataDog/test-infra-definitions/common/config"
"github.com/DataDog/test-infra-definitions/common/namer"
"github.com/DataDog/test-infra-definitions/common/utils"
Expand Down Expand Up @@ -257,7 +257,7 @@ func (h *HostAgent) writeFileDefinition(
fullPath string,
content string,
useSudo bool,
perms optional.Option[perms.FilePermissions],
perms option.Option[perms.FilePermissions],
opts ...pulumi.ResourceOption,
) (pulumi.Resource, error) {
// create directory, if it does not exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/DataDog/datadog-agent/pkg/util/optional"
"github.com/DataDog/datadog-agent/pkg/util/option"
"github.com/DataDog/test-infra-definitions/common"
)

Expand All @@ -21,13 +21,13 @@ type UnixPermissions struct {
var _ FilePermissions = (*UnixPermissions)(nil)

// NewUnixPermissions creates a new UnixPermissions object and applies the given options.
func NewUnixPermissions(options ...UnixPermissionsOption) optional.Option[FilePermissions] {
func NewUnixPermissions(options ...UnixPermissionsOption) option.Option[FilePermissions] {
p, err := common.ApplyOption(&UnixPermissions{}, options)

if err != nil {
panic("Could not create UnixPermissions: " + err.Error())
}
return optional.NewOption[FilePermissions](p)
return option.New[FilePermissions](p)
}

// SetupPermissionsCommand returns a command that sets the owner, group, and permissions of a file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/DataDog/datadog-agent/pkg/util/optional"
"github.com/DataDog/datadog-agent/pkg/util/option"
"github.com/DataDog/test-infra-definitions/common"
)

Expand All @@ -22,13 +22,13 @@ type WindowsPermissions struct {
var _ FilePermissions = (*WindowsPermissions)(nil)

// NewWindowsPermissions creates a new WindowsPermissions object and applies the given options.
func NewWindowsPermissions(options ...WindowsPermissionsOption) optional.Option[FilePermissions] {
func NewWindowsPermissions(options ...WindowsPermissionsOption) option.Option[FilePermissions] {
p, err := common.ApplyOption(&WindowsPermissions{}, options)

if err != nil {
panic("Could not create WindowsPermissions: " + err.Error())
}
return optional.NewOption[FilePermissions](p)
return option.New[FilePermissions](p)
}

// SetupPermissionsCommand returns a command that sets the permissions of a file. It relies on the icacls command.
Expand Down
8 changes: 4 additions & 4 deletions components/datadog/agentparams/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path"
"strings"

"github.com/DataDog/datadog-agent/pkg/util/optional"
"github.com/DataDog/datadog-agent/pkg/util/option"
"github.com/DataDog/test-infra-definitions/common"
"github.com/DataDog/test-infra-definitions/common/config"
"github.com/DataDog/test-infra-definitions/common/utils"
Expand Down Expand Up @@ -40,7 +40,7 @@ import (
type FileDefinition struct {
Content string
UseSudo bool
Permissions optional.Option[perms.FilePermissions]
Permissions option.Option[perms.FilePermissions]
}

type Params struct {
Expand Down Expand Up @@ -196,11 +196,11 @@ func WithIntegration(folderName string, content string) func(*Params) error {

// WithFile adds a file with contents to the install at the given path. This should only be used when the agent needs to be restarted after writing the file.
func WithFile(absolutePath string, content string, useSudo bool) func(*Params) error {
return WithFileWithPermissions(absolutePath, content, useSudo, optional.NewNoneOption[perms.FilePermissions]())
return WithFileWithPermissions(absolutePath, content, useSudo, option.None[perms.FilePermissions]())
}

// WithFileWithPermissions adds a file like WithFile but we can predefine the permissions of the file.
func WithFileWithPermissions(absolutePath string, content string, useSudo bool, perms optional.Option[perms.FilePermissions]) func(*Params) error {
func WithFileWithPermissions(absolutePath string, content string, useSudo bool, perms option.Option[perms.FilePermissions]) func(*Params) error {
return func(p *Params) error {
p.Files[absolutePath] = &FileDefinition{
Content: content,
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.5

require (
dario.cat/mergo v1.0.1
github.com/DataDog/datadog-agent/pkg/util/optional v0.59.1
github.com/DataDog/datadog-agent/pkg/util/option v0.0.0-20241218184455-8f3ec029ce57
github.com/Masterminds/semver v1.5.0
github.com/alessio/shellescape v1.4.2
github.com/aws/aws-sdk-go-v2 v1.32.7
Expand Down Expand Up @@ -70,7 +70,7 @@ require (
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/djherbis/times v1.6.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
Expand Down Expand Up @@ -105,11 +105,11 @@ require (
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.10.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/DataDog/datadog-agent/pkg/util/optional v0.59.1 h1:mw6zkzgGk4r83qxvEdIcwWME0P18oJlgW7QdpIKMHQI=
github.com/DataDog/datadog-agent/pkg/util/optional v0.59.1/go.mod h1:xWT/KJdJg2/0pZyAKZ6XmIiE5sM+AyUo4qvKuPHQ17U=
github.com/DataDog/datadog-agent/pkg/util/option v0.0.0-20241218184455-8f3ec029ce57 h1:nqYy5ad9fceRRw6oc8sJrSLgzK+rUUA9w/AoiIEfDqg=
github.com/DataDog/datadog-agent/pkg/util/option v0.0.0-20241218184455-8f3ec029ce57/go.mod h1:BECd5pnMX9MEnARCAV+S7M0Sk/gYwopL7QlhCFdXSI0=
github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM=
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
Expand Down Expand Up @@ -91,8 +91,9 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
Expand Down Expand Up @@ -198,8 +199,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/term v1.1.0 h1:xIAAdCMh3QIAy+5FrE8Ad8XoDhEU4ufwbaSozViP9kk=
github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 h1:vkHw5I/plNdTr435cARxCW6q9gc0S/Yxz7Mkd38pOb0=
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231/go.mod h1:murToZ2N9hNJzewjHBgfFdXhZKjY3z5cYC1VXk+lbFE=
github.com/pulumi/esc v0.10.0 h1:jzBKzkLVW0mePeanDRfqSQoCJ5yrkux0jIwAkUxpRKE=
Expand Down Expand Up @@ -244,8 +246,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
Expand Down

0 comments on commit 3711109

Please sign in to comment.