ronantakizawa/codereview-bench huggingface dataset:
Repository: opentofu/opentofu
File: internal/tofu/node_provider_eval.go (Go)

Code before:
	"github.com/opentofu/opentofu/internal/addrs"
	"github.com/opentofu/opentofu/internal/providers"
	"github.com/opentofu/opentofu/internal/tfdiags"
)

// NodeEvalableProvider represents a provider during an "eval" walk.
// This special provider node type just initializes a provider and
// fetches its schema, without configuring it or otherwise interacting
// with it.
type NodeEvalableProvider struct {
	*NodeAbstractProvider
}

var _ GraphNodeExecutable = (*NodeEvalableProvider)(nil)

// GraphNodeExecutable
func (n *NodeEvalableProvider) Execute(ctx context.Context, evalCtx EvalContext, op walkOperation) (diags tfdiags.Diagnostics) {
	provider, err := evalCtx.InitProvider(ctx, n.Addr, addrs.NoKey)

	diags = diags.Append(err)
	initDiags := n.InitEvalableProvider(ctx, evalCtx, provider)
	return diags.Append(initDiags)
}

// InitEvalableProvider fetches its schema, builds it, and adds it
// to the context.
func (n *NodeEvalableProvider) InitEvalableProvider(ctx context.Context, evalCtx EvalContext, provider providers.Interface) tfdiags.Diagnostics {
	providerKey := addrs.NoKey
	config := n.ProviderConfig()
	configBody := buildProviderConfig(ctx, evalCtx, n.Addr, config)

	schemaResp := provider.GetProviderSchema(ctx)
	return schemaResp.Diagnostics.InConfigBody(configBody, n.Addr.InstanceString(providerKey))
}


Review comment (performance):
```suggestion
// to the schema cache.
```
If I understand this correctly, this is what it does.

Code after:
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package tofu

import (
	"context"

	"github.com/opentofu/opentofu/internal/addrs"
	"github.com/opentofu/opentofu/internal/tfdiags"
)

// NodeEvalableProvider represents a provider during an "eval" walk.
// This special provider node type just initializes a provider and
// fetches its schema, without configuring it or otherwise interacting
// with it.
type NodeEvalableProvider struct {
	*NodeAbstractProvider
}

var _ GraphNodeExecutable = (*NodeEvalableProvider)(nil)

// GraphNodeExecutable
func (n *NodeEvalableProvider) Execute(ctx context.Context, evalCtx EvalContext, op walkOperation) (diags tfdiags.Diagnostics) {
	_, err := evalCtx.InitProvider(ctx, n.Addr, addrs.NoKey)
	return diags.Append(err)
}
Repository: opentofu/opentofu
File: internal/helper/slowmessage/slowmessage.go (Go)

Code before:
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package slowmessage

import (
	"log"
	"time"
)

// SlowFunc is the function that could be slow. Usually, you'll have to
// wrap an existing function in a lambda to make it match this type signature.
type SlowFunc func() error

// CallbackFunc is the function that is triggered when the threshold is reached.
type CallbackFunc func()

// Do calls sf. If threshold time has passed, cb is called. Note that this
// call will be made concurrently to sf still running.
func Do(threshold time.Duration, sf SlowFunc, cb CallbackFunc) error {
	log.Printf("[DEBUG] Do called with threshold: %v", threshold)
	// Call the slow function
	errCh := make(chan error, 1)
	go func() {
		errCh <- sf()
	}()

	// Wait for it to complete or the threshold to pass
	select {
	case err := <-errCh:
		return err
	case <-time.After(threshold):
		// Threshold reached, call the callback
		cb()
	}

	// Wait an indefinite amount of time for it to finally complete
	return <-errCh
}


Review comment (performance):
It's not really relevant to what this PR was about, but I was amused to notice this here because I recently wrote a very similar function elsewhere because I didn't realize we already had this one:

https://github.com/opentofu/opentofu/blob/af38729ab8750cea5465839ce2b2a1f226f7fdf4/internal/providercache/dir_modify.go#L188-L200

The two aren't quite interchangeable so I don't mean to say we ought to rush to consolidate them -- neither is very much code, after all -- but interesting to see the same problem solved in a very similar way in two places. 🤷‍♂️ 

