Skip to content

chore: cleanup migration + duplicate #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions api/config/cpi/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"encoding/json"

"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/optionutils"
"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/vfs"

"ocm.software/ocm/api/utils"
"ocm.software/ocm/api/utils/blobaccess/blobaccess"
)

Expand Down Expand Up @@ -76,5 +76,5 @@ func (k ContentSpec) Get() (interface{}, error) {
fs = osfs.New()
}

return utils.ReadFile(k.Path, fs)
return optionutils.ReadFile(k.Path, fs)
}
9 changes: 5 additions & 4 deletions api/config/internal/configtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"strings"

"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/general"
"github.com/mandelsoft/goutils/stringutils"
"github.com/modern-go/reflect2"

"ocm.software/ocm/api/utils"
"ocm.software/ocm/api/utils/runtime"
)

Expand Down Expand Up @@ -36,7 +37,7 @@ type configTypeScheme struct {
}

func NewConfigTypeScheme(defaultDecoder ConfigDecoder, base ...ConfigTypeScheme) ConfigTypeScheme {
scheme := runtime.MustNewDefaultTypeScheme[Config, ConfigType](&GenericConfig{}, true, defaultDecoder, utils.Optional(base...))
scheme := runtime.MustNewDefaultTypeScheme[Config, ConfigType](&GenericConfig{}, true, defaultDecoder, general.Optional(base...))
return &configTypeScheme{scheme}
}

Expand All @@ -54,7 +55,7 @@ type versionRegistry struct {
}

func NewStrictConfigTypeScheme(base ...ConfigTypeScheme) runtime.VersionedTypeRegistry[Config, ConfigType] {
scheme := runtime.MustNewDefaultTypeScheme[Config, ConfigType](nil, false, nil, utils.Optional(base...))
scheme := runtime.MustNewDefaultTypeScheme[Config, ConfigType](nil, false, nil, general.Optional(base...))
return &versionRegistry{scheme}
}

Expand All @@ -80,7 +81,7 @@ func (t *configTypeScheme) Usage() string {
for strings.HasSuffix(u, "\n") {
u = u[:len(u)-1]
}
s = fmt.Sprintf("%s\n- <code>%s</code>\n%s", s, ct.GetKind(), utils.IndentLines(u, " "))
s = fmt.Sprintf("%s\n- <code>%s</code>\n%s", s, ct.GetKind(), stringutils.IndentLines(u, " "))
}
return s + "\n"
}
Expand Down
8 changes: 4 additions & 4 deletions api/config/internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import (
"reflect"

"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/general"

"ocm.software/ocm/api/datacontext"
"ocm.software/ocm/api/utils"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/runtime"
)

// OCM_CONFIG_TYPE_SUFFIX is the standard suffix used for configuration
// types provided by this library.
const OCM_CONFIG_TYPE_SUFFIX = ".config" + common.OCM_TYPE_GROUP_SUFFIX
const OCM_CONFIG_TYPE_SUFFIX = ".config" + misc.OCM_TYPE_GROUP_SUFFIX

