 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- func ClientOptionsSchema() map[string]schema.Attribute
- func EntraIDOptionsSchema() map[string]schema.Attribute
- func NewMicrosoft365Provider(version string, unitTestMode ...bool) func() provider.Provider
- type ClientOptionsModel
- type EntraIDOptionsModel
- type M365Provider
- func (p *M365Provider) Configure(ctx context.Context, req provider.ConfigureRequest, ...)
- func (p *M365Provider) DataSources(ctx context.Context) []func() datasource.DataSource
- func (p *M365Provider) EphemeralResources(_ context.Context) []func() ephemeral.EphemeralResource
- func (p *M365Provider) Metadata(ctx context.Context, req provider.MetadataRequest, ...)
- func (p *M365Provider) Resources(ctx context.Context) []func() resource.Resource
- func (p *M365Provider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse)
 
- type M365ProviderModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientOptionsSchema ¶
func EntraIDOptionsSchema ¶
func NewMicrosoft365Provider ¶
NewMicrosoft365Provider returns a function that, when invoked, creates and returns a new instance of the Microsoft365 provider, which implements the terraform-plugin-framework's provider.Provider interface. This function is designed to accept a version string, which is used to track the version of the provider being created.
The provider internally manages two distinct Microsoft Graph clients:
- StableClient: A client instance configured to interact with the stable version of the Microsoft Graph API. 
- BetaClient: A client instance configured to interact with the beta version of the Microsoft Graph API. This client is used for operations that require access to newer or experimental features that are not yet available in the stable API. 
The New function encapsulates these clients within the M365Provider struct, which also holds the provider's configuration and resources. When Terraform invokes this function, it ensures that the provider is correctly instantiated with all necessary clients and configurations, making it ready to manage Microsoft365 resources through Terraform.
Types ¶
type ClientOptionsModel ¶
type ClientOptionsModel struct {
	EnableHeadersInspection types.Bool   `tfsdk:"enable_headers_inspection"`
	EnableRetry             types.Bool   `tfsdk:"enable_retry"`
	MaxRetries              types.Int64  `tfsdk:"max_retries"`
	RetryDelaySeconds       types.Int64  `tfsdk:"retry_delay_seconds"`
	EnableRedirect          types.Bool   `tfsdk:"enable_redirect"`
	MaxRedirects            types.Int64  `tfsdk:"max_redirects"`
	EnableCompression       types.Bool   `tfsdk:"enable_compression"`
	CustomUserAgent         types.String `tfsdk:"custom_user_agent"`
	UseProxy                types.Bool   `tfsdk:"use_proxy"`
	ProxyURL                types.String `tfsdk:"proxy_url"`
	ProxyUsername           types.String `tfsdk:"proxy_username"`
	ProxyPassword           types.String `tfsdk:"proxy_password"`
	TimeoutSeconds          types.Int64  `tfsdk:"timeout_seconds"`
	EnableChaos             types.Bool   `tfsdk:"enable_chaos"`
	ChaosPercentage         types.Int64  `tfsdk:"chaos_percentage"`
	ChaosStatusCode         types.Int64  `tfsdk:"chaos_status_code"`
	ChaosStatusMessage      types.String `tfsdk:"chaos_status_message"`
}
    ClientOptionsModel describes the client options
type EntraIDOptionsModel ¶
type EntraIDOptionsModel struct {
	ClientID                   types.String `tfsdk:"client_id"`
	ClientSecret               types.String `tfsdk:"client_secret"`
	ClientCertificate          types.String `tfsdk:"client_certificate"`
	ClientCertificatePassword  types.String `tfsdk:"client_certificate_password"`
	SendCertificateChain       types.Bool   `tfsdk:"send_certificate_chain"`
	Username                   types.String `tfsdk:"username"` // For Interactive Browser Credential
	DisableInstanceDiscovery   types.Bool   `tfsdk:"disable_instance_discovery"`
	AdditionallyAllowedTenants types.List   `tfsdk:"additionally_allowed_tenants"`
	RedirectUrl                types.String `tfsdk:"redirect_url"`
	FederatedTokenFilePath     types.String `tfsdk:"federated_token_file_path"` // For workload identity
	ManagedIdentityID          types.String `tfsdk:"managed_identity_id"`       // For managed identity
	OIDCTokenFilePath          types.String `tfsdk:"oidc_token_file_path"`      // For OIDC authentication
	OIDCRequestToken           types.String `tfsdk:"oidc_request_token"`        // For GitHub Actions OIDC
	OIDCRequestURL             types.String `tfsdk:"oidc_request_url"`          // For GitHub Actions OIDC
	ADOServiceConnectionID     types.String `tfsdk:"ado_service_connection_id"` // For Azure DevOps OIDC
}
    EntraIDOptionsModel describes the Entra ID options
type M365Provider ¶
type M365Provider struct {
	// contains filtered or unexported fields
}
    M365Provider defines the provider implementation.
func (*M365Provider) Configure ¶
func (p *M365Provider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse)
Configure sets up the Microsoft365 provider with the given configuration. It processes the provider schema, retrieves values from the configuration or environment variables, sets up authentication, and initializes the Microsoft Graph clients.
The function supports various authentication methods, proxy settings, and national cloud deployments. It performs the following main steps:
- Extracts and validates the configuration data.
- Sets up logging and context with relevant fields.
- Converts the provider model to client provider data.
- Configures the Microsoft Graph clients using the client package.
If any errors occur during these steps, appropriate diagnostics are added to the response.
func (*M365Provider) DataSources ¶
func (p *M365Provider) DataSources(ctx context.Context) []func() datasource.DataSource
DataSources returns a slice of functions that each return a datasource.DataSource. This function is a method of the M365Provider type and takes a context.Context as an argument. The returned slice is intended to hold the Microsoft 365 provider datasources.
Parameters:
- ctx: The context for controlling cancellation and timeout.
Returns:
[]func() datasource.DataSource: A slice of functions, each returning a datasource.DataSource.
func (*M365Provider) EphemeralResources ¶
func (p *M365Provider) EphemeralResources(_ context.Context) []func() ephemeral.EphemeralResource
EphemeralResources defines the ephemeral resources implemented in the provider.
func (*M365Provider) Metadata ¶
func (p *M365Provider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse)
func (*M365Provider) Resources ¶
func (p *M365Provider) Resources(ctx context.Context) []func() resource.Resource
Resources returns a slice of functions that each return a resource.Resource. This function is a method of the M365Provider type and takes a context.Context as an argument. The returned slice is intended to hold the Microsoft 365 provider resources.
Parameters:
- ctx: The context for controlling cancellation and timeout.
Returns:
[]func() resource.Resource: A slice of functions, each returning a resource.Resource.
Resources returns a slice of functions that each return a resource.Resource.
func (*M365Provider) Schema ¶
func (p *M365Provider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse)
type M365ProviderModel ¶
type M365ProviderModel struct {
	Cloud           types.String `tfsdk:"cloud"`
	TenantID        types.String `tfsdk:"tenant_id"`
	AuthMethod      types.String `tfsdk:"auth_method"`
	EntraIDOptions  types.Object `tfsdk:"entra_id_options"`
	ClientOptions   types.Object `tfsdk:"client_options"`
	TelemetryOptout types.Bool   `tfsdk:"telemetry_optout"`
	DebugMode       types.Bool   `tfsdk:"debug_mode"`
}
    M365ProviderModel describes the provider data model.