Code after:
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package slowmessage

import (
	"time"
)

// SlowFunc is the function that could be slow. Usually, you'll have to
// wrap an existing function in a lambda to make it match this type signature.
type SlowFunc func() error

// CallbackFunc is the function that is triggered when the threshold is reached.
type CallbackFunc func()

// Do calls sf. If threshold time has passed, cb is called. Note that this
// call will be made concurrently to sf still running.
func Do(threshold time.Duration, sf SlowFunc, cb CallbackFunc) error {
	// Call the slow function
	errCh := make(chan error, 1)
	go func() {
		errCh <- sf()
	}()

	// Wait for it to complete or the threshold to pass
	select {
	case err := <-errCh:
		return err
	case <-time.After(threshold):
		// Threshold reached, call the callback
		cb()
	}

	// Wait an indefinite amount of time for it to finally complete
	return <-errCh
}
Repository: opentofu/opentofu
File: internal/command/testdata/statelocker.go (Go)

Code before:
		Path: os.Args[1],
	}

	info := statemgr.NewLockInfo()
	info.Operation = "test"
	info.Info = "state locker"

	lockID, err := s.Lock(context.Background(), info)
	if err != nil {
		io.WriteString(os.Stderr, err.Error()+"\n")
		return
	}

	// signal to the caller that we're locked
	_, err = io.WriteString(os.Stdout, "LOCKID "+lockID+"\n")

	defer func() {
		if err := s.Unlock(context.Background(), lockID); err != nil {
			io.WriteString(os.Stderr, err.Error()+"\n")
			return
		}
		io.WriteString(os.Stdout, "StateLocker: unlocked"+"\n")
	}()

	if err != nil {
		io.WriteString(os.Stderr, err.Error()+"\n")
		return
	}

	c := make(chan struct{})
	go waitForInput(c)

	// timeout after 10 second in case we don't get cleaned up by the test
	select {
	case <-time.After(10 * time.Second):
	case <-c:
	}
}

func waitForInput(resultChan chan struct{}) {
	// Attempt to read a line with a delimiter
	_, err := bufio.NewReader(os.Stdin).ReadString('\n')
	if err != nil {
		io.WriteString(os.Stderr, err.Error()+"\n")
	}
	resultChan <- struct{}{}
}


Review comment (suggestion):
Having this `if err != nil` so far away from the `io.WriteString` call that produced this `err` made it hard for me to read this code when I first looked at it.

