2
0

azure.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package integrations
  2. import (
  3. "gorm.io/gorm"
  4. "github.com/porter-dev/porter/api/types"
  5. )
  6. // AzureIntegration is an auth mechanism that uses a Azure service account principal to
  7. // authenticate
  8. type AzureIntegration struct {
  9. gorm.Model
  10. // The id of the user that linked this auth mechanism
  11. UserID uint `json:"user_id"`
  12. // The project that this integration belongs to
  13. ProjectID uint `json:"project_id"`
  14. // The Azure client ID that this is linked to
  15. AzureClientID string `json:"azure_client_id"`
  16. // The Azure subscription ID that this is linked to
  17. AzureSubscriptionID string `json:"azure_subscription_id"`
  18. // The Azure tenant ID that this is linked to
  19. AzureTenantID string `json:"azure_tenant_id"`
  20. // ACR-specific fields
  21. ACRTokenName string `json:"acr_token_name"`
  22. ACRResourceGroupName string `json:"acr_resource_group_name"`
  23. ACRName string `json:"acr_name"`
  24. // ------------------------------------------------------------------
  25. // All fields encrypted before storage.
  26. // ------------------------------------------------------------------
  27. // The Azure service principal key
  28. ServicePrincipalSecret []byte `json:"service_principal_secret"`
  29. // The ACR passwords, if set
  30. ACRPassword1 []byte `json:"acr_password_1"`
  31. ACRPassword2 []byte `json:"acr_password_2"`
  32. // The AKS password, if set (used for bearer token auth)
  33. AKSPassword []byte `json:"aks_password"`
  34. }
  35. func (a *AzureIntegration) ToAzureIntegrationType() *types.AzureIntegration {
  36. return &types.AzureIntegration{
  37. CreatedAt: a.CreatedAt,
  38. ID: a.ID,
  39. UserID: a.UserID,
  40. ProjectID: a.ProjectID,
  41. AzureClientID: a.AzureClientID,
  42. AzureSubscriptionID: a.AzureSubscriptionID,
  43. AzureTenantID: a.AzureTenantID,
  44. }
  45. }