Skip to content

Commit

Permalink
chore: Small style + usability refactors for new contributors (#86)
Browse files Browse the repository at this point in the history
* Update skaffold.yaml

* Update fake assert statement, standardize casing

* NewAZClient calls NewAZClientFromAPI
  • Loading branch information
rakechill authored Jan 10, 2024
1 parent d0091a7 commit 8d9211c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pkg/fake/azureresourcegraphapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type AzureResourceGraphBehavior struct {
}

// assert that the fake implements the interface
var _ instance.AzureResourceGraphAPI = (*AzureResourceGraphAPI)(nil)
var _ instance.AzureResourceGraphAPI = &AzureResourceGraphAPI{}

type AzureResourceGraphAPI struct {
AzureResourceGraphBehavior
Expand Down
2 changes: 1 addition & 1 deletion pkg/fake/communityimageversionsapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type CommunityGalleryImageVersionsAPI struct {
}

// assert that the fake implements the interface
var _ imagefamily.CommunityGalleryImageVersionsAPI = (*CommunityGalleryImageVersionsAPI)(nil)
var _ imagefamily.CommunityGalleryImageVersionsAPI = &CommunityGalleryImageVersionsAPI{}

// NewListPager returns a new pager to return the next page of CommunityGalleryImageVersionsClientListResponse
func (c *CommunityGalleryImageVersionsAPI) NewListPager(_ string, _ string, _ string, _ *armcompute.CommunityGalleryImageVersionsClientListOptions) *runtime.Pager[armcompute.CommunityGalleryImageVersionsClientListResponse] {
Expand Down
2 changes: 1 addition & 1 deletion pkg/fake/networkinterfaceapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type NetworkInterfacesBehavior struct {
}

// assert that the fake implements the interface
var _ instance.NetworkInterfacesAPI = (*NetworkInterfacesAPI)(nil)
var _ instance.NetworkInterfacesAPI = &NetworkInterfacesAPI{}

type NetworkInterfacesAPI struct {
// instance.NetworkInterfacesAPI
Expand Down
3 changes: 3 additions & 0 deletions pkg/fake/pricingapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type PricingBehavior struct {
ProductsPricePage AtomicPtr[client.ProductsPricePage]
}

// assert that the fake implements the interface
var _ client.PricingAPI = &PricingAPI{}

func (p *PricingAPI) Reset() {
p.NextError.Reset()
p.ProductsPricePage.Reset()
Expand Down
2 changes: 1 addition & 1 deletion pkg/fake/virtualmachineextensionsapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type VirtualMachineExtensionsBehavior struct {
}

// assert that ComputeAPI implements ARMComputeAPI
var _ instance.VirtualMachineExtensionsAPI = (*VirtualMachineExtensionsAPI)(nil)
var _ instance.VirtualMachineExtensionsAPI = &VirtualMachineExtensionsAPI{}

type VirtualMachineExtensionsAPI struct {
// instance.VirtualMachineExtensionsAPI
Expand Down
2 changes: 1 addition & 1 deletion pkg/fake/virtualmachinesapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type VirtualMachinesBehavior struct {
}

// assert that the fake implements the interface
var _ instance.VirtualMachinesAPI = (*VirtualMachinesAPI)(nil)
var _ instance.VirtualMachinesAPI = &VirtualMachinesAPI{}

type VirtualMachinesAPI struct {
// TODO: document the implications of embedding vs. not embedding the interface here
Expand Down
6 changes: 3 additions & 3 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ type Operator struct {
}

func NewOperator(ctx context.Context, operator *operator.Operator) (context.Context, *Operator) {
azConfig, err := GetAzConfig()
azConfig, err := GetAZConfig()
lo.Must0(err, "creating Azure config") // TODO: I assume we prefer this over the cleaner azConfig := lo.Must(GetAzConfig()), as this has a helpful error message?

azClient, err := instance.CreateAzClient(ctx, azConfig)
azClient, err := instance.CreateAZClient(ctx, azConfig)
lo.Must0(err, "creating Azure client")

unavailableOfferingsCache := azurecache.NewUnavailableOfferings()
Expand Down Expand Up @@ -125,7 +125,7 @@ func NewOperator(ctx context.Context, operator *operator.Operator) (context.Cont
}
}

func GetAzConfig() (*auth.Config, error) {
func GetAZConfig() (*auth.Config, error) {
cfg, err := auth.BuildAzureConfig()
if err != nil {
return nil, err
Expand Down
21 changes: 9 additions & 12 deletions pkg/providers/instance/azure_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NewAZClientFromAPI(
}
}

func CreateAzClient(ctx context.Context, cfg *auth.Config) (*AZClient, error) {
func CreateAZClient(ctx context.Context, cfg *auth.Config) (*AZClient, error) {
// Defaulting env to Azure Public Cloud.
env := azure.PublicCloud
var err error
Expand Down Expand Up @@ -132,7 +132,7 @@ func NewAZClient(ctx context.Context, cfg *auth.Config, env *azure.Environment)
}

opts := armopts.DefaultArmOpts()
extClient, err := armcompute.NewVirtualMachineExtensionsClient(cfg.SubscriptionID, cred, opts)
extensionsClient, err := armcompute.NewVirtualMachineExtensionsClient(cfg.SubscriptionID, cred, opts)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -177,14 +177,11 @@ func NewAZClient(ctx context.Context, cfg *auth.Config, env *azure.Environment)
// TODO Move this over to track 2 when skewer is migrated
skuClient := skuclient.NewSkuClient(ctx, cfg, env)

return &AZClient{
networkInterfacesClient: interfacesClient,
virtualMachinesClient: virtualMachinesClient,
virtualMachinesExtensionClient: extClient,
azureResourceGraphClient: azureResourceGraphClient,

ImageVersionsClient: imageVersionsClient,
SKUClient: skuClient,
LoadBalancersClient: loadBalancersClient,
}, nil
return NewAZClientFromAPI(virtualMachinesClient,
azureResourceGraphClient,
extensionsClient,
interfacesClient,
loadBalancersClient,
imageVersionsClient,
skuClient), nil
}
20 changes: 10 additions & 10 deletions skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build:
paths:
- '**/*.go'
- '**/*.gtpl'
#flags: ['-tags', 'ccp']
#flags: ['-tags', 'ccp']
manifests:
helm:
releases:
Expand All @@ -29,10 +29,10 @@ manifests:
drift: true
azure:
clusterName: karpenter
clusterEndpoint: https://karpenter-tallaxes-azure-k-26fe00-j3imiwu5.hcp.westus2.staging.azmk8s.io:443
kubeletClientTLSBootstrapToken: "<updateme>" # TODO: get this from the cluster
clusterEndpoint: "Please run make az-all"
kubeletClientTLSBootstrapToken: "Please run make az-all" # TODO: get this from the cluster
# TODO: autogenerate
sshPublicKey: "<updateme>"
sshPublicKey: "Please run make az-all"
networkPlugin: "azure" # TODO: get this from the cluster
networkPolicy: ""
replicas: 1 # for better debugging experience
Expand All @@ -46,23 +46,23 @@ manifests:
batchMaxDuration: 10s # 60s is a good value for large runs (500+ nodes)
env:
- name: ARM_SUBSCRIPTION_ID
value: ""
value: "Please run make az-all"
- name: LOCATION
value: westus2
- name: ARM_USE_MANAGED_IDENTITY_EXTENSION
value: "true"
- name: ARM_USER_ASSIGNED_IDENTITY_ID
value: ""
value: "Please run make az-all"
- name: AZURE_NODE_RESOURCE_GROUP
value: ""
value: "Please run make az-all"
- name: AZURE_SUBNET_ID # the id of subnet to create network interfaces on
value: ""
value: "Please run make az-all"
- name: LEADER_ELECT # disable leader election for better debugging experience
value: "false"
- name: AZURE_VNET_NAME
value: ""
value: "Please run make az-all"
- name: AZURE_SUBNET_NAME
value: ""
value: "Please run make az-all"
# disable HTTP/2 to reduce ARM throttling on large-scale tests;
# with this in place write (and read) QPS can be increased too
#- name: GODEBUG
Expand Down

0 comments on commit 8d9211c

Please sign in to comment.