// CreateRepository provides a mock function with given fields: ctx, r
170830
func (_m *ArgoDB) CreateRepository(ctx context.Context, r *v1alpha1.Repository) (*v1alpha1.Repository, error) {
	ret := _m.Called(ctx, r)

	var r0 *v1alpha1.Repository
	if rf, ok := ret.Get(0).(func(context.Context, *v1alpha1.Repository) *v1alpha1.Repository); ok {
		r0 = rf(ctx, r)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*v1alpha1.Repository)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, *v1alpha1.Repository) error); ok {
		r1 = rf(ctx, r)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
667276
func NewRepository(db *gorm.DB) *GormRepository {
	return &GormRepository{
		db:   db,
		winr: numbersequence.NewWorkItemNumberSequenceRepository(db),
	}
}
473848
func (m *GormUserRepository) Create(ctx context.Context, u *User) error {
	defer goa.MeasureSince([]string{"goa", "db", "user", "create"}, time.Now())
	if u.ID == uuid.Nil {
		u.ID = uuid.NewV4()
	}

	err := m.db.Create(u).Error
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"user_id": u.ID,
			"err":     err,
		}, "unable to create the user")
		return errs.WithStack(err)
	}
	log.Debug(ctx, map[string]interface{}{
		"user_id": u.ID,
	}, "User created!")
	return nil
}
1322904
func NewRepository() *Repository {
	repo := Repository{
		channel:       params.StableChannel,
		charms:        make(map[params.Channel]map[charm.URL]charm.Charm),
		bundles:       make(map[params.Channel]map[charm.URL]charm.Bundle),
		resources:     make(map[params.Channel]map[charm.URL][]params.Resource),
		revisions:     make(map[params.Channel]map[charm.URL]int),
		added:         make(map[string][]charm.URL),
		resourcesData: make(datastore),
		published:     make(map[params.Channel]set.Strings),
	}
	for _, channel := range params.OrderedChannels {
		repo.charms[channel] = make(map[charm.URL]charm.Charm)
		repo.bundles[channel] = make(map[charm.URL]charm.Bundle)
		repo.resources[channel] = make(map[charm.URL][]params.Resource)
		repo.revisions[channel] = make(map[charm.URL]int)
		repo.published[channel] = set.NewStrings()
	}
	return &repo
}
252598
func (h Home) LocalRepository(elem ...string) string {
	p := []string{"repository", "local"}
	p = append(p, elem...)
	return h.Path(p...)
}
490824
func (config *Config) AddPluginRepository(name string, url string) {
	config.ConfigFile.PluginRepositories = append(config.ConfigFile.PluginRepositories,
		PluginRepository{Name: name, URL: url})
}
1364432
func (s *Server) Create(ctx context.Context, q *RepoCreateRequest) (*appsv1.Repository, error) {
	if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionCreate, q.Repo.Repo); err != nil {
		return nil, err
	}
	r := q.Repo
	err := git.TestRepo(r.Repo, r.Username, r.Password, r.SSHPrivateKey, r.InsecureIgnoreHostKey)
	if err != nil {
		return nil, err
	}

	r.ConnectionState = appsv1.ConnectionState{Status: appsv1.ConnectionStatusSuccessful}
	repo, err := s.db.CreateRepository(ctx, r)
	if status.Convert(err).Code() == codes.AlreadyExists {
		// act idempotent if existing spec matches new spec
		existing, getErr := s.db.GetRepository(ctx, r.Repo)
		if getErr != nil {
			return nil, status.Errorf(codes.Internal, "unable to check existing repository details: %v", getErr)
		}

		// repository ConnectionState may differ, so make consistent before testing
		existing.ConnectionState = r.ConnectionState
		if reflect.DeepEqual(existing, r) {
			repo, err = existing, nil
		} else if q.Upsert {
			return s.Update(ctx, &RepoUpdateRequest{Repo: r})
		} else {
			return nil, status.Errorf(codes.InvalidArgument, "existing repository spec is different; use upsert flag to force update")
		}
	}
	return &appsv1.Repository{Repo: repo.Repo}, err
}
487064
func (m *MockLambdaAPI) CreateFunction(arg0 *lambda.CreateFunctionInput) (*lambda.FunctionConfiguration, error) {
	ret := m.ctrl.Call(m, "CreateFunction", arg0)
	ret0, _ := ret[0].(*lambda.FunctionConfiguration)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
773665
func (r *GormQueryRepository) Create(ctx context.Context, q *Query) error {
	defer goa.MeasureSince([]string{"goa", "db", "Query", "create"}, time.Now())
	q.ID = uuid.NewV4()
	if q.Creator == uuid.Nil {
		return errors.NewBadParameterError("creator cannot be nil", q.Creator).Expected("valid user ID")
	}
	var v map[string]interface{}
	if err := json.Unmarshal([]byte(q.Fields), &v); err != nil {
		return errors.NewBadParameterError("query field is invalid JSON syntax", q.Fields).Expected("valid JSON")
	}
	// Parse fields to make sure that query is valid
	exp, _, err := search.ParseFilterString(ctx, q.Fields)
	if err != nil || exp == nil {
		log.Error(ctx, map[string]interface{}{
			"space_id": q.SpaceID,
			"fields":   q.Fields,
		}, "unable to parse the query fields")
		return err
	}
	err = r.db.Create(q).Error
	if err != nil {
		if gormsupport.IsCheckViolation(err, "queries_title_check") {
			return errors.NewBadParameterError("Title", q.Title).Expected("not empty")
		}
		// combination of title, space ID and creator should be unique
		if gormsupport.IsUniqueViolation(err, "queries_title_space_id_creator_unique") {
			log.Error(ctx, map[string]interface{}{
				"err":      err,
				"title":    q.Title,
				"space_id": q.SpaceID,
			}, "unable to create query because a query with same title already exists in the space by same creator")
			return errors.NewDataConflictError(fmt.Sprintf("query already exists with title = %s , space_id = %s, creator = %s", q.Title, q.SpaceID, q.Creator))
		}
		log.Error(ctx, map[string]interface{}{}, "error adding Query: %s", err.Error())
		return err
	}
	return nil
}
1357352
func (m *GormRoleRepository) Create(ctx context.Context, u *Role) error {
	defer goa.MeasureSince([]string{"goa", "db", "role", "create"}, time.Now())
	if u.RoleID == uuid.Nil {
		u.RoleID = uuid.NewV4()
	}
	err := m.db.Create(u).Error
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"role_id": u.RoleID,
			"err":     err,
		}, "unable to create the role")
		if gormsupport.IsUniqueViolation(err, "uq_role_resource_type_name") {
			log.Error(ctx, map[string]interface{}{
				"err":              err,
				"role_name":        u.Name,
				"resource_type_id": u.ResourceTypeID,
			}, "unable to create role because the same role already exists for this resource_type")
			return errors.NewDataConflictError(fmt.Sprintf("role already exists with name = %s , resource_type_id = %s ", u.Name, u.ResourceTypeID.String()))
		}
		return errs.WithStack(err)
	}
	log.Debug(ctx, map[string]interface{}{
		"role_id": u.RoleID,
	}, "Role created!")
	return nil
}
626315
func (i *InstallationRepositoriesEvent) GetRepositorySelection() string {
	if i == nil || i.RepositorySelection == nil {
		return ""
	}
	return *i.RepositorySelection
}
636794
func (m *GormCommentRepository) Create(ctx context.Context, comment *Comment, creatorID uuid.UUID) error {
	defer goa.MeasureSince([]string{"goa", "db", "comment", "create"}, time.Now())
	comment.ID = uuid.NewV4()
	// make sure no comment is created with an empty 'markup' value
	if comment.Markup == "" {
		comment.Markup = rendering.SystemMarkupDefault
	}
	if err := m.db.Create(comment).Error; err != nil {
		log.Error(ctx, map[string]interface{}{
			"comment_id": comment.ID,
			"err":        err,
		}, "unable to create the comment")
		return errs.WithStack(err)
	}
	// save a revision of the created comment
	if err := m.revisionRepository.Create(ctx, creatorID, RevisionTypeCreate, *comment); err != nil {
		return errs.Wrapf(err, "error while creating comment")
	}
	log.Debug(ctx, map[string]interface{}{
		"comment_id": comment.ID,
	}, "Comment created!")

	return nil
}
1173193
func NewRepo() *Repo {
	r := &Repo{
		ids: map[namespace][]uuid.UUID{},
		db:  map[namespace]map[uuid.UUID]eh.Entity{},
	}
	return r
}
210402
func (m *MockEnviron) Create(arg0 context.ProviderCallContext, arg1 environs.CreateParams) error {
	ret := m.ctrl.Call(m, "Create", arg0, arg1)
	ret0, _ := ret[0].(error)
	return ret0
}
1267494
func (s *App) SetRepository(v string) *App {
	s.Repository = &v
	return s
}
903741
func (s *DeleteRepositoryOutput) SetRepository(v *Repository) *DeleteRepositoryOutput {
	s.Repository = v
	return s
}
1142518
func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, error) {
	body, err := json.Marshal(&opt)
	if err != nil {
		return nil, err
	}
	repo := new(Repository)
	return repo, c.getParsedResponse("POST", "/user/repos", jsonHeader, bytes.NewReader(body), repo)
}