Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] apply fieldalignment #37312

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/opampsupervisor/supervisor/commander/commander.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
// for the Agent process to finish.
type Commander struct {
logger *zap.Logger
cfg config.Agent
logsDir string
args []string
cmd *exec.Cmd
doneCh chan struct{}
exitCh chan struct{}
running *atomic.Int64
logsDir string
args []string
cfg config.Agent
}

func NewCommander(logger *zap.Logger, logsDir string, cfg config.Agent, args ...string) (*Commander, error) {
Expand Down
8 changes: 4 additions & 4 deletions cmd/opampsupervisor/supervisor/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
// Supervisor is the Supervisor config file format.
type Supervisor struct {
Server OpAMPServer `mapstructure:"server"`
Agent Agent `mapstructure:"agent"`
Capabilities Capabilities `mapstructure:"capabilities"`
Storage Storage `mapstructure:"storage"`
Telemetry Telemetry `mapstructure:"telemetry"`
Agent Agent `mapstructure:"agent"`
Capabilities Capabilities `mapstructure:"capabilities"`
}

// Load loads the Supervisor config from a file.
Expand Down Expand Up @@ -162,9 +162,9 @@ func (o OpAMPServer) Validate() error {
}

type Agent struct {
Description AgentDescription `mapstructure:"description"`
Executable string `mapstructure:"executable"`
OrphanDetectionInterval time.Duration `mapstructure:"orphan_detection_interval"`
Description AgentDescription `mapstructure:"description"`
ConfigApplyTimeout time.Duration `mapstructure:"config_apply_timeout"`
BootstrapTimeout time.Duration `mapstructure:"bootstrap_timeout"`
HealthCheckPort int `mapstructure:"health_check_port"`
Expand Down Expand Up @@ -217,8 +217,8 @@ type Telemetry struct {
}

type Logs struct {
Level zapcore.Level `mapstructure:"level"`
OutputPaths []string `mapstructure:"output_paths"`
Level zapcore.Level `mapstructure:"level"`
Comment on lines 220 to +221
Copy link
Member

@dmitryax dmitryax Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this done by a tool? Looks like it simply orders the fields by the size, but it doesn't matter in this case. It should be 32 bits in both cases. Curious if it can be configured to avoid changing fields if it's unnecessary?

I'm a bit concerned because it's technically a public API-breaking change for someone initializing it as Logs{level, paths} even if it's an anti-pattern.

}

// DefaultSupervisor returns the default supervisor config
Expand Down
4 changes: 2 additions & 2 deletions cmd/opampsupervisor/supervisor/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
func TestValidate(t *testing.T) {
testCases := []struct {
name string
config Supervisor
expectedError string
config Supervisor
}{
{
name: "Valid filled out config",
Expand Down Expand Up @@ -514,8 +514,8 @@ func TestLoad(t *testing.T) {
require.NoError(t, err)

testCases := []struct {
desc string
testFunc func(t *testing.T)
desc string
}{
{
desc: "Minimal Config Supervisor",
Expand Down
5 changes: 2 additions & 3 deletions cmd/opampsupervisor/supervisor/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import (

// persistentState represents persistent state for the supervisor
type persistentState struct {
InstanceID uuid.UUID `yaml:"instance_id"`

// Path to the config file that the state should be saved to.
// This is not marshaled.
configPath string `yaml:"-"`
configPath string `yaml:"-"`
InstanceID uuid.UUID `yaml:"instance_id"`
}

func (p *persistentState) SetInstanceID(id uuid.UUID) error {
Expand Down
Loading