mirror of https://github.com/harness/drone.git
fix: [AH-306c]: fix anonymous flow (#2574)
* Merge branch 'main' of https://git0.harness.io/l7B_kbSEQD2wjrM7PShm5w/PROD/Harness_Commons/gitness into AH-307-plus-url-support-2 * [AH-307]: Comments * Merge commit * Merge commit * Merge commit * Added comments * Revert changes * Merge commit * Merge branch 'main' of https://git0.harness.io/l7B_kbSEQD2wjrM7PShm5w/PROD/Harness_Commons/gitness into AH-307-plus-url-support-2 * Merge branch 'AH-306d' of https://git0.harness.io/l7B_kbSEQD2wjrM7PShm5w/PROD/Harness_Commons/gitness into AH-307-plus-url-support-2 * fix space path handling * Merge branch 'main' of https://git0.harness.io/l7B_kbSEQD2wjrM7PShm5w/PROD/Harness_Commons/gitness into AH-307-plus-url-support-2 * Updated URLs to support slashes with + separator * fix: [AH-306c]: fix anonymous flow * fix: [AH-306c]: fix anonymous flow * feat: [AH-307]: plus url support on UI (cherry picked from commit 3fb6add3ce03498b6668b5f8f6d547e1acedaec4) * [AH-307]: Added examples (cherry picked from commit e83e41303da536f421be333be04aed09fbf75f5f) * [AH-307]: Added Regex request rewrite support (cherry picked from commit ed7b155256bdcd1134bc228b5705556a1233add6) * fix: [AH-306c]: fix anonymous flowCODE-2402
parent
fb99bcb8d2
commit
744b884c1f
|
@ -16,6 +16,7 @@ package encode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/harness/gitness/app/api/render"
|
"github.com/harness/gitness/app/api/render"
|
||||||
|
@ -32,7 +33,8 @@ const (
|
||||||
// GitPathBefore wraps an http.HandlerFunc in a layer that encodes a path coming
|
// GitPathBefore wraps an http.HandlerFunc in a layer that encodes a path coming
|
||||||
// as part of the GIT api (e.g. "space1/repo.git") before executing the provided http.HandlerFunc.
|
// as part of the GIT api (e.g. "space1/repo.git") before executing the provided http.HandlerFunc.
|
||||||
func GitPathBefore(next http.Handler) http.Handler {
|
func GitPathBefore(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(
|
||||||
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
_, err := pathTerminatedWithMarker(r, "", ".git", "")
|
_, err := pathTerminatedWithMarker(r, "", ".git", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -41,14 +43,16 @@ func GitPathBefore(next http.Handler) http.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TerminatedPathBefore wraps an http.HandlerFunc in a layer that encodes a terminated path (e.g. "/space1/space2/+")
|
// TerminatedPathBefore wraps an http.HandlerFunc in a layer that encodes a terminated path (e.g. "/space1/space2/+")
|
||||||
// before executing the provided http.HandlerFunc. The first prefix that matches the URL.Path will
|
// before executing the provided http.HandlerFunc. The first prefix that matches the URL.Path will
|
||||||
// be used during encoding (prefix is ignored during encoding).
|
// be used during encoding (prefix is ignored during encoding).
|
||||||
func TerminatedPathBefore(prefixes []string, next http.Handler) http.Handler {
|
func TerminatedPathBefore(prefixes []string, next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(
|
||||||
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
for _, p := range prefixes {
|
for _, p := range prefixes {
|
||||||
changed, err := pathTerminatedWithMarker(r, p, "/+", "")
|
changed, err := pathTerminatedWithMarker(r, p, "/+", "")
|
||||||
|
@ -64,7 +68,31 @@ func TerminatedPathBefore(prefixes []string, next http.Handler) http.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TerminatedRegexPathBefore is similar to TerminatedPathBefore but supports regex prefixes.
|
||||||
|
func TerminatedRegexPathBefore(regexPrefixes []string, next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(
|
||||||
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
ctx := r.Context()
|
||||||
|
for _, p := range regexPrefixes {
|
||||||
|
changed, err := regexPathTerminatedWithMarker(r, p, "/+", "")
|
||||||
|
if err != nil {
|
||||||
|
render.TranslatedUserError(ctx, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// first prefix that leads to success we can stop
|
||||||
|
if changed {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pathTerminatedWithMarker function encodes a path followed by a custom marker and returns a request with an
|
// pathTerminatedWithMarker function encodes a path followed by a custom marker and returns a request with an
|
||||||
|
@ -86,6 +114,12 @@ func pathTerminatedWithMarker(r *http.Request, prefix string, marker string, mar
|
||||||
urlPath = r.URL.RawPath
|
urlPath = r.URL.RawPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return pathTerminatedWithMarkerAndURL(r, prefix, marker, markerReplacement, urlPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func pathTerminatedWithMarkerAndURL(
|
||||||
|
r *http.Request, prefix string, marker string, markerReplacement string, urlPath string,
|
||||||
|
) (bool, error) {
|
||||||
// In case path doesn't start with prefix - nothing to encode
|
// In case path doesn't start with prefix - nothing to encode
|
||||||
if len(urlPath) < len(prefix) || urlPath[0:len(prefix)] != prefix {
|
if len(urlPath) < len(prefix) || urlPath[0:len(prefix)] != prefix {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -109,7 +143,8 @@ func pathTerminatedWithMarker(r *http.Request, prefix string, marker string, mar
|
||||||
prefix,
|
prefix,
|
||||||
marker,
|
marker,
|
||||||
prefixWithPath,
|
prefixWithPath,
|
||||||
prefixWithEscapedPath)
|
prefixWithEscapedPath,
|
||||||
|
)
|
||||||
|
|
||||||
err := request.ReplacePrefix(r, prefixWithPath, prefixWithEscapedPath)
|
err := request.ReplacePrefix(r, prefixWithPath, prefixWithEscapedPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -119,6 +154,41 @@ func pathTerminatedWithMarker(r *http.Request, prefix string, marker string, mar
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// regexPathTerminatedWithMarker is similar to pathTerminatedWithMarker but with regex prefix support.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
// 1. Path: "/registry/app1%2Fremote2/artifact/foo/bar/+/summary"
|
||||||
|
// Prefix: => "^/registry/([^/]+)/artifact/" Marker: => "/+" MarkerReplacement: => ""
|
||||||
|
// ==> "/registry/app1%2Fremote2/artifact/foo%2Fbar/summary"
|
||||||
|
//
|
||||||
|
// 2. Path: "/registry/abc/artifact/foo/bar/+/summary"
|
||||||
|
// Prefix: => "^/registry/([^/]+)/artifact/" Marker: => "/+" MarkerReplacement: => ""
|
||||||
|
// ==> "/registry/abc/artifact/foo%2Fbar/summary"
|
||||||
|
|
||||||
|
func regexPathTerminatedWithMarker(
|
||||||
|
r *http.Request,
|
||||||
|
regexPrefix string,
|
||||||
|
marker string,
|
||||||
|
markerReplacement string,
|
||||||
|
) (bool, error) {
|
||||||
|
prefixPattern := regexp.MustCompile(regexPrefix)
|
||||||
|
|
||||||
|
matches := prefixPattern.FindStringSubmatch(r.URL.Path)
|
||||||
|
// In case path doesn't start with prefix - nothing to encode
|
||||||
|
if len(matches) == 0 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// We only care about the first match as we provide prefix
|
||||||
|
prefix := matches[0]
|
||||||
|
|
||||||
|
urlPath := r.URL.Path
|
||||||
|
if r.URL.RawPath != "" {
|
||||||
|
urlPath = r.URL.RawPath
|
||||||
|
}
|
||||||
|
return pathTerminatedWithMarkerAndURL(r, prefix, marker, markerReplacement, urlPath)
|
||||||
|
}
|
||||||
|
|
||||||
// cutOutTerminatedPath cuts out the resource path terminated with the provided marker (path segment suffix).
|
// cutOutTerminatedPath cuts out the resource path terminated with the provided marker (path segment suffix).
|
||||||
// e.g. subPath: "/space1/space2/+/authToken", marker: "/+" => "/space1/space2"
|
// e.g. subPath: "/space1/space2/+/authToken", marker: "/+" => "/space1/space2"
|
||||||
// e.g. subPath: "/space1/space2.git", marker: ".git" => "/space1/space2"
|
// e.g. subPath: "/space1/space2.git", marker: ".git" => "/space1/space2"
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
middlewareauthn "github.com/harness/gitness/app/api/middleware/authn"
|
middlewareauthn "github.com/harness/gitness/app/api/middleware/authn"
|
||||||
|
"github.com/harness/gitness/app/api/middleware/encode"
|
||||||
"github.com/harness/gitness/app/auth/authn"
|
"github.com/harness/gitness/app/auth/authn"
|
||||||
"github.com/harness/gitness/app/auth/authz"
|
"github.com/harness/gitness/app/auth/authz"
|
||||||
corestore "github.com/harness/gitness/app/store"
|
corestore "github.com/harness/gitness/app/store"
|
||||||
|
@ -33,6 +34,18 @@ import (
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// terminatedPathPrefixesAPI is the list of prefixes that will require resolving terminated paths.
|
||||||
|
terminatedPathPrefixesAPI = []string{
|
||||||
|
"/api/v1/spaces/", "/api/v1/registry/",
|
||||||
|
}
|
||||||
|
|
||||||
|
// terminatedPathRegexPrefixesAPI is the list of regex prefixes that will require resolving terminated paths.
|
||||||
|
terminatedPathRegexPrefixesAPI = []string{
|
||||||
|
"^/api/v1/registry/([^/]+)/artifact/",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
type APIHandler interface {
|
type APIHandler interface {
|
||||||
http.Handler
|
http.Handler
|
||||||
}
|
}
|
||||||
|
@ -72,5 +85,9 @@ func NewAPIHandler(
|
||||||
auditService,
|
auditService,
|
||||||
)
|
)
|
||||||
handler := artifact.NewStrictHandler(apiController, []artifact.StrictMiddlewareFunc{})
|
handler := artifact.NewStrictHandler(apiController, []artifact.StrictMiddlewareFunc{})
|
||||||
return artifact.HandlerFromMuxWithBaseURL(handler, r, baseURL)
|
muxHandler := artifact.HandlerFromMuxWithBaseURL(handler, r, baseURL)
|
||||||
|
return encode.TerminatedPathBefore(
|
||||||
|
terminatedPathPrefixesAPI,
|
||||||
|
encode.TerminatedRegexPathBefore(terminatedPathRegexPrefixesAPI, muxHandler),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ package router
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/harness/gitness/registry/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const RegistryMount = "/api/v1/registry"
|
const RegistryMount = "/api/v1/registry"
|
||||||
|
@ -35,11 +37,13 @@ func (r *RegistryRouter) Handle(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RegistryRouter) IsEligibleTraffic(req *http.Request) bool {
|
func (r *RegistryRouter) IsEligibleTraffic(req *http.Request) bool {
|
||||||
if strings.HasPrefix(req.URL.Path, RegistryMount) || strings.HasPrefix(req.URL.Path, "/v2/") ||
|
urlPath := req.URL.Path
|
||||||
strings.HasPrefix(req.URL.Path, "/registry/") ||
|
if req.URL.RawPath != "" {
|
||||||
(strings.HasPrefix(req.URL.Path, APIMount+"/v1/spaces/") &&
|
urlPath = req.URL.RawPath
|
||||||
(strings.HasSuffix(req.URL.Path, "/artifacts") ||
|
}
|
||||||
strings.HasSuffix(req.URL.Path, "/registries"))) {
|
if utils.HasAnyPrefix(urlPath, []string{RegistryMount, "/v2/", "/registry/"}) ||
|
||||||
|
(strings.HasPrefix(urlPath, APIMount+"/v1/spaces/") &&
|
||||||
|
utils.HasAnySuffix(urlPath, []string{"/artifacts", "/registries"})) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2023 Harness, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
func HasAnyPrefix(s string, prefixes []string) bool {
|
||||||
|
for _, prefix := range prefixes {
|
||||||
|
if strings.HasPrefix(s, prefix) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func HasAnySuffix(s string, prefixes []string) bool {
|
||||||
|
for _, prefix := range prefixes {
|
||||||
|
if strings.HasSuffix(s, prefix) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
|
@ -15,10 +15,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { isUndefined } from 'lodash-es'
|
import { isUndefined } from 'lodash-es'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
|
||||||
import { useAppStore } from './useAppStore'
|
import { useAppStore } from './useAppStore'
|
||||||
import { useDecodedParams } from './useDecodedParams'
|
import { useDecodedParams } from './useDecodedParams'
|
||||||
|
|
||||||
|
export const encodeRef = (pattern: string): string => {
|
||||||
|
return pattern + '/+'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const decodeRef = (pattern: string): string => {
|
||||||
|
if (pattern.endsWith('/+')) return pattern.replace('/+', '')
|
||||||
|
return pattern
|
||||||
|
}
|
||||||
|
|
||||||
export const useGetSpaceRef = (repoKey?: string): string => {
|
export const useGetSpaceRef = (repoKey?: string): string => {
|
||||||
const { scope } = useAppStore()
|
const { scope } = useAppStore()
|
||||||
const { space } = scope
|
const { space } = scope
|
||||||
|
@ -29,5 +37,6 @@ export const useGetSpaceRef = (repoKey?: string): string => {
|
||||||
} else if (repositoryIdentifier) {
|
} else if (repositoryIdentifier) {
|
||||||
url += `/${repositoryIdentifier}`
|
url += `/${repositoryIdentifier}`
|
||||||
}
|
}
|
||||||
return encodePathParams(url.replace(/^\/|\/$/g, ''))
|
url = url.replace(/^\/|\/$/g, '')
|
||||||
|
return encodeRef(url)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { Button, ButtonVariation, Layout, getErrorInfoFromErrorObject, useToaste
|
||||||
import { useUpdateArtifactLabelsMutation, type ArtifactSummary } from '@harnessio/react-har-service-client'
|
import { useUpdateArtifactLabelsMutation, type ArtifactSummary } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { useGetSpaceRef } from '@ar/hooks'
|
import { useGetSpaceRef } from '@ar/hooks'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { useStrings } from '@ar/frameworks/strings/String'
|
import { useStrings } from '@ar/frameworks/strings/String'
|
||||||
import type { RepositoryPackageType } from '@ar/common/types'
|
import type { RepositoryPackageType } from '@ar/common/types'
|
||||||
import type { ArtifactDetailsPathParams } from '@ar/routes/types'
|
import type { ArtifactDetailsPathParams } from '@ar/routes/types'
|
||||||
|
@ -59,7 +59,7 @@ function ArtifactDetailsHeaderContent(props: ArtifactDetailsHeaderContentProps):
|
||||||
const response = await modifyArtifactLabels({
|
const response = await modifyArtifactLabels({
|
||||||
body: { labels: newLabels },
|
body: { labels: newLabels },
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(artifactIdentifier)
|
artifact: encodeRef(artifactIdentifier)
|
||||||
})
|
})
|
||||||
if (response.content.status === 'SUCCESS') {
|
if (response.content.status === 'SUCCESS') {
|
||||||
clear()
|
clear()
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { ArtifactSummary, useGetArtifactSummaryQuery } from '@harnessio/react-ha
|
||||||
import { Page } from '@harnessio/uicore'
|
import { Page } from '@harnessio/uicore'
|
||||||
|
|
||||||
import { useGetSpaceRef } from '@ar/hooks'
|
import { useGetSpaceRef } from '@ar/hooks'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
|
|
||||||
import css from './ArtifactProvider.module.scss'
|
import css from './ArtifactProvider.module.scss'
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ const ArtifactProvider: FC<PropsWithChildren<{ repoKey: string; artifact: string
|
||||||
refetch
|
refetch
|
||||||
} = useGetArtifactSummaryQuery({
|
} = useGetArtifactSummaryQuery({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(artifact)
|
artifact: encodeRef(artifact)
|
||||||
})
|
})
|
||||||
|
|
||||||
const responseData = data?.content?.data
|
const responseData = data?.content?.data
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { Page } from '@harnessio/uicore'
|
||||||
import { useGetDockerArtifactManifestsQuery } from '@harnessio/react-har-service-client'
|
import { useGetDockerArtifactManifestsQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { useGetSpaceRef } from '@ar/hooks'
|
import { useGetSpaceRef } from '@ar/hooks'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { useStrings } from '@ar/frameworks/strings/String'
|
import { useStrings } from '@ar/frameworks/strings/String'
|
||||||
import DigestListTable from './components/DigestListTable/DigestListTable'
|
import DigestListTable from './components/DigestListTable/DigestListTable'
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ export default function DigestListPage(props: DigestListPageProps): JSX.Element
|
||||||
refetch
|
refetch
|
||||||
} = useGetDockerArtifactManifestsQuery({
|
} = useGetDockerArtifactManifestsQuery({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(artifact),
|
artifact: encodeRef(artifact),
|
||||||
version
|
version
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import CreateRepositoryWidget from '@ar/frameworks/RepositoryStep/CreateReposito
|
||||||
|
|
||||||
import { REPO_KEY_REGEX } from '@ar/constants'
|
import { REPO_KEY_REGEX } from '@ar/constants'
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
|
import { decodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { useGetSpaceRef } from '@ar/hooks'
|
import { useGetSpaceRef } from '@ar/hooks'
|
||||||
import type { FormikFowardRef } from '@ar/common/types'
|
import type { FormikFowardRef } from '@ar/common/types'
|
||||||
import { RepositoryPackageType, RepositoryConfigType } from '@ar/common/types'
|
import { RepositoryPackageType, RepositoryConfigType } from '@ar/common/types'
|
||||||
|
@ -137,7 +138,7 @@ function RepositoryCreateForm(props: RepositoryCreateFormProps, formikRef: Formi
|
||||||
const response = await createRepository({
|
const response = await createRepository({
|
||||||
body: {
|
body: {
|
||||||
...formattedValuesForCleanupPolicy,
|
...formattedValuesForCleanupPolicy,
|
||||||
parentRef: decodeURIComponent(parentRef)
|
parentRef: decodeRef(parentRef)
|
||||||
} as RegistryRequestRequestBody
|
} as RegistryRequestRequestBody
|
||||||
})
|
})
|
||||||
if (response.content.status === 'SUCCESS') {
|
if (response.content.status === 'SUCCESS') {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { Anonymous, UserPassword, useCreateRegistryMutation } from '@harnessio/r
|
||||||
|
|
||||||
import { useGetSpaceRef } from '@ar/hooks'
|
import { useGetSpaceRef } from '@ar/hooks'
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
|
import { decodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { setFormikRef } from '@ar/common/utils'
|
import { setFormikRef } from '@ar/common/utils'
|
||||||
import { REPO_KEY_REGEX, URL_REGEX } from '@ar/constants'
|
import { REPO_KEY_REGEX, URL_REGEX } from '@ar/constants'
|
||||||
import { Separator } from '@ar/components/Separator/Separator'
|
import { Separator } from '@ar/components/Separator/Separator'
|
||||||
|
@ -138,7 +139,7 @@ function UpstreamProxyCreateForm(props: UpstreamProxyCreateFormProps, formikRef:
|
||||||
const response = await createUpstreamProxy({
|
const response = await createUpstreamProxy({
|
||||||
body: {
|
body: {
|
||||||
...values,
|
...values,
|
||||||
parentRef: decodeURIComponent(spaceRef)
|
parentRef: decodeRef(spaceRef)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (response.content.status === 'SUCCESS') {
|
if (response.content.status === 'SUCCESS') {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { defaultTo } from 'lodash-es'
|
||||||
import { Page } from '@harnessio/uicore'
|
import { Page } from '@harnessio/uicore'
|
||||||
import { useGetDockerArtifactManifestQuery } from '@harnessio/react-har-service-client'
|
import { useGetDockerArtifactManifestQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
||||||
import { useDecodedParams, useGetSpaceRef, useParentHooks } from '@ar/hooks'
|
import { useDecodedParams, useGetSpaceRef, useParentHooks } from '@ar/hooks'
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ export default function DockerManifestDetailsContent(): JSX.Element {
|
||||||
} = useGetDockerArtifactManifestQuery(
|
} = useGetDockerArtifactManifestQuery(
|
||||||
{
|
{
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(pathParams.artifactIdentifier),
|
artifact: encodeRef(pathParams.artifactIdentifier),
|
||||||
version: pathParams.versionIdentifier,
|
version: pathParams.versionIdentifier,
|
||||||
queryParams: {
|
queryParams: {
|
||||||
digest
|
digest
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { Card, Layout, Page, Text } from '@harnessio/uicore'
|
||||||
import { useGetDockerArtifactLayersQuery } from '@harnessio/react-har-service-client'
|
import { useGetDockerArtifactLayersQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
||||||
import { useDecodedParams, useGetSpaceRef, useParentHooks } from '@ar/hooks'
|
import { useDecodedParams, useGetSpaceRef, useParentHooks } from '@ar/hooks'
|
||||||
import LayersTable from './components/LayersTable/LayersTable'
|
import LayersTable from './components/LayersTable/LayersTable'
|
||||||
|
@ -43,7 +43,7 @@ export default function DockerVersionLayersContent(): JSX.Element {
|
||||||
} = useGetDockerArtifactLayersQuery(
|
} = useGetDockerArtifactLayersQuery(
|
||||||
{
|
{
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(pathParams.artifactIdentifier),
|
artifact: encodeRef(pathParams.artifactIdentifier),
|
||||||
version: pathParams.versionIdentifier,
|
version: pathParams.versionIdentifier,
|
||||||
queryParams: {
|
queryParams: {
|
||||||
digest
|
digest
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { Card, Container, Layout, Page, Text } from '@harnessio/uicore'
|
||||||
import { useGetDockerArtifactDetailsQuery } from '@harnessio/react-har-service-client'
|
import { useGetDockerArtifactDetailsQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
||||||
import { useDecodedParams, useGetSpaceRef, useParentHooks } from '@ar/hooks'
|
import { useDecodedParams, useGetSpaceRef, useParentHooks } from '@ar/hooks'
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ export default function DockerVersionOSSGeneralInfo({ className }: DockerVersion
|
||||||
} = useGetDockerArtifactDetailsQuery(
|
} = useGetDockerArtifactDetailsQuery(
|
||||||
{
|
{
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(pathParams.artifactIdentifier),
|
artifact: encodeRef(pathParams.artifactIdentifier),
|
||||||
version: pathParams.versionIdentifier,
|
version: pathParams.versionIdentifier,
|
||||||
queryParams: {
|
queryParams: {
|
||||||
digest
|
digest
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { Card, Container, Layout, Page, Text } from '@harnessio/uicore'
|
||||||
import { useGetDockerArtifactDetailsQuery } from '@harnessio/react-har-service-client'
|
import { useGetDockerArtifactDetailsQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { DEFAULT_DATE_TIME_FORMAT } from '@ar/constants'
|
import { DEFAULT_DATE_TIME_FORMAT } from '@ar/constants'
|
||||||
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
||||||
import { getReadableDateTime } from '@ar/common/dateUtils'
|
import { getReadableDateTime } from '@ar/common/dateUtils'
|
||||||
|
@ -47,7 +47,7 @@ export default function DockerVersionOverviewContent(): JSX.Element {
|
||||||
} = useGetDockerArtifactDetailsQuery(
|
} = useGetDockerArtifactDetailsQuery(
|
||||||
{
|
{
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(pathParams.artifactIdentifier),
|
artifact: encodeRef(pathParams.artifactIdentifier),
|
||||||
version: pathParams.versionIdentifier,
|
version: pathParams.versionIdentifier,
|
||||||
queryParams: {
|
queryParams: {
|
||||||
digest
|
digest
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { debounce } from 'lodash-es'
|
||||||
import { DropDown, SelectOption } from '@harnessio/uicore'
|
import { DropDown, SelectOption } from '@harnessio/uicore'
|
||||||
import { useGetDockerArtifactManifestsQuery } from '@harnessio/react-har-service-client'
|
import { useGetDockerArtifactManifestsQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
import { useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
import HeaderTitle from '@ar/components/Header/Title'
|
import HeaderTitle from '@ar/components/Header/Title'
|
||||||
|
@ -46,7 +46,7 @@ export default function ArchitectureSelector(props: ArchitectureSelectorProps):
|
||||||
error
|
error
|
||||||
} = useGetDockerArtifactManifestsQuery({
|
} = useGetDockerArtifactManifestsQuery({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(artifactIdentifier),
|
artifact: encodeRef(artifactIdentifier),
|
||||||
version: version
|
version: version
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { defaultTo } from 'lodash-es'
|
||||||
import { Page } from '@harnessio/uicore'
|
import { Page } from '@harnessio/uicore'
|
||||||
import { useGetHelmArtifactManifestQuery } from '@harnessio/react-har-service-client'
|
import { useGetHelmArtifactManifestQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
import { useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
||||||
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export default function HelmManifestDetailsContent(): JSX.Element {
|
||||||
refetch
|
refetch
|
||||||
} = useGetHelmArtifactManifestQuery({
|
} = useGetHelmArtifactManifestQuery({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(pathParams.artifactIdentifier),
|
artifact: encodeRef(pathParams.artifactIdentifier),
|
||||||
version: pathParams.versionIdentifier
|
version: pathParams.versionIdentifier
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ import { FontVariation } from '@harnessio/design-system'
|
||||||
import { Card, Container, Layout, Page, Text } from '@harnessio/uicore'
|
import { Card, Container, Layout, Page, Text } from '@harnessio/uicore'
|
||||||
import { useGetHelmArtifactDetailsQuery } from '@harnessio/react-har-service-client'
|
import { useGetHelmArtifactDetailsQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
||||||
import { useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
import { useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ export default function HelmVersionOSSGeneralInfo(props: HelmVersionOSSGeneralIn
|
||||||
refetch
|
refetch
|
||||||
} = useGetHelmArtifactDetailsQuery({
|
} = useGetHelmArtifactDetailsQuery({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(pathParams.artifactIdentifier),
|
artifact: encodeRef(pathParams.artifactIdentifier),
|
||||||
version: pathParams.versionIdentifier
|
version: pathParams.versionIdentifier
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ import { FontVariation } from '@harnessio/design-system'
|
||||||
import { Card, Container, Layout, Page, Text } from '@harnessio/uicore'
|
import { Card, Container, Layout, Page, Text } from '@harnessio/uicore'
|
||||||
import { useGetHelmArtifactDetailsQuery } from '@harnessio/react-har-service-client'
|
import { useGetHelmArtifactDetailsQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { DEFAULT_DATE_TIME_FORMAT } from '@ar/constants'
|
import { DEFAULT_DATE_TIME_FORMAT } from '@ar/constants'
|
||||||
import { getReadableDateTime } from '@ar/common/dateUtils'
|
import { getReadableDateTime } from '@ar/common/dateUtils'
|
||||||
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
||||||
|
@ -44,7 +44,7 @@ export default function HelmVersionOverviewContent(): JSX.Element {
|
||||||
refetch
|
refetch
|
||||||
} = useGetHelmArtifactDetailsQuery({
|
} = useGetHelmArtifactDetailsQuery({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(pathParams.artifactIdentifier),
|
artifact: encodeRef(pathParams.artifactIdentifier),
|
||||||
version: pathParams.versionIdentifier
|
version: pathParams.versionIdentifier
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { GetAllArtifactVersionsOkResponse, getAllArtifactVersions } from '@harne
|
||||||
|
|
||||||
import { useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
import { useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import HeaderTitle from '@ar/components/Header/Title'
|
import HeaderTitle from '@ar/components/Header/Title'
|
||||||
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
import type { VersionDetailsPathParams } from '@ar/routes/types'
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ export default function VersionSelector(props: VersionSelectorProps): JSX.Elemen
|
||||||
const refetchAllVersions = (): Promise<GetAllArtifactVersionsOkResponse> => {
|
const refetchAllVersions = (): Promise<GetAllArtifactVersionsOkResponse> => {
|
||||||
return getAllArtifactVersions({
|
return getAllArtifactVersions({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(artifactIdentifier),
|
artifact: encodeRef(artifactIdentifier),
|
||||||
queryParams: {
|
queryParams: {
|
||||||
size: 100,
|
size: 100,
|
||||||
page: 0,
|
page: 0,
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { Page } from '@harnessio/uicore'
|
||||||
import { ArtifactVersionSummary, useGetArtifactVersionSummaryQuery } from '@harnessio/react-har-service-client'
|
import { ArtifactVersionSummary, useGetArtifactVersionSummaryQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { useGetSpaceRef } from '@ar/hooks'
|
import { useGetSpaceRef } from '@ar/hooks'
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
|
|
||||||
import css from '../VersionDetails.module.scss'
|
import css from '../VersionDetails.module.scss'
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ const VersionProvider: FC<PropsWithChildren<VersionProviderSpcs>> = ({
|
||||||
refetch
|
refetch
|
||||||
} = useGetArtifactVersionSummaryQuery({
|
} = useGetArtifactVersionSummaryQuery({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(artifactKey),
|
artifact: encodeRef(artifactKey),
|
||||||
version: versionKey
|
version: versionKey
|
||||||
})
|
})
|
||||||
const responseData = data?.content?.data
|
const responseData = data?.content?.data
|
||||||
|
|
|
@ -20,8 +20,8 @@ import { Expander } from '@blueprintjs/core'
|
||||||
import { Button, ButtonVariation, ExpandingSearchInput, ExpandingSearchInputHandle, Page } from '@harnessio/uicore'
|
import { Button, ButtonVariation, ExpandingSearchInput, ExpandingSearchInputHandle, Page } from '@harnessio/uicore'
|
||||||
import { PackageType, useGetAllArtifactVersionsQuery } from '@harnessio/react-har-service-client'
|
import { PackageType, useGetAllArtifactVersionsQuery } from '@harnessio/react-har-service-client'
|
||||||
|
|
||||||
import { encodePathParams } from '@ar/routes/utils'
|
|
||||||
import { useStrings } from '@ar/frameworks/strings'
|
import { useStrings } from '@ar/frameworks/strings'
|
||||||
|
import { encodeRef } from '@ar/hooks/useGetSpaceRef'
|
||||||
import { useParentHooks, useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
import { useParentHooks, useDecodedParams, useGetSpaceRef } from '@ar/hooks'
|
||||||
import type { RepositoryPackageType } from '@ar/common/types'
|
import type { RepositoryPackageType } from '@ar/common/types'
|
||||||
import type { ArtifactDetailsPathParams } from '@ar/routes/types'
|
import type { ArtifactDetailsPathParams } from '@ar/routes/types'
|
||||||
|
@ -65,7 +65,7 @@ function VersionListPage(props: VersionListPageProps): JSX.Element {
|
||||||
error
|
error
|
||||||
} = useGetAllArtifactVersionsQuery({
|
} = useGetAllArtifactVersionsQuery({
|
||||||
registry_ref: spaceRef,
|
registry_ref: spaceRef,
|
||||||
artifact: encodePathParams(pathParams.artifactIdentifier),
|
artifact: encodeRef(pathParams.artifactIdentifier),
|
||||||
queryParams: {
|
queryParams: {
|
||||||
page,
|
page,
|
||||||
size,
|
size,
|
||||||
|
|
Loading…
Reference in New Issue