package edgedb import ( "context" "edge-infra.dev/pkg/edge/api/types" ) const getClusterArtifactVersions = `SELECT artifact_name, artifact_version FROM cluster_artifact_versions WHERE cluster_edge_id = $1;` // GetClusterArtifactVersions gets the desired set of artifacts that should be scheduled to a cluster. Ie the name and a tag or digest // of a pallet to use in the cluster's Shipment func (edb *EdgeDB) GetClusterArtifactVersions(ctx context.Context, clusterEdgeID string) ([]types.ArtifactVersion, error) { artifacts := []types.ArtifactVersion{} // TODO(dk185217): Remove nil check on r.EdgeDB.DB after it is no longer being set: // https://github.com/ncrvoyix-swt-retail/edge-infra/blob/master/cmd/edge/clusterctl/main.go#L77C9-L77C9 if edb.DB == nil { return artifacts, nil } rows, err := edb.QueryContext(ctx, getClusterArtifactVersions, clusterEdgeID) if err != nil { return []types.ArtifactVersion{}, err } for rows.Next() { var a types.ArtifactVersion if err := rows.Scan(&a.Name, &a.Version); err != nil { return []types.ArtifactVersion{}, err } artifacts = append(artifacts, a) } return artifacts, nil }