diff --git a/pkg/contexts/credentials/builtin/helm/identity/identity.go b/pkg/contexts/credentials/builtin/helm/identity/identity.go index 9a568f16a4..586ab6054e 100644 --- a/pkg/contexts/credentials/builtin/helm/identity/identity.go +++ b/pkg/contexts/credentials/builtin/helm/identity/identity.go @@ -10,7 +10,6 @@ import ( "helm.sh/helm/v3/pkg/registry" "github.com/open-component-model/ocm/pkg/common" - "github.com/open-component-model/ocm/pkg/contexts/credentials" ociidentity "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" "github.com/open-component-model/ocm/pkg/contexts/credentials/cpi" "github.com/open-component-model/ocm/pkg/contexts/credentials/identity/hostpath" @@ -60,11 +59,11 @@ func IdentityMatcher(pattern, cur, id cpi.ConsumerIdentity) bool { // used credential attributes const ( - ATTR_USERNAME = credentials.ATTR_USERNAME - ATTR_PASSWORD = credentials.ATTR_PASSWORD - ATTR_CERTIFICATE_AUTHORITY = credentials.ATTR_CERTIFICATE_AUTHORITY - ATTR_CERTIFICATE = credentials.ATTR_CERTIFICATE - ATTR_PRIVATE_KEY = credentials.ATTR_PRIVATE_KEY + ATTR_USERNAME = cpi.ATTR_USERNAME + ATTR_PASSWORD = cpi.ATTR_PASSWORD + ATTR_CERTIFICATE_AUTHORITY = cpi.ATTR_CERTIFICATE_AUTHORITY + ATTR_CERTIFICATE = cpi.ATTR_CERTIFICATE + ATTR_PRIVATE_KEY = cpi.ATTR_PRIVATE_KEY ) func OCIRepoURL(repourl string, chartname string) string { @@ -76,7 +75,7 @@ func OCIRepoURL(repourl string, chartname string) string { } func SimpleCredentials(user, passwd string) cpi.Credentials { - return credentials.DirectCredentials{ + return cpi.DirectCredentials{ ATTR_USERNAME: user, ATTR_PASSWORD: passwd, } @@ -95,12 +94,12 @@ func GetConsumerId(repourl string, chartname string) cpi.ConsumerIdentity { } } -func GetCredentials(ctx credentials.ContextProvider, repourl string, chartname string) common.Properties { +func GetCredentials(ctx cpi.ContextProvider, repourl string, chartname string) common.Properties { id := GetConsumerId(repourl, chartname) if id == nil { return nil } - creds, err := credentials.CredentialsForConsumer(ctx.CredentialsContext(), id) + creds, err := cpi.CredentialsForConsumer(ctx.CredentialsContext(), id) if creds == nil || err != nil { return nil } diff --git a/pkg/contexts/credentials/cpi/const.go b/pkg/contexts/credentials/cpi/const.go index 00d373d51f..86ebf23c33 100644 --- a/pkg/contexts/credentials/cpi/const.go +++ b/pkg/contexts/credentials/cpi/const.go @@ -20,4 +20,6 @@ const ( ATTR_REGISTRY_TOKEN = internal.ATTR_REGISTRY_TOKEN ATTR_KEY = internal.ATTR_KEY ATTR_CERTIFICATE_AUTHORITY = internal.ATTR_CERTIFICATE_AUTHORITY + ATTR_CERTIFICATE = internal.ATTR_CERTIFICATE + ATTR_PRIVATE_KEY = internal.ATTR_PRIVATE_KEY ) diff --git a/pkg/helm/identity/identity.go b/pkg/helm/identity/identity.go new file mode 100644 index 0000000000..7a43618dee --- /dev/null +++ b/pkg/helm/identity/identity.go @@ -0,0 +1,75 @@ +// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Open Component Model contributors. +// +// SPDX-License-Identifier: Apache-2.0 + +package identity + +import ( + "github.com/open-component-model/ocm/pkg/common" + "github.com/open-component-model/ocm/pkg/contexts/credentials" + helmidentity "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity" +) + +// CONSUMER_TYPE is the Helm chart repository type. +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +const CONSUMER_TYPE = helmidentity.CONSUMER_TYPE + +// ID_TYPE is the type field of a consumer identity. +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +const ID_TYPE = helmidentity.ID_PORT + +// ID_SCHEME is the scheme of the repository. +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +const ID_SCHEME = helmidentity.ID_SCHEME + +// ID_HOSTNAME is the hostname of a repository. +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +const ID_HOSTNAME = helmidentity.ID_HOSTNAME + +// ID_PORT is the port number of a repository. +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +const ID_PORT = helmidentity.ID_PORT + +// ID_PATHPREFIX is the path of a repository. +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +const ID_PATHPREFIX = helmidentity.ID_PATHPREFIX + +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +func IdentityMatcher(pattern, cur, id credentials.ConsumerIdentity) bool { + return helmidentity.IdentityMatcher(pattern, cur, id) +} + +// used credential attributes + +const ( + // Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. + ATTR_USERNAME = credentials.ATTR_USERNAME + // Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. + ATTR_PASSWORD = credentials.ATTR_PASSWORD + // Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. + ATTR_CERTIFICATE_AUTHORITY = credentials.ATTR_CERTIFICATE_AUTHORITY + // Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. + ATTR_CERTIFICATE = credentials.ATTR_CERTIFICATE + // Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. + ATTR_PRIVATE_KEY = credentials.ATTR_PRIVATE_KEY +) + +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +func OCIRepoURL(repourl string, chartname string) string { + return helmidentity.OCIRepoURL(repourl, chartname) +} + +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +func SimpleCredentials(user, passwd string) credentials.Credentials { + return helmidentity.SimpleCredentials(user, passwd) +} + +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +func GetConsumerId(repourl string, chartname string) credentials.ConsumerIdentity { + return helmidentity.GetConsumerId(repourl, chartname) +} + +// Deprecated: use package github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/helm/identity. +func GetCredentials(ctx credentials.ContextProvider, repourl string, chartname string) common.Properties { + return helmidentity.GetCredentials(ctx, repourl, chartname) +}