chart.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package forms
  2. import (
  3. "github.com/porter-dev/porter/internal/helm"
  4. "github.com/porter-dev/porter/internal/repository"
  5. )
  6. // ChartForm is the generic base type for CRUD operations on charts
  7. type ChartForm struct {
  8. HelmOptions *helm.Form `json:"helm" form:"required"`
  9. UserID uint `json:"user_id"`
  10. }
  11. // PopulateHelmOptions uses the passed user ID to populate the HelmOptions object
  12. func (cf *ChartForm) PopulateHelmOptions(repo repository.UserRepository) error {
  13. user, err := repo.ReadUser(cf.UserID)
  14. if err != nil {
  15. return err
  16. }
  17. cf.HelmOptions.AllowedContexts = user.ContextToSlice()
  18. cf.HelmOptions.KubeConfig = user.RawKubeConfig
  19. return nil
  20. }
  21. // ListChartForm represents the accepted values for listing Helm charts
  22. type ListChartForm struct {
  23. ChartForm
  24. ListFilter *helm.ListFilter `json:"filter" form:"required"`
  25. }
  26. // GetChartForm represents the accepted values for getting a single Helm chart
  27. type GetChartForm struct {
  28. ChartForm
  29. Name string `json:"name" form:"required"`
  30. Revision int `json:"release"`
  31. }