Skip to content

Commit

Permalink
VnetName check only on fleet-member-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
britaniar committed Nov 13, 2024
1 parent e7ebd08 commit 448fa35
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/utils/cloudconfig/azure/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func (cfg *CloudConfig) validate() error {
return fmt.Errorf("resource group is empty")
}

if cfg.VnetName == "" {
return fmt.Errorf("virtual network name is empty")
if cfg.UserAgent == "fleet-member-agent" && cfg.VnetName == "" {
return fmt.Errorf("vnet name is empty")
}

if cfg.VnetResourceGroup == "" {
Expand Down
8 changes: 5 additions & 3 deletions pkg/utils/cloudconfig/azure/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ func TestValidate(t *testing.T) {
"VnetName empty": {
config: &CloudConfig{
ARMClientConfig: azclient.ARMClientConfig{
Cloud: "c",
Cloud: "c",
UserAgent: "fleet-member-agent",
},
AzureAuthConfig: azclient.AzureAuthConfig{
UseManagedIdentityExtension: true,
Expand Down Expand Up @@ -559,8 +560,9 @@ func TestNewCloudConfigFromFile(t *testing.T) {
filePath: "./test/azure_valid_config.json",
wantConfig: &CloudConfig{
ARMClientConfig: azclient.ARMClientConfig{
Cloud: "AzurePublicCloud",
TenantID: "00000000-0000-0000-0000-000000000000",
Cloud: "AzurePublicCloud",
TenantID: "00000000-0000-0000-0000-000000000000",
UserAgent: "fleet-member-agent",
},
AzureAuthConfig: azclient.AzureAuthConfig{
UseManagedIdentityExtension: true,
Expand Down
1 change: 1 addition & 0 deletions pkg/utils/cloudconfig/azure/test/azure_valid_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"cloud": "AzurePublicCloud",
"userAgent": "fleet-member-agent",
"tenantId": "00000000-0000-0000-0000-000000000000",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"useManagedIdentityExtension": true,
Expand Down
1 change: 1 addition & 0 deletions test/e2e/azure_valid_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
config:
azureCloudConfig:
cloud: "AzurePublicCloud"
userAgent: "fleet-member-agent"
tenantId: "00000000-0000-0000-0000-000000000000"
subscriptionId: "00000000-0000-0000-0000-000000000000"
useManagedIdentityExtension: true
Expand Down

0 comments on commit 448fa35

Please sign in to comment.