Skip to content

Commit

Permalink
rename nBContractConfiguration to nodeBootstrapConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Devin Wong committed Apr 16, 2024
1 parent 664cedd commit ea5a8be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions pkg/nbcontracthelper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

type NBContractBuilder struct {
// NBContractConfiguration is the configuration object for the NBContract (Node Bootstrap Contract)
nBContractConfiguration *nbcontractv1.Configuration
// nodeBootstrapConfig is the configuration object for the NBContract (Node Bootstrap Contract)
nodeBootstrapConfig *nbcontractv1.Configuration
}

// Check and initialize each field if it is nil
Expand Down Expand Up @@ -38,28 +38,28 @@ func ensureConfigsNonNil(nBC *nbcontractv1.Configuration) {
initializeIfNil(&nBC.CustomSearchDomainConfig)
}

// Creates a new instance of NBContractBuilder and ensures all objects in nBContractConfiguration are non-nil
// Creates a new instance of NBContractBuilder and ensures all objects in nodeBootstrapConfig are non-nil
func NewNBContractBuilder() *NBContractBuilder {
nbc := &nbcontractv1.Configuration{}
ensureConfigsNonNil(nbc)
nBCB := &NBContractBuilder{nBContractConfiguration: nbc}
nBCB := &NBContractBuilder{nodeBootstrapConfig: nbc}
return nBCB
}

// Apply the configuration to the nbContractConfiguration object
// Apply the configuration to the nodeBootstrapConfig object
func (nBCB *NBContractBuilder) ApplyConfiguration(config *nbcontractv1.Configuration) {
if config == nil {
return
}

// Use deep copy to avoid modifying the original object 'config'
nBCB.deepCopy(config, nBCB.nBContractConfiguration)
ensureConfigsNonNil(nBCB.nBContractConfiguration)
nBCB.deepCopy(config, nBCB.nodeBootstrapConfig)
ensureConfigsNonNil(nBCB.nodeBootstrapConfig)
}

// Get the NBContractConfiguration object
func (nBCB *NBContractBuilder) GetNBContractConfiguration() *nbcontractv1.Configuration {
return nBCB.nBContractConfiguration
// Get the nodeBootstrapConfig object
func (nBCB *NBContractBuilder) GetNodeBootstrapConfig() *nbcontractv1.Configuration {
return nBCB.nodeBootstrapConfig
}

// Deep copy the source object to the destination object.
Expand Down
8 changes: 4 additions & 4 deletions pkg/nbcontracthelper/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestNewNBContractBuilder(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewNBContractBuilder().nBContractConfiguration; !reflect.DeepEqual(got, tt.want) {
if got := NewNBContractBuilder().nodeBootstrapConfig; !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewNBContractConfiguration() = %v, want %v", got, tt.want)
}
})
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestNBContractBuilder_ApplyConfiguration(t *testing.T) {
},
},
want: func() *nbcontractv1.Configuration {
tmpResult := NewNBContractBuilder().nBContractConfiguration
tmpResult := NewNBContractBuilder().nodeBootstrapConfig
tmpResult.AuthConfig.TargetCloud = "some-cloud"
tmpResult.LinuxAdminUsername = "testuser"
return tmpResult
Expand All @@ -109,7 +109,7 @@ func TestNBContractBuilder_ApplyConfiguration(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
builder := NewNBContractBuilder()
builder.ApplyConfiguration(tt.fields.nBContractConfiguration)
if got := builder.nBContractConfiguration; !reflect.DeepEqual(got, tt.want) {
if got := builder.nodeBootstrapConfig; !reflect.DeepEqual(got, tt.want) {
t.Errorf("ApplyConfiguration() = %v, want %v", got, tt.want)
}
})
Expand Down Expand Up @@ -197,7 +197,7 @@ func TestNBContractBuilder_deepCopy(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
nBCB := &NBContractBuilder{
nBContractConfiguration: &nbcontractv1.Configuration{},
nodeBootstrapConfig: &nbcontractv1.Configuration{},
}
nBCB.deepCopy(tt.args.src, tt.args.dst)
log.Printf("dst = %v, src %v", tt.args.dst, tt.args.src)
Expand Down

0 comments on commit ea5a8be

Please sign in to comment.