Skip to content

Commit

Permalink
remove unused client methods
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Dec 5, 2024
1 parent b44c908 commit 308b7df
Show file tree
Hide file tree
Showing 21 changed files with 2 additions and 738 deletions.
83 changes: 0 additions & 83 deletions pkg/api/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,89 +5,6 @@ import (
"github.com/pluralsh/gqlclient/pkg/utils"
)

type packageCacheEntry struct {
Charts []*ChartInstallation
Terraform []*TerraformInstallation
}

var packageCache = make(map[string]*packageCacheEntry)

func (client *client) GetVersions(chartId string) ([]*Version, error) {
versions := make([]*Version, 0)
resp, err := client.pluralClient.GetVersions(client.ctx, chartId)
if err != nil {
return nil, err
}
for _, version := range resp.Versions.Edges {
versions = append(versions, convertVersion(version.Node))
}
return versions, err
}

func (client *client) GetChartInstallations(repoId string) ([]*ChartInstallation, error) {
insts := make([]*ChartInstallation, 0)
resp, err := client.pluralClient.GetChartInstallations(client.ctx, repoId)
if err != nil {
return nil, err
}

for _, edge := range resp.ChartInstallations.Edges {
if edge.Node != nil {
insts = append(insts, convertChartInstallation(edge.Node))
}
}

return insts, err
}

func ClearPackageCache() {
packageCache = make(map[string]*packageCacheEntry)
}

func (client *client) GetPackageInstallations(repoId string) (charts []*ChartInstallation, tfs []*TerraformInstallation, err error) {
if entry, ok := packageCache[repoId]; ok {
return entry.Charts, entry.Terraform, nil
}

resp, err := client.pluralClient.GetPackageInstallations(client.ctx, repoId)
if err != nil {
return
}

charts = make([]*ChartInstallation, 0)
for _, edge := range resp.ChartInstallations.Edges {
if edge.Node != nil {
charts = append(charts, convertChartInstallation(edge.Node))
}
}

tfs = make([]*TerraformInstallation, 0)
for _, edge := range resp.TerraformInstallations.Edges {
node := edge.Node
if node != nil {
tfInstall := &TerraformInstallation{
Id: utils.ConvertStringPointer(node.ID),
Terraform: convertTerraform(node.Terraform),

Version: convertVersion(node.Version),
}

tfs = append(tfs, tfInstall)
}
}

if err == nil {
packageCache[repoId] = &packageCacheEntry{Charts: charts, Terraform: tfs}
}

return
}

func (client *client) UninstallChart(id string) (err error) {
_, err = client.pluralClient.UninstallChart(client.ctx, id)
return
}

func convertVersion(version *gqlclient.VersionFragment) *Version {
if version == nil {
return nil
Expand Down
7 changes: 0 additions & 7 deletions pkg/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ type Client interface {
DeleteEabCredential(cluster string, provider string) error
CreateEvent(event *UserEventAttributes) error
GetTfProviders() ([]string, error)
GetTfProviderScaffold(name string, version string) (string, error)
GetRepository(repo string) (*Repository, error)
CreateRepository(name string, publisher string, input *gqlclient.RepositoryAttributes) error
AcquireLock(repo string) (*ApplyLock, error)
ReleaseLock(repo string, lock string) (*ApplyLock, error)
ListRepositories(query string) ([]*Repository, error)
Scaffolds(in *ScaffoldInputs) ([]*ScaffoldFile, error)
UpdateVersion(spec *VersionSpec, tags []string) error
CreateDomain(name string) error
CreateInstallation(id string) (string, error)
Expand All @@ -57,7 +51,6 @@ type Client interface {
GetHelp(prompt string) (string, error)
Clusters() ([]*Cluster, error)
Cluster(id string) (*Cluster, error)
Release(name string, tags []string) error
Chat(history []*ChatMessage) (*ChatMessage, error)
CreateTrust(issuer, trust string) error
DeleteTrust(id string) error
Expand Down
8 changes: 0 additions & 8 deletions pkg/api/installations.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ func (client *client) GetInstallation(name string) (*Installation, error) {

}

func (client *client) GetInstallationById(id string) (*Installation, error) {
resp, err := client.pluralClient.GetInstallationByID(client.ctx, &id)
if err != nil {
return nil, err
}
return convertInstallation(resp.Installation), nil
}

func (client *client) DeleteInstallation(id string) error {
_, err := client.pluralClient.DeleteInstallation(client.ctx, id)
return err
Expand Down
71 changes: 0 additions & 71 deletions pkg/api/recipes.go

This file was deleted.

Loading

0 comments on commit 308b7df

Please sign in to comment.