azure.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. }
  33. func (a *AzureIntegration) ToAzureIntegrationType() *types.AzureIntegration {
  34. return &types.AzureIntegration{
  35. CreatedAt: a.CreatedAt,
  36. ID: a.ID,
  37. UserID: a.UserID,
  38. ProjectID: a.ProjectID,
  39. AzureClientID: a.AzureClientID,
  40. AzureSubscriptionID: a.AzureSubscriptionID,
  41. AzureTenantID: a.AzureTenantID,
  42. }
  43. }