If I'm understanding correctly, this `defer` statement is effectively a cleanup for the `s.Lock` call further up, rather than for printing the `LOCKID` line, so perhaps it would make sense to move the `defer` statement immediately after the lock was acquired (just before the `// signal to the caller that we're locked` comment) and then the error check for `io.WriteString` can appear immediately after that call.


Code after:
		Path: os.Args[1],
	}

	info := statemgr.NewLockInfo()
	info.Operation = "test"
	info.Info = "state locker"

	lockID, err := s.Lock(context.Background(), info)
	if err != nil {
		io.WriteString(os.Stderr, err.Error()+"\n")
		return
	}

	defer func() {
		if err := s.Unlock(context.Background(), lockID); err != nil {
			io.WriteString(os.Stderr, err.Error()+"\n")
			return
		}
	}()

	// signal to the caller that we're locked
	_, err = io.WriteString(os.Stdout, "LOCKID "+lockID+"\n")
	if err != nil {
		io.WriteString(os.Stderr, err.Error()+"\n")
		return
	}

	c := make(chan struct{})
	go waitForEOF(c)

	// timeout after 10 second in case we don't get cleaned up by the test
	select {
	case <-time.After(10 * time.Second):
	case <-c:
	}
}

func waitForEOF(resultChan chan struct{}) {
	_, err := io.ReadAll(os.Stdin)
	if err != nil {
		fmt.Errorf("on waiting for input: %s", err.Error())
	}

	close(resultChan)
}
Repository: opentofu/opentofu
File: internal/command/testdata/statelocker.go (Go)

Code before:
		}
		io.WriteString(os.Stdout, "StateLocker: unlocked"+"\n")
	}()

	if err != nil {
		io.WriteString(os.Stderr, err.Error()+"\n")
		return
	}

	c := make(chan struct{})
	go waitForInput(c)

	// timeout after 10 second in case we don't get cleaned up by the test
	select {
	case <-time.After(10 * time.Second):
	case <-c:
	}
}

func waitForInput(resultChan chan struct{}) {
	// Attempt to read a line with a delimiter
	_, err := bufio.NewReader(os.Stdin).ReadString('\n')
	if err != nil {
		io.WriteString(os.Stderr, err.Error()+"\n")
	}
	resultChan <- struct{}{}
}


Review comment (suggestion):
`close(resultChan)` would have the same effect here. Closing a channel is a typical pattern for signalling a "stop" condition, because it means that _all future_ reads from the channel will immediately return.

(Funnily enough, this is essentially the Go channels equivalent of the "close the pipe" recommendation I wrote in the comment above. Unbuffered channels are a lot like pipes. 😀 )


Code after:
	// signal to the caller that we're locked
	_, err = io.WriteString(os.Stdout, "LOCKID "+lockID+"\n")
	if err != nil {
		io.WriteString(os.Stderr, err.Error()+"\n")
		return
	}

	c := make(chan struct{})
	go waitForEOF(c)

	// timeout after 10 second in case we don't get cleaned up by the test
	select {
	case <-time.After(10 * time.Second):
	case <-c:
	}
}

func waitForEOF(resultChan chan struct{}) {
	_, err := io.ReadAll(os.Stdin)
	if err != nil {
		fmt.Errorf("on waiting for input: %s", err.Error())
	}

	close(resultChan)
}
Repository: opentofu/opentofu
File: internal/flock/filesystem_lock_windows.go (Go)

Code before:
				resultChan <- ctx.Err()
				return
			default:
				// LockFileEx returns this error when the lock is contended.
				var errno syscall.Errno
				ok := errors.As(err, &errno)
				if ok && errno == ERROR_LOCK_VIOLATION {
					// Chill for a bit before trying again
					time.Sleep(100 * time.Millisecond)
					continue
				}
				// All other errors are fatal.
				resultChan <- err
			}
		}
	}()

	return <-resultChan
}

func Unlock(*os.File) error {
	// the lock is released when Close() is called
	return nil
}

func lockFileEx(h syscall.Handle, flags, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) err error {
	r1, _, e1 := syscall.Syscall6(
		procLockFileEx.Addr(),
		6,
		uintptr(h),
		uintptr(flags),
		uintptr(reserved),
		uintptr(locklow),
		uintptr(lockhigh),
		uintptr(unsafe.Pointer(ol)),
	)
	if r1 == 0 {
		if e1 != 0 {
			err = error(e1)
		} else {
			err = syscall.EINVAL
		}
	}
	return
}

// newOverlapped creates a structure used to track asynchronous
// I/O requests that have been issued.
func newOverlapped() (*syscall.Overlapped, error) {
	event, err := createEvent(nil, true, false, nil)
	if err != nil {

Review comment (suggestion):
There's a syntax error in the declaration of `lockFileEx`. 

Code after:
				return
			default:
				// LockFileEx returns this error when the lock is contended.
				var errno syscall.Errno
				ok := errors.As(err, &errno)
				if ok && errno == ERROR_LOCK_VIOLATION {
					// Chill for a bit before trying again
					time.Sleep(100 * time.Millisecond)
					continue
				}
				// All other errors are fatal.
				resultChan <- err
			}
		}
	}()

	return <-resultChan
}

func Unlock(*os.File) error {
	// the lock is released when Close() is called
	return nil
}

func lockFileEx(h syscall.Handle, flags, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) {
	r1, _, e1 := syscall.Syscall6(
		procLockFileEx.Addr(),
		6,
		uintptr(h),
		uintptr(flags),
		uintptr(reserved),
		uintptr(locklow),
		uintptr(lockhigh),
		uintptr(unsafe.Pointer(ol)),
	)
	if r1 == 0 {
		if e1 != 0 {
			err = error(e1)
		} else {
			err = syscall.EINVAL
		}
	}
	return
}

// newOverlapped creates a structure used to track asynchronous
// I/O requests that have been issued.
func newOverlapped() (*syscall.Overlapped, error) {
	event, err := createEvent(nil, true, false, nil)
	if err != nil {
		return nil, err
Repository: opentofu/opentofu
File: internal/flock/filesystem_lock_test.go (Go)

Code before:
	lockFile := filepath.Join(tmpDir, "test.lock")

	// Create test file
	f, err := os.Create(lockFile)
	if err != nil {
		t.Fatalf("Failed to create test file: %v", err)
	}
	defer f.Close()

	// Test acquiring lock
	err = Lock(f)
	if err != nil {
		t.Fatalf("Failed to acquire lock: %v", err)
	}

	// Test unlocking
	err = Unlock(f)
	if err != nil {
		t.Fatalf("Failed to unlock: %v", err)
	}
}

func TestLock_Contention(t *testing.T) {
	// Tests back-to-back Lock calls on a single file

	tmpDir := t.TempDir()
	lockFile := filepath.Join(tmpDir, "contention.lock")

	// Create test file
	f1, err := os.OpenFile(lockFile, os.O_CREATE|os.O_RDWR, 0644)
	if err != nil {
		t.Fatalf("Failed to create test file: %v", err)
	}
	defer f1.Close()

	// Open same file with different handle to simulate multiple accessors
	f2, err := os.OpenFile(lockFile, os.O_RDWR, 0644)
	if err != nil {
		t.Fatalf("Failed to open test file: %v", err)
	}
	defer f2.Close()

	// First lock should always succeed regardless of OS
	err = Lock(f1)
	if err != nil {
		t.Fatalf("First lock should succeed: %v", err)
	}

	// Second lock behavior is OS-dependent due to different locking semantics:
	//
	// UNIX/Linux/macOS (fcntl-based):

Review comment (bug):
This test is breaking on Windows:

```
--- FAIL: TestLock_Contention (0.00s)
    filesystem_lock_test.go:90: Second lock failed as expected - true contention detected: The process cannot access the file because another process has locked a portion of the file.
    filesystem_lock_test.go:102: Second lock should succeed after first unlock: The process cannot access the file because another process has locked a portion of the file.
