// SourceCode provides a mock function with given fields: repository, path, revision, submodule
342710
func (_m *Source) SourceCode(repository string, path string, revision string, submodule bool) error {
	ret := _m.Called(repository, path, revision, submodule)

	var r0 error
	if rf, ok := ret.Get(0).(func(string, string, string, bool) error); ok {
		r0 = rf(repository, path, revision, submodule)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
1069103
func (r *SourceRepository) LocalPath() (string, error) {
	if len(r.localDir) > 0 {
		return r.localDir, nil
	}
	if r.url.IsLocal() {
		r.localDir = filepath.Join(r.url.LocalPath(), r.contextDir)
	} else {
		gitRepo := git.NewRepository()
		var err error
		if r.localDir, err = ioutil.TempDir("", "gen"); err != nil {
			return "", err
		}
		r.localDir, err = CloneAndCheckoutSources(gitRepo, r.url.StringNoFragment(), r.url.URL.Fragment, r.localDir, r.contextDir)
		if err != nil {
			return "", err
		}
	}
	if _, err := os.Stat(r.localDir); os.IsNotExist(err) {
		return "", fmt.Errorf("supplied context directory '%s' does not exist in '%s'", r.contextDir, r.url.String())
	}
	return r.localDir, nil
}
447944
func (f *Function) DeployCode(zip []byte, config *lambda.GetFunctionOutput) error {
	remoteHash := *config.Configuration.CodeSha256
	localHash := utils.Sha256(zip)

	if localHash == remoteHash {
		f.Log.Info("code unchanged")

		version := config.Configuration.Version

		// Creating an alias to $LATEST would mean its tied to any future deploys.
		// To correct this behaviour, we take the latest version at the time of deploy.
		if *version == "$LATEST" {
			versions, err := f.versions()
			if err != nil {
				return err
			}

			version = versions[len(versions)-1].Version
		}

		return f.CreateOrUpdateAlias(f.Alias, *version)
	}

	f.Log.WithFields(log.Fields{
		"local":  localHash,
		"remote": remoteHash,
	}).Debug("code changed")

	return f.Update(zip)
}
278062
func BuildSource(s string) *Source {
	var result []string
	var lineBuf bytes.Buffer
	for _, runeValue := range s {
		lineBuf.WriteRune(runeValue)
		if runeValue == '\n' {
			result = append(result, lineBuf.String())
			lineBuf.Reset()
		}
	}
	rest := lineBuf.String()
	// Stuff after last end-of-line (EOF or some more code)
	result = append(result, rest+"\n")
	return &Source{result}
}
186189
func (fp *formatParser) codeCode(i int, r rune) error {
	fp.processCode(i)
	fp.start = i
	fp.code = (*formatParser).freshCode
	fp.next = (*formatParser).freshNext
	fp.end = (*formatParser).freshEnd
	return nil
}
199351
func (v *Validator) Code(att *design.AttributeDefinition, nonzero, required, hasDefault bool, target, context string, depth int, private bool) string {
	if _, ok := att.Metadata["struct:field:type"]; ok {
		// Skip validation generation for attributes with custom types
		return ""
	}
	buf := v.recurse(att, nonzero, required, hasDefault, target, context, depth, private)
	return buf.String()
}
307904
func NewRemoteConfigSource(source *apiv1.NodeConfigSource) (RemoteConfigSource, string, error) {
	// NOTE: Even though the API server validates the config, we check whether all *known* fields are
	// nil here, so that if a new API server allows a new config source type, old clients can send
	// an error message rather than crashing due to a nil pointer dereference.

	// Exactly one reference subfield of the config source must be non-nil.
	// Currently ConfigMap is the only reference subfield.
	if source.ConfigMap == nil {
		return nil, status.AllNilSubfieldsError, fmt.Errorf("%s, NodeConfigSource was: %#v", status.AllNilSubfieldsError, source)
	}
	return &remoteConfigMap{source}, "", nil
}
1055145
func (fn *ScriptFunction) Source() (interface{}, error) {
	source := make(map[string]interface{})
	if fn.script != nil {
		src, err := fn.script.Source()
		if err != nil {
			return nil, err
		}
		source["script"] = src
	}
	// Notice that the weight has to be serialized in FunctionScoreQuery.
	return source, nil
}
12306
func FormatSourceCode(filename string) {
	cmd := exec.Command("gofmt", "-w", filename)
	if err := cmd.Run(); err != nil {
		beeLogger.Log.Warnf("Error while running gofmt: %s", err)
	}
}
947483
func (e JSONCliError) ExitCode() int {
	if e.resp == nil {
		return 1
	}
	code := e.resp.HTTP.StatusCode
	if code >= 100 && code < 200 {
		return 10
	} else if code >= 200 && code < 300 {
		return 20
	} else if code >= 300 && code < 400 {
		return 30
	} else if code >= 400 && code < 500 {
		return 40
	} else if code >= 500 && code < 600 {
		return 50
	}
	return 2
}
304890
func (c *Context) Code(code int) (err error) {
	c.response.WriteHeader(code)
	return
}
896414
func addSourceEnvVars(source buildv1.BuildSource, output *[]corev1.EnvVar) {
	sourceVars := []corev1.EnvVar{}
	if source.Git != nil {
		sourceVars = append(sourceVars, corev1.EnvVar{Name: "SOURCE_REPOSITORY", Value: source.Git.URI})
		sourceVars = append(sourceVars, corev1.EnvVar{Name: "SOURCE_URI", Value: source.Git.URI})
	}
	if len(source.ContextDir) > 0 {
		sourceVars = append(sourceVars, corev1.EnvVar{Name: "SOURCE_CONTEXT_DIR", Value: source.ContextDir})
	}
	if source.Git != nil && len(source.Git.Ref) > 0 {
		sourceVars = append(sourceVars, corev1.EnvVar{Name: "SOURCE_REF", Value: source.Git.Ref})
	}
	*output = append(*output, sourceVars...)
}
287216
func (s *NestedSort) Source() (interface{}, error) {
	source := make(map[string]interface{})

	if s.path != "" {
		source["path"] = s.path
	}
	if s.filter != nil {
		src, err := s.filter.Source()
		if err != nil {
			return nil, err
		}
		source["filter"] = src
	}
	if s.nestedSort != nil {
		src, err := s.nestedSort.Source()
		if err != nil {
			return nil, err
		}
		source["nested"] = src
	}

	return source, nil
}
1126956
func (s *Version) SetSourceCodeUrl(v string) *Version {
	s.SourceCodeUrl = &v
	return s
}
697982
func main() {
	p := params{Timestamp: time.Now(), Name: "codegen"}
	for i := 0; i < numTypes; i++ {
		p.StringTypeNames = append(p.StringTypeNames, fmt.Sprintf("Test%03d", i))
	}

	baseDir, err := os.Getwd()
	die(err)
	baseDir = filepath.Join(baseDir, "..")

	fmt.Printf("Generating test files in %v\n", filepath.Join(baseDir, "_gen"))
	apath := filepath.Join(baseDir, "_gen", "A")

	_ = os.MkdirAll(apath, 0755)

	instantiateTemplate(modelTemplate, p, filepath.Join(apath, "codegen_model.go"))
	instantiateTemplate(schemaTemplate, p, filepath.Join(apath, "codegen_schema.go"))
	instantiateTemplate(dataTemplate, p, filepath.Join(apath, "codegen_data.go"))
}
458780
func (fp *formatParser) freshCode(i int, r rune) error {
	fp.start = i
	fp.code = (*formatParser).codeCode
	fp.next = (*formatParser).codeNext
	fp.end = (*formatParser).codeEnd
	return nil
}
1149751
func (m *Registry) GetSource(sourceType string) (Source, error) {
	return m.getDepth(0, sourceType)
}