github.com/opentofu/opentofu@v1.7.1/internal/cloud/backend_cli.go (about)

     1  // Copyright (c) The OpenTofu Authors
     2  // SPDX-License-Identifier: MPL-2.0
     3  // Copyright (c) 2023 HashiCorp, Inc.
     4  // SPDX-License-Identifier: MPL-2.0
     5  
     6  package cloud
     7  
     8  import (
     9  	"github.com/opentofu/opentofu/internal/backend"
    10  	"github.com/opentofu/opentofu/internal/command/jsonformat"
    11  )
    12  
    13  // CLIInit implements backend.CLI
    14  func (b *Cloud) CLIInit(opts *backend.CLIOpts) error {
    15  	if cli, ok := b.local.(backend.CLI); ok {
    16  		if err := cli.CLIInit(opts); err != nil {
    17  			return err
    18  		}
    19  	}
    20  
    21  	b.CLI = opts.CLI
    22  	b.CLIColor = opts.CLIColor
    23  	b.ContextOpts = opts.ContextOpts
    24  	b.runningInAutomation = opts.RunningInAutomation
    25  	b.input = opts.Input
    26  	b.renderer = &jsonformat.Renderer{
    27  		Streams:  opts.Streams,
    28  		Colorize: opts.CLIColor,
    29  	}
    30  
    31  	return nil
    32  }