```

Code after:
	tmpDir := t.TempDir()
	lockFile := filepath.Join(tmpDir, "test.lock")

	// Create test file
	f, err := os.Create(lockFile)
	if err != nil {
		t.Fatalf("Failed to create test file: %v", err)
	}
	defer f.Close()

	// Test acquiring lock
	err = Lock(f)
	if err != nil {
		t.Fatalf("Failed to acquire lock: %v", err)
	}

	// Test unlocking
	err = Unlock(f)
	if err != nil {
		t.Fatalf("Failed to unlock: %v", err)
	}
}

func TestLock_Contention(t *testing.T) {
	// Tests back-to-back Lock calls on a single file

	tmpDir := t.TempDir()
	lockFile := filepath.Join(tmpDir, "contention.lock")

	// Create test file
	f1, err := os.OpenFile(lockFile, os.O_CREATE|os.O_RDWR, 0644)
	if err != nil {
		t.Fatalf("Failed to create test file: %v", err)
	}
	defer f1.Close()

	// Open same file with different handle to simulate multiple accessors
	f2, err := os.OpenFile(lockFile, os.O_RDWR, 0644)
	if err != nil {
		t.Fatalf("Failed to open test file: %v", err)
	}
	defer f2.Close()

	// First lock should always succeed regardless of OS
	err = Lock(f1)
	if err != nil {
		t.Fatalf("First lock should succeed: %v", err)
	}

	// Second lock behavior is OS-dependent due to different locking semantics:
	//
Repository: opentofu/opentofu
File: internal/flock/filesystem_lock_test.go (Go)

Code before:
	if err != nil {
		t.Fatalf("Failed to create test file: %v", err)
	}
	defer f.Close()

	ctx := context.Background()

	// Test blocking lock acquisition
	err = LockBlocking(ctx, f)
	if err != nil {
		t.Fatalf("Failed to acquire blocking lock: %v", err)
	}

	// Test unlocking
	err = Unlock(f)
	if err != nil {
		t.Fatalf("Failed to unlock: %v", err)
	}
}

func TestLockBlocking_Cancellation(t *testing.T) {
	// Tests cancellation of LockBlocking on a single file while a Lock is already in place
	// Doesn't really test anything in POSIX systems since the same process can hold multiple locks
	// on the same file

	tmpDir := t.TempDir()
	lockFile := filepath.Join(tmpDir, "cancel.lock")
	
	// Create test file
	f1, err := os.OpenFile(lockFile, os.O_CREATE|os.O_RDWR, 0644)
	if err != nil {
		t.Fatalf("Failed to create test file: %v", err)
	}
	defer f1.Close()

	f2, err := os.OpenFile(lockFile, os.O_RDWR, 0644)
	if err != nil {
		t.Fatalf("Failed to open test file: %v", err)
	}
	defer f2.Close()

	// First, test if this system supports real contention between same-process handles
	err = Lock(f1)
	if err != nil {
		t.Fatalf("Failed to acquire first lock: %v", err)
	}
	
	// Test if second lock fails
	testErr := Lock(f2)
	if testErr == nil {
		// Same process can acquire multiple locks - POSIX behavior

Review comment (refactor):
This test is breaking on Windows:

```
    filesystem_lock_test.go:200: System supports real contention between same-process handles
    filesystem_lock_test.go:221: Lock was properly cancelled: context deadline exceeded (took 202.3348ms)
    filesystem_lock_test.go:225: Cancellation took too long: 202.3348ms
