func NewOperator()

in pkg/operator/operator.go [35:60]


func NewOperator(ctx context.Context, operator *operator.Operator) (context.Context, *Operator) {
	azConfig, err := GetAzConfig()
	if err != nil {
		logging.FromContext(ctx).Errorf("creating Azure config, %s", err)
	}

	azClient, err := instance.CreateAzClient(azConfig)
	if err != nil {
		logging.FromContext(ctx).Errorf("creating Azure client, %s", err)
		// Let us panic here, instead of crashing in the following code.
		// TODO: move this to an init container
		panic(fmt.Sprintf("Configure azure client fails. Please ensure federatedcredential has been created for identity %s.", os.Getenv("AZURE_CLIENT_ID")))
	}

	instanceProvider := instance.NewProvider(
		azClient,
		operator.GetClient(),
		azConfig.ResourceGroup,
		azConfig.ClusterName,
	)

	return ctx, &Operator{
		Operator:         operator,
		InstanceProvider: instanceProvider,
	}
}