diff --git a/pkg/fission-cli/cmd/package/util/util.go b/pkg/fission-cli/cmd/package/util/util.go index f1e15802..1f6e7005 100644 --- a/pkg/fission-cli/cmd/package/util/util.go +++ b/pkg/fission-cli/cmd/package/util/util.go @@ -104,11 +104,12 @@ func getArchiveURL(ctx context.Context, client cmd.Client, archiveID string, ser storageType := resp.Header.Get("X-FISSION-STORAGETYPE") if storageType == "local" { - storagesvcURL, err := util.GetStorageURL(ctx, client) + storageSvc, err := util.GetSvcName(ctx, client.KubernetesClient, "fission-storage") if err != nil { return "", err } - client := storageSvcClient.MakeClient(storagesvcURL.String()) + storagesvcURL := "http://" + storageSvc + client := storageSvcClient.MakeClient(storagesvcURL) return client.GetUrl(archiveID), nil } else if storageType == "s3" { storageBucket := resp.Header.Get("X-FISSION-BUCKET") diff --git a/pkg/fission-cli/util/util.go b/pkg/fission-cli/util/util.go index 4f0530ee..15deadfe 100644 --- a/pkg/fission-cli/util/util.go +++ b/pkg/fission-cli/util/util.go @@ -511,6 +511,23 @@ func ConfigMapExists(ctx context.Context, m *metav1.ObjectMeta, kClient kubernet return err } +func GetSvcName(ctx context.Context, kClient kubernetes.Interface, application string) (string, error) { + appLabelSelector := "application=" + application + + services, err := kClient.CoreV1().Services("").List(ctx, metav1.ListOptions{ + LabelSelector: appLabelSelector, + }) + if err != nil { + return "", err + } + + if len(services.Items) > 1 || len(services.Items) == 0 { + return "", errors.Errorf("more than one service found for application=%s", application) + } + service := services.Items[0] + return service.Name + "." + service.Namespace, nil +} + // FunctionPodLogs : Get logs for a function directly from pod func FunctionPodLogs(ctx context.Context, fnName, ns string, client cmd.Client) (err error) {