...
1 package edgedb
2
3 import (
4 "context"
5
6 "edge-infra.dev/pkg/edge/api/types"
7 )
8
9 const getClusterArtifactVersions = `SELECT artifact_name, artifact_version FROM cluster_artifact_versions WHERE cluster_edge_id = $1;`
10
11
12
13 func (edb *EdgeDB) GetClusterArtifactVersions(ctx context.Context, clusterEdgeID string) ([]types.ArtifactVersion, error) {
14 artifacts := []types.ArtifactVersion{}
15
16
17 if edb.DB == nil {
18 return artifacts, nil
19 }
20 rows, err := edb.QueryContext(ctx, getClusterArtifactVersions, clusterEdgeID)
21 if err != nil {
22 return []types.ArtifactVersion{}, err
23 }
24 for rows.Next() {
25 var a types.ArtifactVersion
26 if err := rows.Scan(&a.Name, &a.Version); err != nil {
27 return []types.ArtifactVersion{}, err
28 }
29 artifacts = append(artifacts, a)
30 }
31 return artifacts, nil
32 }
33
View as plain text