Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateImportConfigFromIDs(pipelineRuleIDs []string) string
- func GenerateImportConfigFromResources(resources []string) string
- func GetConflictingFilePatternsWithRemoved() []string
- func ValidateAndExtractPipelineRuleIDs(workspacePath string, resources []string, config *ToolConfig) ([]string, error)
- func WriteConfigToFile(workspacePath, config, fileName string)
- type CommandContext
- func (ctx *CommandContext) CheckProviderVersion() error
- func (ctx *CommandContext) ExecuteCommand(command, actionName string) error
- func (ctx *CommandContext) ExecuteStandardFlow(planCmd, actionCmd string, resources []string) error
- func (ctx *CommandContext) GenerateTargetCommands(resources []string) (planCmd, actionCmd string)
- func (ctx *CommandContext) GetDropRuleResources() ([]string, error)
- func (ctx *CommandContext) InitializeCommand() error
- func (ctx *CommandContext) PrintCommands(planCmd, actionCmd string)
- func (ctx *CommandContext) PrintCommandsForResourceIDs()
- func (ctx *CommandContext) PromptForActionConfirmation() bool
- func (ctx *CommandContext) PromptForExecution() bool
- func (ctx *CommandContext) ValidateResults(resources []string)
- type CommandType
- type DropRuleInput
- type DropRuleResource
- type TerraformState
- type ToolConfig
Constants ¶
const ( TerraformToolName = "terraform" TofuToolName = "tofu" TerraformDisplay = "Terraform" OpenTofuDisplay = "OpenTofu" )
Tool names and display names
const ( MinRequiredVersion = "1.5" MinRemovedBlocksVersion = "1.7" )
Version requirements
const ( ProviderConfigFile = "provider.tf" ImportConfigFile = "imports.tf" RemovedBlocksFile = "removals.tf" PipelineCloudRulesFile = "pcrs.tf" )
File names
const ( SeparatorLength = 80 SeparatorChar = "=" )
UI constants
const ( ColorReset = "\033[0m" ColorBold = "\033[1m" ColorCyan = "\033[1;36m" ColorYellow = "\033[1;33m" )
ANSI color codes
const ( MigrationRecommendationsTitle = "IMPORTANT: CI/CD MIGRATION RECOMMENDATIONS" SuccessMessage = "✅ Local workspace setup completed successfully!" MigrationCompleteMessage = "Migration workspace prepared successfully! 🎉" AccountMismatchWarning = "⚠️ WARNING: ACCOUNT ID MISMATCH DETECTED" )
Messages
const ImportBlockTemplate = `import {
to = newrelic_pipeline_cloud_rule.%s
id = "%s"
}`
Import block template
const OptionalRegionEnvVar = "NEW_RELIC_REGION"
const ProviderConfigTemplate = `` /* 305-byte string literal not displayed */
Provider configuration template
const RemovedBlockTemplate = `removed {
from = newrelic_nrql_drop_rule.%s
lifecycle {
destroy = false
}
}`
Removed block template
Variables ¶
var Command = &cobra.Command{
Use: "migrate",
Short: "Commands to support migration of New Relic Resources for EOLs and more.",
}
var ConflictingFilePatterns = []string{ ".tfstate", ".tfstate.backup", ".terraform", ProviderConfigFile, ImportConfigFile, PipelineCloudRulesFile, }
File patterns for workspace validation (removed blocks file only included when needed)
var LoadingDots = []string{".", "..", "...", "...."}
Loading animation
var RequiredEnvVars = []string{"NEW_RELIC_ACCOUNT_ID", "NEW_RELIC_API_KEY"}
Environment variables
Functions ¶
func GenerateImportConfigFromIDs ¶ added in v0.106.0
func GenerateImportConfigFromResources ¶ added in v0.106.0
func GetConflictingFilePatternsWithRemoved ¶
func GetConflictingFilePatternsWithRemoved() []string
GetConflictingFilePatternsWithRemoved returns file patterns including removed blocks file
func ValidateAndExtractPipelineRuleIDs ¶ added in v0.106.0
func ValidateAndExtractPipelineRuleIDs(workspacePath string, resources []string, config *ToolConfig) ([]string, error)
func WriteConfigToFile ¶ added in v0.106.0
func WriteConfigToFile(workspacePath, config, fileName string)
Types ¶
type CommandContext ¶ added in v0.106.0
type CommandContext struct {
ToolConfig *ToolConfig
WorkspacePath string
SkipPrompts bool
CommandType CommandType
ResourceIDs []string
}
CommandContext holds shared context and configuration for commands
func NewCommandContext ¶ added in v0.106.0
func NewCommandContext(useTofu bool, workspacePath string, skipPrompts bool, cmdType CommandType, resourceIDs []string) (*CommandContext, error)
NewCommandContext creates and initializes a command context
func (*CommandContext) CheckProviderVersion ¶ added in v0.106.0
func (ctx *CommandContext) CheckProviderVersion() error
CheckProviderVersion validates New Relic provider version for update operations
func (*CommandContext) ExecuteCommand ¶ added in v0.106.0
func (ctx *CommandContext) ExecuteCommand(command, actionName string) error
ExecuteCommand runs a command with proper logging and immediate output display
func (*CommandContext) ExecuteStandardFlow ¶ added in v0.106.0
func (ctx *CommandContext) ExecuteStandardFlow(planCmd, actionCmd string, resources []string) error
ExecuteStandardFlow runs the standard plan->confirm->action workflow with improved UX
func (*CommandContext) GenerateTargetCommands ¶ added in v0.106.0
func (ctx *CommandContext) GenerateTargetCommands(resources []string) (planCmd, actionCmd string)
GenerateTargetCommands creates terraform commands with target flags This function validates resources and is used only for display purposes
func (*CommandContext) GetDropRuleResources ¶ added in v0.106.0
func (ctx *CommandContext) GetDropRuleResources() ([]string, error)
GetDropRuleResources retrieves NRQL drop rule resources from state
func (*CommandContext) InitializeCommand ¶ added in v0.106.0
func (ctx *CommandContext) InitializeCommand() error
InitializeCommand performs common initialization steps
func (*CommandContext) PrintCommands ¶ added in v0.106.0
func (ctx *CommandContext) PrintCommands(planCmd, actionCmd string)
PrintCommands displays generated commands to the user
func (*CommandContext) PrintCommandsForResourceIDs ¶ added in v0.106.0
func (ctx *CommandContext) PrintCommandsForResourceIDs()
PrintCommandsForResourceIDs displays commands for provided resource identifiers
func (*CommandContext) PromptForActionConfirmation ¶ added in v0.106.0
func (ctx *CommandContext) PromptForActionConfirmation() bool
PromptForActionConfirmation asks for confirmation before destructive actions
func (*CommandContext) PromptForExecution ¶ added in v0.106.0
func (ctx *CommandContext) PromptForExecution() bool
PromptForExecution asks user if they want to execute commands
func (*CommandContext) ValidateResults ¶ added in v0.106.0
func (ctx *CommandContext) ValidateResults(resources []string)
ValidateResults performs post-action validation based on command type
type CommandType ¶ added in v0.106.0
type CommandType int
CommandType represents the type of operation being performed
const ( CommandUpdate CommandType = iota CommandImport CommandDelist // Removed CommandDestroy since we use CommandDelist for safe state removal )
type DropRuleInput ¶
type DropRuleInput struct {
DropRuleResourceIDs []DropRuleResource `json:"drop_rule_resource_ids"`
}
DropRuleInput represents the input structure containing drop rule resources
type DropRuleResource ¶
type DropRuleResource struct {
Name string `json:"name"`
ID string `json:"id"`
PipelineCloudRuleEntityID string `json:"pipeline_cloud_rule_entity_id"`
}
DropRuleResource represents a single drop rule resource with its metadata
type TerraformState ¶ added in v0.106.0
type ToolConfig ¶
ToolConfig holds configuration for the Terraform/OpenTofu tool being used
Source Files
¶
- command.go
- command_nrql_drop_rules.go
- command_nrql_drop_rules_tf_destroy.go
- command_nrql_drop_rules_tf_importgen-ci.go
- command_nrql_drop_rules_tf_importgen.go
- command_nrql_drop_rules_tf_update.go
- tf_importgen_ci_constants.go
- tf_importgen_ci_generator.go
- tf_importgen_ci_terraform.go
- tf_importgen_ci_types.go
- tf_importgen_ci_ui.go
- tf_importgen_ci_validation.go
- tf_importgen_helpers.go