Skip to content

Commit

Permalink
windows cgo
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptisteFoy committed Oct 22, 2024
1 parent 7583384 commit 3de4c3d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
6 changes: 2 additions & 4 deletions pkg/fleet/internal/cdn/cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"context"
"errors"
"regexp"
"runtime"

"github.com/DataDog/datadog-agent/pkg/fleet/env"
)
Expand Down Expand Up @@ -42,13 +41,12 @@ type CDN interface {
// New creates a new CDN.
func New(env *env.Env, configDBPath string) (CDN, error) {
if !env.RemotePolicies {
return nil, nil
return newNoop()
}
if env.CDNLocalDirPath != "" {
return newLocal(env)
}
if !env.CDNEnabled && runtime.GOOS != "windows" {
// Windows can't use the direct CDN yet as it breaks the static binary build
if !env.CDNEnabled {
return newDirect(env, configDBPath)
}
return newRegular(env, configDBPath)
Expand Down
37 changes: 37 additions & 0 deletions pkg/fleet/internal/cdn/cdn_noop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package cdn

import (
"context"
)

type cdnNoop struct {
}

type configNoop struct{}

// newNoop creates a new noop CDN.
func newNoop() (CDN, error) {
return &cdnNoop{}, nil
}

// Get gets the configuration from the CDN.
func (c *cdnNoop) Get(_ context.Context, _ string) (Config, error) {
return &configNoop{}, nil
}

func (c *cdnNoop) Close() error {
return nil
}

func (c *configNoop) Version() string {
return ""
}

func (c *configNoop) Write(_ string) error {
return nil
}
4 changes: 1 addition & 3 deletions pkg/util/hostname/fqdn_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
package hostname

import (
"C"
"os"
"unsafe"

"golang.org/x/sys/windows"
)
Expand All @@ -23,7 +21,7 @@ func getSystemFQDN() (string, error) {
if err != nil {
return "", err
}
namestring := C.GoString((*C.char)(unsafe.Pointer(he.Name)))
namestring := windows.BytePtrToString(he.Name)

return namestring, nil
}

0 comments on commit 3de4c3d

Please sign in to comment.