// GetCloneCreatorOwnership returns the appropriate ownership for the
// new snapshot and if an update is required
552553
func (v *VolumeSpec) GetCloneCreatorOwnership(ctx context.Context) (*Ownership, bool) {
	o := v.GetOwnership()

	// If there is user information, then auth is enabled
	if userinfo, ok := auth.NewUserInfoFromContext(ctx); ok {

		// Check if the owner is the one who cloned it
		if o != nil && o.IsOwner(userinfo) {
			return o, false
		}

		// Not the same owner, we now need new ownership.
		// This works for public volumes also.
		return OwnershipSetUsernameFromContext(ctx, nil), true
	}

	return o, false
}
209014
func (m *Manager) SaveOwner(organization *Organization, owner string) error {
	return m.collection.Update(
		bson.M{"globalid": organization.Globalid},
		bson.M{"$addToSet": bson.M{"owners": owner}})
}
198504
func (s *service) GetResourceOwnerId(email string) (userId uint) {
	entity, err := s.repo.FindByEmail(email)
	if err != nil {
		return 0
	}
	return entity.ID
}
311827
func (m *mockManager) CampaignOwner(_ context.Context) error {
	m.toBeOwner()
	return nil
}
127991
func (m *MockAuthorizer) AuthOwner(arg0 names_v2.Tag) bool {
	ret := m.ctrl.Call(m, "AuthOwner", arg0)
	ret0, _ := ret[0].(bool)
	return ret0
}
1233647
func (s *UserDefinedFunction) SetOwnerType(v string) *UserDefinedFunction {
	s.OwnerType = &v
	return s
}
373662
func (s *service) GetResourceOwnerId(token string) (rest.ResponseDTOUserInfo, *servicehelper.Error) {
	accessToken, err := s.repo.FindByAccessToken(token)
	if err != nil {
		return rest.ResponseDTOUserInfo{}, &servicehelper.Error{
			Param:  "access_token",
			Detail: errors.New("failed to retrieve access token"),
		}
	}
	return rest.ResponseDTOUserInfo{
		UserId: accessToken.UserId,
	}, nil
}
919579
func (net *Network) GetOrCreateConn(oneID, otherID enode.ID) (*Conn, error) {
	net.lock.Lock()
	defer net.lock.Unlock()
	return net.getOrCreateConn(oneID, otherID)
}
153283
func OwnerCreateSignedCCDepSpec(cds *peer.ChaincodeDeploymentSpec, instPolicy *common.SignaturePolicyEnvelope, owner msp.SigningIdentity) (*common.Envelope, error) {
	if cds == nil {
		return nil, fmt.Errorf("invalid chaincode deployment spec")
	}

	if instPolicy == nil {
		return nil, fmt.Errorf("must provide an instantiation policy")
	}

	cdsbytes := utils.MarshalOrPanic(cds)

	instpolicybytes := utils.MarshalOrPanic(instPolicy)

	var endorsements []*peer.Endorsement
	//it is not mandatory (at this utils level) to have a signature
	//this is especially convenient during dev/test
	//it may be necessary to enforce it via a policy at a higher level
	if owner != nil {
		// serialize the signing identity
		endorser, err := owner.Serialize()
		if err != nil {
			return nil, fmt.Errorf("Could not serialize the signing identity for %s, err %s", owner.GetIdentifier(), err)
		}

		// sign the concatenation of cds, instpolicy and the serialized endorser identity with this endorser's key
		signature, err := owner.Sign(append(cdsbytes, append(instpolicybytes, endorser...)...))
		if err != nil {
			return nil, fmt.Errorf("Could not sign the ccpackage, err %s", err)
		}

		// each owner starts off the endorsements with one element. All such endorsed
		// packages will be collected in a final package by CreateSignedCCDepSpecForInstall
		// when endorsements will have all the entries
		endorsements = make([]*peer.Endorsement, 1)

		endorsements[0] = &peer.Endorsement{Signature: signature, Endorser: endorser}
	}

	return createSignedCCDepSpec(cdsbytes, instpolicybytes, endorsements)
}
274304
func (c *Client) CreateModel(
	name, owner, cloud, cloudRegion string,
	cloudCredential names.CloudCredentialTag,
	config map[string]interface{},
) (base.ModelInfo, error) {
	var result base.ModelInfo
	if !names.IsValidUser(owner) {
		return result, errors.Errorf("invalid owner name %q", owner)
	}
	var cloudTag string
	if cloud != "" {
		if !names.IsValidCloud(cloud) {
			return result, errors.Errorf("invalid cloud name %q", cloud)
		}
		cloudTag = names.NewCloudTag(cloud).String()
	}
	var cloudCredentialTag string
	if cloudCredential != (names.CloudCredentialTag{}) {
		cloudCredentialTag = cloudCredential.String()
	}
	createArgs := params.ModelCreateArgs{
		Name:               name,
		OwnerTag:           names.NewUserTag(owner).String(),
		Config:             config,
		CloudTag:           cloudTag,
		CloudRegion:        cloudRegion,
		CloudCredentialTag: cloudCredentialTag,
	}
	var modelInfo params.ModelInfo
	err := c.facade.FacadeCall("CreateModel", createArgs, &modelInfo)
	if err != nil {
		// We don't want the message to contain the "(already exists)" suffix.
		if rpcErr, ok := errors.Cause(err).(*rpc.RequestError); ok {
			return result, errors.New(rpcErr.Message)
		}
		return result, errors.Trace(err)
	}
	return convertParamsModelInfo(modelInfo)
}
1047096
func (_ENS *ENSTransactor) SetOwner(opts *bind.TransactOpts, node [32]byte, owner common.Address) (*types.Transaction, error) {
	return _ENS.contract.Transact(opts, "setOwner", node, owner)
}
524110
func (c *WorkitemController) WorkitemCreatorOrSpaceOwner(ctx context.Context, spaceID uuid.UUID, creatorID uuid.UUID, editorID uuid.UUID) error {
	// check if workitem editor is same as workitem creator
	if editorID == creatorID {
		return nil
	}
	space, err := c.db.Spaces().Load(ctx, spaceID)
	if err != nil {
		return errors.NewNotFoundError("space", spaceID.String())
	}
	// check if workitem editor is same as space owner
	if space != nil && editorID == space.OwnerID {
		return nil
	}
	return errors.NewForbiddenError("user is not a workitem creator or space owner")
}
1192996
func (c *Changelog) GetVersionOrCreate(versionNum string) *Version {
	version := c.GetVersion(versionNum)
	if version == nil {
		version = NewVersion(versionNum)
		c.Versions = append([]*Version{version}, c.Versions...)
	}
	return version
}
458699
func GetUpdater(owner string, repo string, currentReleaseVersion string) (*Updater, error) {
	client := github.NewClient(nil) // unuthenticated client, 60 req/hour
	///TODO: rate limit error catching( impossible to same client checks 60 times for github updates, but we should do that check)

	// assign a new instace of context to support go-github's current API (https://github.com/google/go-github/issues/526)
	ctx := context.TODO()
	
	// get the latest release, delay depends on the user's internet connection's download speed
	latestRelease, response, err := client.Repositories.GetLatestRelease(ctx, owner, repo)
	if err != nil {
		return nil, errCantFetchRepo.Format(owner+":"+repo, err)
	}

	if c := response.StatusCode; c != 200 && c != 201 && c != 202 && c != 301 && c != 302 && c == 304 {
		return nil, errAccessRepo
	}

	currentVersion, err := version.NewVersion(currentReleaseVersion)
	if err != nil {
		return nil, err
	}

	latestVersion, err := version.NewVersion(*latestRelease.TagName)
	if err != nil {
		return nil, err
	}

	u := &Updater{
		currentVersion: currentVersion,
		latestVersion:  latestVersion,
		owner:          owner,
		repo:           repo,
	}

	return u, nil
}
406418
func (s *AllocatePublicVirtualInterfaceInput) SetOwnerAccount(v string) *AllocatePublicVirtualInterfaceInput {
	s.OwnerAccount = &v
	return s
}
282681
func GetInstanceProviderID(ctx context.Context, cloud Interface, nodeName types.NodeName) (string, error) {
	instances, ok := cloud.Instances()
	if !ok {
		return "", fmt.Errorf("failed to get instances from cloud provider")
	}
	instanceID, err := instances.InstanceID(ctx, nodeName)
	if err != nil {
		return "", fmt.Errorf("failed to get instance ID from cloud provider: %v", err)
	}
	return cloud.ProviderName() + "://" + instanceID, nil
}
206129
func (b *lowBuilder) searchOwner() (owner *serverconfig.Owner, err error) {
	if b.high.Identity == "" {
		return nil, errNoOwner
	}
	if b.high.IdentitySecretRing == "" {
		return nil, errNoOwner
	}
	return &serverconfig.Owner{
		Identity:    b.high.Identity,
		SecringFile: b.high.IdentitySecretRing,
	}, nil
}