```

Code after:
	// Create test file
	f, err := os.Create(lockFile)
	if err != nil {
		t.Fatalf("Failed to create test file: %v", err)
	}
	defer f.Close()

	ctx := context.Background()

	// Test blocking lock acquisition
	err = LockBlocking(ctx, f)
	if err != nil {
		t.Fatalf("Failed to acquire blocking lock: %v", err)
	}

	// Test unlocking
	err = Unlock(f)
	if err != nil {
		t.Fatalf("Failed to unlock: %v", err)
	}
}

func TestLockBlocking_Cancellation(t *testing.T) {
	// Tests cancellation of LockBlocking on a single file while a Lock is already in place
	// Doesn't really test anything in POSIX systems since the same process can hold multiple locks
	// on the same file

	tmpDir := t.TempDir()
	lockFile := filepath.Join(tmpDir, "cancel.lock")
	
	// Create test file
	f1, err := os.OpenFile(lockFile, os.O_CREATE|os.O_RDWR, 0644)
	if err != nil {
		t.Fatalf("Failed to create test file: %v", err)
	}
	defer f1.Close()

	f2, err := os.OpenFile(lockFile, os.O_RDWR, 0644)
	if err != nil {
		t.Fatalf("Failed to open test file with a second handler: %v", err)
	}
	defer f2.Close()

	// First, test if this system supports real contention between same-process handles
	err = Lock(f1)
	if err != nil {
		t.Fatalf("Failed to acquire first lock: %v", err)
	}
	
	// Test if second lock fails
	testErr := Lock(f2)
Repository: opentofu/opentofu
File: internal/tracing/traceattrs/semconv.go (Go)

Code before:
// version of the OpenTelemetry semantic conventions.
//
// This wraps [semconv.URLFull].
func URLFull(val string) attribute.KeyValue {
	return semconv.URLFull(val)
}

// FilePath returns an attribute representing an absolute file path associated
// with a trace span, using the attribute name defined by our currently-selected
// version of the OpenTelemetry semantic conventions.
//
// This wraps [semconv.FilePath].
func FilePath(val string) attribute.KeyValue {
	return semconv.FilePath(val)
}

// FileSize returns an attribute representing the size in bytes of a file
// associated with a trace span, using the attribute name defined by our
// currently-selected version of the OpenTelemetry semantic conventions.
//
// This wraps [semconv.FileSize].
func FileSize(val int) attribute.KeyValue {
	return semconv.FileSize(val)
}

// OCIManifiestDigest returns an attribute representing an OCI manifest
// digest associated with a trace span, using the attribute name defined
// by our currently-selected version of the OpenTelemetry semantic conventions.
//
// This wraps [semconv.OCIManifestDigest].
func OCIManifestDigest(digest string) attribute.KeyValue {
	return semconv.OCIManifestDigest(digest)
}


Review comment (suggestion):
```suggestion
// OCIManifestDigest returns an attribute representing an OCI manifest
```

Code after:
// version of the OpenTelemetry semantic conventions.
//
// This wraps [semconv.URLFull].
func URLFull(val string) attribute.KeyValue {
	return semconv.URLFull(val)
}

// FilePath returns an attribute representing an absolute file path associated
// with a trace span, using the attribute name defined by our currently-selected
// version of the OpenTelemetry semantic conventions.
//
// This wraps [semconv.FilePath].
func FilePath(val string) attribute.KeyValue {
	return semconv.FilePath(val)
}

// FileSize returns an attribute representing the size in bytes of a file
// associated with a trace span, using the attribute name defined by our
// currently-selected version of the OpenTelemetry semantic conventions.
//
// This wraps [semconv.FileSize].
func FileSize(val int) attribute.KeyValue {
	return semconv.FileSize(val)
}

// OCIManifestDigest returns an attribute representing an OCI manifest
// digest associated with a trace span, using the attribute name defined
// by our currently-selected version of the OpenTelemetry semantic conventions.
//
// This wraps [semconv.OCIManifestDigest].
func OCIManifestDigest(digest string) attribute.KeyValue {
	return semconv.OCIManifestDigest(digest)
}
Repository: opentofu/opentofu
File: internal/tofu/transform_module_expansion.go (Go)

Code before:
	if !ok {
		return nil
	}

	return child.find(addr)
}

// isNestedCheckDataSource returns true if the vertex represents a data source
// that is nested inside a check block. Such data sources are observational
// and should not participate in module dependency ordering.
func (t *ModuleExpansionTransformer) isNestedCheckDataSource(v dag.Vertex) bool {
	// Try to get the Config from various node types that embed NodeAbstractResource
	var config *configs.Resource

	switch n := v.(type) {
	case *NodeValidatableResource:
		config = n.Config
	case *nodeExpandPlannableResource:
		config = n.Config
	case *nodeExpandApplyableResource:
		config = n.Config
	case *NodePlannableResourceInstance:
		config = n.Config
	case *NodeApplyableResourceInstance:
		config = n.Config
	}

	if config != nil && config.Container != nil {
		_, isCheck := config.Container.(*configs.Check)
		return isCheck
	}

	return false
}


Review comment (suggestion):
Whilst I think this approach could work, I'm slightly worried about the possibilities for regressions in the future with new node types.

What do you think about checking if the node is a `GraphNodeConfigResource` (it should be in this case), and then once you have that you can check everything you need to. 

I think something similar to this may work: (Note my development env isn't working today, so this may need some tweaks!)

```go
func (t *ModuleExpansionTransformer) isNestedCheckDataSource(v dag.Vertex) bool {
    cfgNode, ok := v.(GraphNodeConfigResource)
    if !ok {
        return false
    }

    addr := cfgNode.ResourceAddr()
    if addr.Resource.Mode != addrs.DataResourceMode {
        return false
    }

    config := t.Config.Descendent(addr.Module)
    if config == nil {
        return false
    }

    resource := config.Module.DataResources[addr.Resource.String()]
    if resource != nil && resource.Container != nil {
        _, isCheck := resource.Container.(*configs.Check)
        return isCheck
    }

    return false
}
```

Code after:
	next, addr := addr[0], addr[1:]
	child, ok := t.children[next]
	if !ok {
		return nil
	}

	return child.find(addr)
}

// isNestedCheckDataSource returns true if the vertex represents a data source
// that is nested inside a check block. Such data sources are observational
// and should not participate in module dependency ordering.
func (t *ModuleExpansionTransformer) isNestedCheckDataSource(v dag.Vertex) bool {
	cfgNode, ok := v.(GraphNodeConfigResource)
	if !ok {
		return false
	}

	addr := cfgNode.ResourceAddr()
	if addr.Resource.Mode != addrs.DataResourceMode {
		return false
	}

	config := t.Config.Descendent(addr.Module)
	if config == nil {
		return false
	}

	resource := config.Module.DataResources[addr.Resource.String()]
	if resource != nil && resource.Container != nil {
		_, isCheck := resource.Container.(*configs.Check)
		return isCheck
	}

	return false
}