Skip to content

Commit

Permalink
rename to DisableExtraIdentityDefaulting
Browse files Browse the repository at this point in the history
  • Loading branch information
mandelsoft committed Jan 7, 2025
1 parent b0ac2bd commit 388cf95
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions api/ocm/cpi/modopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func NewTargetElementOptions(list ...TargetElementOption) *TargetElementOptions
return &m
}

func RawIdentity(flag ...bool) internal.TargetOptionImpl {
return internal.RawIdentity(flag...)
func DisableExtraIdentityDefaulting(flag ...bool) internal.TargetOptionImpl {
return internal.DisableExtraIdentityDefaulting(flag...)
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions api/ocm/cpi/repocpi/view_cv.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (c *componentVersionAccessView) SetResource(meta *cpi.ResourceMeta, acc com
} else {
cd.Resources[idx] = *res
}
if opts.IsModifyElement() && !opts.IsRawIdentity() {
if opts.IsModifyElement() && !opts.IsDisableExtraIdentityDefaulting() {
// default handling for completing an extra identity for modifications, only.
compdesc.DefaultResources(cd)
}
Expand Down Expand Up @@ -549,7 +549,7 @@ func (c *componentVersionAccessView) SetSource(meta *cpi.SourceMeta, acc compdes
} else {
cd.Sources[idx] = *res
}
if !opts.IsRawIdentity() {
if !opts.IsDisableExtraIdentityDefaulting() {
compdesc.DefaultSources(cd)
}
return c.bridge.Update(false)
Expand Down Expand Up @@ -587,7 +587,7 @@ func (c *componentVersionAccessView) SetReference(ref *cpi.ComponentReference, o
cd.References[idx].Equivalent(ref)
cd.References[idx] = *ref
}
if opts.IsModifyElement(moddef) && !opts.IsRawIdentity() {
if opts.IsModifyElement(moddef) && !opts.IsDisableExtraIdentityDefaulting() {
compdesc.DefaultReferences(cd)
}
return c.bridge.Update(false)
Expand Down
28 changes: 14 additions & 14 deletions api/ocm/internal/modopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ type TargetOptionImpl interface {
type TargetElementOptions struct {
TargetElement TargetElement

// RawIdentity disables the implicit defaulting of the extraIdentity.
// DisableExtraIdentityDefaulting disables the implicit defaulting of the extraIdentity.
// A transfer operation must set this flag to preserve the normalizations.
RawIdentity *bool
DisableExtraIdentityDefaulting *bool
}

type TargetElementOption interface {
Expand All @@ -132,11 +132,11 @@ func (m *TargetElementOptions) ApplyElementModificationOption(opts *ElementModif

func (m *TargetElementOptions) ApplyTargetOption(opts *TargetElementOptions) {
optionutils.Transfer(&opts.TargetElement, m.TargetElement)
optionutils.Transfer(&opts.RawIdentity, m.RawIdentity)
optionutils.Transfer(&opts.DisableExtraIdentityDefaulting, m.DisableExtraIdentityDefaulting)
}

func (m *TargetElementOptions) IsRawIdentity() bool {
return utils.AsBool(m.RawIdentity)
func (m *TargetElementOptions) IsDisableExtraIdentityDefaulting() bool {
return utils.AsBool(m.DisableExtraIdentityDefaulting)
}

func (m *TargetElementOptions) ApplyTargetOptions(list ...TargetElementOption) *TargetElementOptions {
Expand Down Expand Up @@ -364,27 +364,27 @@ func (m TargetIdentity) ApplyTargetOption(opts *TargetElementOptions) {

////////////////////////////////////////////////////////////////////////////////

type rawidentity bool
type disableextraidentitydefaulting bool

func (m rawidentity) ApplyBlobModificationOption(opts *BlobModificationOptions) {
func (m disableextraidentitydefaulting) ApplyBlobModificationOption(opts *BlobModificationOptions) {
m.ApplyModificationOption(&opts.ModificationOptions)
}

func (m rawidentity) ApplyModificationOption(opts *ModificationOptions) {
func (m disableextraidentitydefaulting) ApplyModificationOption(opts *ModificationOptions) {
m.ApplyTargetOption(&opts.TargetElementOptions)
}

func (m rawidentity) ApplyElementModificationOption(opts *ElementModificationOptions) {
func (m disableextraidentitydefaulting) ApplyElementModificationOption(opts *ElementModificationOptions) {
m.ApplyTargetOption(&opts.TargetElementOptions)
}

func (m rawidentity) ApplyTargetOption(opts *TargetElementOptions) {
opts.RawIdentity = utils.BoolP(m)
func (m disableextraidentitydefaulting) ApplyTargetOption(opts *TargetElementOptions) {
opts.DisableExtraIdentityDefaulting = utils.BoolP(m)
}

// RawIdentity disables the defaulting of the extra identity.
func RawIdentity(flag ...bool) TargetOptionImpl {
return rawidentity(utils.OptionalDefaultedBool(true, flag...))
// DisableExtraIdentityDefaulting disables the defaulting of the extra identity.
func DisableExtraIdentityDefaulting(flag ...bool) TargetOptionImpl {
return disableextraidentitydefaulting(utils.OptionalDefaultedBool(true, flag...))
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions api/ocm/modopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ func TargetIndex(idx int) internal.TargetOptionImpl {
return internal.TargetIndex(idx)
}

// RawIdentity disables the defaulting of the extra identity
func RawIdentity(flag ...bool) internal.TargetOptionImpl {
return internal.RawIdentity(flag...)
// DisableExtraIdentityDefaulting disables the defaulting of the extra identity
func DisableExtraIdentityDefaulting(flag ...bool) internal.TargetOptionImpl {
return internal.DisableExtraIdentityDefaulting(flag...)
}

const AppendElement = internal.TargetIndex(-1)
Expand Down
2 changes: 1 addition & 1 deletion api/ocm/tools/transfer/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func copyVersion(printer common.Printer, log logging.Logger, hist common.History
err = handler.HandleTransferResource(r, m, hint, t)
} else {
if err == nil { // old resource found -> keep current access method
t.SetResource(r.Meta(), old.Access, ocm.ModifyElement(), ocm.SkipVerify(), ocm.RawIdentity())
t.SetResource(r.Meta(), old.Access, ocm.ModifyElement(), ocm.SkipVerify(), ocm.DisableExtraIdentityDefaulting())
}
notifyArtifactInfo(printer, log, "resource", i, r.Meta(), hint, "already present")
}
Expand Down
4 changes: 2 additions & 2 deletions api/ocm/tools/transfer/transferhandler/standard/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (h *Handler) HandleTransferResource(r ocm.ResourceAccess, m cpi.AccessMetho
}
defer blob.Close()
return accessio.Retry(h.opts.GetRetries(), time.Second, func() error {
return t.SetResourceBlob(r.Meta(), blob, hint, h.GlobalAccess(t.GetContext(), m), ocm.SkipVerify(), ocm.RawIdentity())
return t.SetResourceBlob(r.Meta(), blob, hint, h.GlobalAccess(t.GetContext(), m), ocm.SkipVerify(), ocm.DisableExtraIdentityDefaulting())
})
}

Expand All @@ -98,7 +98,7 @@ func (h *Handler) HandleTransferSource(r ocm.SourceAccess, m cpi.AccessMethod, h
}
defer blob.Close()
return accessio.Retry(h.opts.GetRetries(), time.Second, func() error {
return t.SetSourceBlob(r.Meta(), blob, hint, h.GlobalAccess(t.GetContext(), m), ocm.RawIdentity())
return t.SetSourceBlob(r.Meta(), blob, hint, h.GlobalAccess(t.GetContext(), m), ocm.DisableExtraIdentityDefaulting())
})
}

Expand Down

0 comments on commit 388cf95

Please sign in to comment.