Skip to content

Commit

Permalink
Switch to the new Repos API (#4954)
Browse files Browse the repository at this point in the history
* wip Revamp AppRepoForm

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Update tests

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Allow no-commented-out-tests temporarily

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix linter issue

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix linter issues

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Delete AppRepository

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix repos action

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Add remaining changes

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* wip fix some test cases

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix repos.ts test suite

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Implement PackageRepositoriesService test suite

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Add plural names. Add packageFormat in repo list

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Add AppRepoForm

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix AppRepoForm test cases

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix remaining tests

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Remove no longer used urls

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Avoid setting auth values if undefined

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix e2e tests

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Allow setting pullSecret in the UI. Improve CA input/secret selector

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Disable e2e test 03

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix linter issue

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix test case

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix test 03

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Run prettier

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Minor file renames from AppRepo to PkgRepo  (#4955)

* Minor renames

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Rename files from AppRepo to PkgRepo

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix test cases

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Comment-out e2e test

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Extract regex to a const

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Add some suggestions from code review

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Fix type issues in actons. Perform renames

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Rename kubeappsNamespace to globalReposNamespace

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Remove validation action. Fix action tests

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Return summaries in action to avoid full reload

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Add test case for sorting when adding repo

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Disable unsupported auth methods

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Suggest pull secrets if usign docker creds

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Remove ad-hoc helm client

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Extract customDetails encoding to a fn

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Delete leftover

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Remove apprepo management from Kubeops (#5026)

* Remove unused logic from kubeops

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Remove old kubeops endpoint from api docs

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Remove unused kubeops args

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Address PR's comments

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Tidy up the `/pkg` folder (#5027)

* Remove pkg/handlerutil

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Remove unused code from pkg/agent

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Move pkg/agent to plugins/pkg/agent

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Add dockerjson auth type as supported to flux plg

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* cast request.customDetails to RepositoryCustomDetails

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Avoid seding mixed user/kubeapps mgn secrets

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Modify toggle msgs

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

* Improve secret info msg

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
  • Loading branch information
antgamdia committed Jul 8, 2022
1 parent 208573a commit f4d5d54
Show file tree
Hide file tree
Showing 66 changed files with 4,292 additions and 5,874 deletions.
1 change: 0 additions & 1 deletion chart/kubeapps/templates/kubeops/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ spec:
args: {{- include "common.tplvalues.render" (dict "value" .Values.kubeops.args "context" $) | nindent 12 }}
{{- else }}
args:
- --user-agent-comment=kubeapps/{{ .Chart.AppVersion }}
{{- if .Values.clusters }}
- --clusters-config-path=/config/clusters.conf
{{- end }}
Expand Down
5 changes: 2 additions & 3 deletions cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import (
corev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/core/packages/v1alpha1"
helmv1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/plugins/helm/packages/v1alpha1"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/utils"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/agent"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/clientgetter"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/paginate"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/pkgutils"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/resourcerefs"
"github.com/vmware-tanzu/kubeapps/pkg/agent"
chartutils "github.com/vmware-tanzu/kubeapps/pkg/chart"
"github.com/vmware-tanzu/kubeapps/pkg/chart/models"
"github.com/vmware-tanzu/kubeapps/pkg/dbutils"
"github.com/vmware-tanzu/kubeapps/pkg/handlerutil"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/anypb"
Expand Down Expand Up @@ -866,7 +865,7 @@ func (s *Server) fetchChartWithRegistrySecrets(ctx context.Context, chartDetails
}

// Grab the chart itself
ch, err := handlerutil.GetChart(
ch, err := utils.GetChart(
&chartutils.Details{
AppRepositoryResourceName: appRepo.Name,
AppRepositoryResourceNamespace: appRepo.Namespace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
helmv1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/plugins/helm/packages/v1alpha1"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/common"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/utils"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/agent"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/clientgetter"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/paginate"
"github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/pkgutils"
"github.com/vmware-tanzu/kubeapps/pkg/agent"
"github.com/vmware-tanzu/kubeapps/pkg/chart/fake"
"github.com/vmware-tanzu/kubeapps/pkg/chart/models"
"github.com/vmware-tanzu/kubeapps/pkg/dbutils"
Expand Down
17 changes: 17 additions & 0 deletions cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
package utils

import (
appRepov1 "github.com/vmware-tanzu/kubeapps/cmd/apprepository-controller/pkg/apis/apprepository/v1alpha1"
chartUtils "github.com/vmware-tanzu/kubeapps/pkg/chart"
"github.com/vmware-tanzu/kubeapps/pkg/chart/models"
"github.com/vmware-tanzu/kubeapps/pkg/dbutils"
"helm.sh/helm/v3/pkg/chart"
k8scorev1 "k8s.io/api/core/v1"
)

type AssetManager interface {
Expand All @@ -32,3 +36,16 @@ type ChartQuery struct {
func NewManager(databaseType string, config dbutils.Config, globalReposNamespace string) (AssetManager, error) {
return NewPGManager(config, globalReposNamespace)
}

// GetChart retrieves a chart
func GetChart(chartDetails *chartUtils.Details, appRepo *appRepov1.AppRepository, caCertSecret *k8scorev1.Secret, authSecret *k8scorev1.Secret, chartClient chartUtils.ChartClient) (*chart.Chart, error) {
err := chartClient.Init(appRepo, caCertSecret, authSecret)
if err != nil {
return nil, err
}
ch, err := chartClient.GetChart(chartDetails, appRepo.Spec.URL)
if err != nil {
return nil, err
}
return ch, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ import (
"sigs.k8s.io/yaml"
)

type AppOverview struct {
ReleaseName string `json:"releaseName"`
Version string `json:"version"`
Namespace string `json:"namespace"`
Icon string `json:"icon,omitempty"`
Status string `json:"status"`
Chart string `json:"chart"`
ChartMetadata chart.Metadata `json:"chartMetadata"`
}

// StorageForDriver is a function type which returns a specific storage.
type StorageForDriver func(namespace string, clientset *kubernetes.Clientset) *storage.Storage

Expand All @@ -42,43 +32,6 @@ func StorageForSecrets(namespace string, clientset *kubernetes.Clientset) *stora
return storage.Init(d)
}

// StorageForConfigMaps returns a storage using the ConfigMap driver.
func StorageForConfigMaps(namespace string, clientset *kubernetes.Clientset) *storage.Storage {
d := driver.NewConfigMaps(clientset.CoreV1().ConfigMaps(namespace))
d.Log = log.Infof
return storage.Init(d)
}

// StorageForMemory returns a storage using the Memory driver.
func StorageForMemory(_ string, _ *kubernetes.Clientset) *storage.Storage {
d := driver.NewMemory()
return storage.Init(d)
}

// ListReleases lists releases in the specified namespace, or all namespaces if the empty string is given.
func ListReleases(actionConfig *action.Configuration, namespace string, listLimit int, status string) ([]AppOverview, error) {
allNamespaces := namespace == ""
cmd := action.NewList(actionConfig)
if allNamespaces {
cmd.AllNamespaces = true
}
cmd.Limit = listLimit
if status == "all" {
cmd.StateMask = action.ListAll
}
releases, err := cmd.Run()
if err != nil {
return nil, err
}
appOverviews := make([]AppOverview, 0)
for _, r := range releases {
if allNamespaces || r.Namespace == namespace {
appOverviews = append(appOverviews, appOverviewFromRelease(r))
}
}
return appOverviews, nil
}

// CreateRelease creates a release.
func CreateRelease(actionConfig *action.Configuration, name, namespace, valueString string,
ch *chart.Chart, registrySecrets map[string]string, timeoutSeconds int32) (*release.Release, error) {
Expand Down Expand Up @@ -246,29 +199,3 @@ func getValues(raw []byte) (Values, error) {
func stringptr(val string) *string {
return &val
}

// ParseDriverType maps strings to well-typed driver representations.
func ParseDriverType(raw string) (StorageForDriver, error) {
switch raw {
case "secret", "secrets":
return StorageForSecrets, nil
case "configmap", "configmaps":
return StorageForConfigMaps, nil
case "memory":
return StorageForMemory, nil
default:
return nil, fmt.Errorf("Invalid Helm driver type: %s", raw)
}
}

func appOverviewFromRelease(r *release.Release) AppOverview {
return AppOverview{
ReleaseName: r.Name,
Version: r.Chart.Metadata.Version,
Icon: r.Chart.Metadata.Icon,
Namespace: r.Namespace,
Status: r.Info.Status.String(),
Chart: r.Chart.Name(),
ChartMetadata: *r.Chart.Metadata,
}
}
Loading

0 comments on commit f4d5d54

Please sign in to comment.