type ConfigSelector interface {
Select(Config) bool
Expand Down Expand Up @@ -157,7 +157,7 @@ type gcWrapper struct {
}

func newView(c *_context, ref ...bool) Context {
if utils.Optional(ref...) {
if general.Optional(ref...) {
return datacontext.FinalizedContext[gcWrapper](c)
}
return c
Expand Down
4 changes: 2 additions & 2 deletions api/credentials/builtin/github/ghcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"ocm.software/ocm/api/credentials/cpi"
"ocm.software/ocm/api/tech/oci/identity"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

const HOST = "ghcr.io"
Expand All @@ -23,7 +23,7 @@ func init() {
user = "any"
}
if src, err := cpi.DefaultContext.GetCredentialsForConsumer(id); err != nil || src == nil {
creds := cpi.NewCredentials(common.Properties{cpi.ATTR_IDENTITY_TOKEN: t, cpi.ATTR_USERNAME: user})
creds := cpi.NewCredentials(misc.Properties{cpi.ATTR_IDENTITY_TOKEN: t, cpi.ATTR_USERNAME: user})
cpi.DefaultContext.SetCredentialsForConsumer(id, creds)
}
}
Expand Down
4 changes: 2 additions & 2 deletions api/credentials/builtin/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"ocm.software/ocm/api/credentials/cpi"
"ocm.software/ocm/api/tech/github/identity"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

func init() {
Expand All @@ -15,7 +15,7 @@ func init() {
id := identity.GetConsumerId(us)

if src, err := cpi.DefaultContext.GetCredentialsForConsumer(id); err != nil || src == nil {
creds := cpi.NewCredentials(common.Properties{cpi.ATTR_TOKEN: t})
creds := cpi.NewCredentials(misc.Properties{cpi.ATTR_TOKEN: t})
cpi.DefaultContext.SetCredentialsForConsumer(id, creds)
}
}
Expand Down
8 changes: 4 additions & 4 deletions api/credentials/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
"ocm.software/ocm/api/credentials/extensions/repositories/aliases"
"ocm.software/ocm/api/credentials/extensions/repositories/directcreds"
"ocm.software/ocm/api/credentials/extensions/repositories/memory"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/runtime"
)

var DefaultContext = credentials.New()

var _ = Describe("generic credentials", func() {
props := common.Properties{
props := misc.Properties{
"user": "USER",
"password": "PASSWORD",
}
Expand Down Expand Up @@ -154,7 +154,7 @@ var _ = Describe("generic credentials", func() {
credentials.ID_TYPE: "mytype",
"host": "localhost",
}
props := common.Properties{"token": "mytoken"}
props := misc.Properties{"token": "mytoken"}
creds := directcreds.NewCredentials(props)
Expect(cfg.AddConsumer(consumer, creds)).To(Succeed())

Expand Down Expand Up @@ -182,7 +182,7 @@ type: credentials.config.ocm.software
})

It("applies a config for consumers", func() {
props := common.Properties{"token": "mytoken"}
props := misc.Properties{"token": "mytoken"}
consumer := credentials.ConsumerIdentity{
credentials.ID_TYPE: "mytype",
"host": "localhost",
Expand Down
4 changes: 2 additions & 2 deletions api/credentials/cpi/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package cpi
import (
"ocm.software/ocm/api/credentials/internal"
"ocm.software/ocm/api/datacontext"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

const (
Expand Down Expand Up @@ -83,7 +83,7 @@ func RegisterStandardIdentity(typ string, matcher IdentityMatcher, desc string,
internal.StandardIdentityMatchers.Register(typ, matcher, desc, attrs)
}

func NewCredentials(props common.Properties) Credentials {
func NewCredentials(props misc.Properties) Credentials {
return internal.NewCredentials(props)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (

"ocm.software/ocm/api/credentials"
local "ocm.software/ocm/api/credentials/extensions/repositories/aliases"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

var DefaultContext = credentials.New()

var _ = Describe("alias credentials", func() {
props := common.Properties{
props := misc.Properties{
"user": "USER",
"password": "PASSWORD",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package directcreds

import (
"ocm.software/ocm/api/credentials/cpi"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

func NewCredentials(props common.Properties) cpi.CredentialsSpec {
func NewCredentials(props misc.Properties) cpi.CredentialsSpec {
return cpi.NewCredentialsSpec(Type, NewRepositorySpec(props))
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (

"ocm.software/ocm/api/credentials"
"ocm.software/ocm/api/credentials/extensions/repositories/directcreds"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

var DefaultContext = credentials.New()

var _ = Describe("direct credentials", func() {
props := common.Properties{
props := misc.Properties{
"user": "USER",
"password": "PASSWORD",
}
Expand Down
6 changes: 3 additions & 3 deletions api/credentials/extensions/repositories/directcreds/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package directcreds

import (
"ocm.software/ocm/api/credentials/cpi"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/runtime"
)

Expand All @@ -19,7 +19,7 @@ func init() {
// RepositorySpec describes a repository interface for single direct credentials.
type RepositorySpec struct {
runtime.ObjectVersionedType `json:",inline"`
Properties common.Properties `json:"properties"`
Properties misc.Properties `json:"properties"`
}

var (
Expand All @@ -28,7 +28,7 @@ var (
)

// NewRepositorySpec creates a new RepositorySpec.
func NewRepositorySpec(credentials common.Properties) *RepositorySpec {
func NewRepositorySpec(credentials misc.Properties) *RepositorySpec {
return &RepositorySpec{
ObjectVersionedType: runtime.NewVersionedTypedObject(Type),
Properties: credentials,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/mandelsoft/goutils/set"

"ocm.software/ocm/api/credentials/cpi"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

type Credentials struct {
Expand All @@ -27,10 +27,10 @@ func NewCredentials(cfg *configfile.ConfigFile, name string, store dockercred.St
}
}

func (c *Credentials) get() common.Properties {
func (c *Credentials) get() misc.Properties {
auth, err := c.config.GetAuthConfig(c.name)
if err != nil {
return common.Properties{}
return misc.Properties{}
}
return newCredentials(auth).Properties()
}
Expand Down Expand Up @@ -62,6 +62,6 @@ func (c *Credentials) PropertyNames() set.Set[string] {
return c.get().Names()
}

func (c *Credentials) Properties() common.Properties {
func (c *Credentials) Properties() misc.Properties {
return c.get()
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ import (
local "ocm.software/ocm/api/credentials/extensions/repositories/dockerconfig"
"ocm.software/ocm/api/datacontext"
"ocm.software/ocm/api/tech/oci/identity"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/runtimefinalizer"
)

var _ = Describe("docker config", func() {
props := common.Properties{
props := misc.Properties{
"username": "mandelsoft",
"password": "password",
"serverAddress": "https://index.docker.io/v1/",
}

props2 := common.Properties{
props2 := misc.Properties{
"username": "mandelsoft",
"password": "token",
"serverAddress": "https://ghcr.io",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/config/types"
"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/ioutils"

"ocm.software/ocm/api/credentials/cpi"
"ocm.software/ocm/api/datacontext"
"ocm.software/ocm/api/utils"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/runtimefinalizer"
)

Expand Down Expand Up @@ -87,7 +87,7 @@ func (r *Repository) Read(force bool) error {
id runtimefinalizer.ObjectIdentity
)
if r.path != "" {
path, err := utils.ResolvePath(r.path)
path, err := ioutils.ResolvePath(r.path)
if err != nil {
return errors.Wrapf(err, "cannot resolve path %q", r.path)
}
Expand All @@ -113,7 +113,7 @@ func (r *Repository) Read(force bool) error {
}

func newCredentials(auth types.AuthConfig) cpi.Credentials {
props := common.Properties{
props := misc.Properties{
cpi.ATTR_USERNAME: norm(auth.Username),
cpi.ATTR_PASSWORD: norm(auth.Password),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"encoding/json"
"fmt"

"github.com/mandelsoft/goutils/general"
"github.com/mandelsoft/goutils/generics"
"github.com/mandelsoft/goutils/optionutils"

"ocm.software/ocm/api/credentials/cpi"
"ocm.software/ocm/api/utils"
"ocm.software/ocm/api/utils/runtime"
)

Expand Down Expand Up @@ -38,7 +39,7 @@ func (s RepositorySpec) WithConsumerPropagation(propagate bool) *RepositorySpec
func NewRepositorySpec(path string, prop ...bool) *RepositorySpec {
var p *bool
if len(prop) > 0 {
p = generics.Pointer(utils.Optional(prop...))
p = generics.PointerTo(general.Optional(prop...))
}
if path == "" {
path = "~/.docker/config.json"
Expand All @@ -53,7 +54,7 @@ func NewRepositorySpec(path string, prop ...bool) *RepositorySpec {
func NewRepositorySpecForConfig(data []byte, prop ...bool) *RepositorySpec {
var p *bool
if len(prop) > 0 {
p = generics.Pointer(utils.Optional(prop...))
p = generics.PointerTo(general.Optional(prop...))
}
return &RepositorySpec{
ObjectVersionedType: runtime.NewVersionedTypedObject(Type),
Expand All @@ -72,5 +73,5 @@ func (a *RepositorySpec) Repository(ctx cpi.Context, creds cpi.Credentials) (cpi
if !ok {
return nil, fmt.Errorf("failed to assert type %T to Repositories", r)
}
return repos.GetRepository(ctx, a.DockerConfigFile, a.DockerConfig, utils.AsBool(a.PropgateConsumerIdentity, true))
return repos.GetRepository(ctx, a.DockerConfigFile, a.DockerConfig, optionutils.AsBool(a.PropgateConsumerIdentity, true))
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"ocm.software/ocm/api/credentials/identity/hostpath"
"ocm.software/ocm/api/tech/oci/identity"
"ocm.software/ocm/api/utils"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

func init() {
Expand Down Expand Up @@ -90,7 +90,7 @@ func (h Handler) ParseConfig(configReader io.Reader) ([]gardenercfgcpi.Credentia
}

func newCredentialsFromContainerRegistryCredentials(auth *containerRegistryCredentials) cpi.Credentials {
props := common.Properties{
props := misc.Properties{
cpi.ATTR_USERNAME: auth.Username,
cpi.ATTR_PASSWORD: auth.Password,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"ocm.software/ocm/api/credentials/identity/hostpath"
"ocm.software/ocm/api/utils"
"ocm.software/ocm/api/utils/listformat"
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/misc"
)

const CONSUMER_TYPE = "Buildcredentials" + common.OCM_TYPE_GROUP_SUFFIX
const CONSUMER_TYPE = "Buildcredentials" + misc.OCM_TYPE_GROUP_SUFFIX

// used identity attributes.
const (
Expand Down
Loading
Loading