Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Deprecated: "API specs are created automatically in the Akita app.", Use: "apispec", Short: "Convert traces into an OpenAPI3 specification.", SilenceUsage: true, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, _ []string) error { traces, err := toLocations(tracesFlag) if err != nil { return err } traceTags, err := util.ParseTags(tracesByTagFlag) if err != nil { return err } for _, version := range versionsFlag { if version_names.IsReservedVersionName(version) { return errors.Errorf("'%s' is an Akita-reserved version", version) } } var timeRange *time_span.TimeSpan var startTime time.Time endTime := time.Now() if fromTimeFlag != "" { startTime, err = parseTime(fromTimeFlag) if err != nil { return errors.Wrap(err, "failed to parse start time") } } if toTimeFlag != "" { endTime, err = parseTime(toTimeFlag) if err != nil { return errors.Wrap(err, "failed to parse end time") } } if fromTimeFlag != "" || toTimeFlag != "" { timeRange = time_span.NewTimeSpan(startTime, endTime) } if len(traces) == 0 && len(traceTags) == 0 { return errors.New("Must specify at least one input via \"traces\" or \"trace-tag\"") } if len(traceTags) > 0 { var projectName string if serviceFlag != "" { projectName = serviceFlag } else if outFlag.AkitaURI != nil { projectName = outFlag.AkitaURI.ServiceName } else { return errors.New("Must specify \"project\" or \"out\" to use \"trace-tag\"") } destURI, err := util.GetTraceURIByTags(rest.Domain, telemetry.GetClientID(), projectName, traceTags, "trace-tag") if err != nil { return err } if destURI.ObjectName == "" { return cmderr.AkitaErr{Err: errors.New("No traces matching specified tag, cannot create spec")} } traces = append(traces, location.Location{AkitaURI: &destURI}) } tags, err := util.ParseTagsAndWarn(tagsFlag) if err != nil { return err } var gitlabMR *gitlab.MRInfo if gitlabProjectFlag != "" { gitlabMR = &gitlab.MRInfo{ Project: gitlabProjectFlag, IID: gitlabMRFlag, Branch: gitlabBranchFlag, Commit: gitlabCommitFlag, } } plugins, err := pluginloader.Load(pluginsFlag) if err != nil { return errors.Wrap(err, "failed to load plugins") } args := apispec.Args{ ClientID: telemetry.GetClientID(), Domain: rest.Domain, Traces: traces, Out: outFlag, Service: serviceFlag, Format: formatFlag, Tags: tags, Versions: versionsFlag, PathParams: pathParamsFlag, PathExclusions: pathExclusionsFlag, TimeRange: timeRange, GitHubBranch: githubBranchFlag, GitHubCommit: githubCommitFlag, GitHubRepo: githubRepoFlag, GitHubPR: githubPRFlag, GitLabMR: gitlabMR, GetSpecEnableRelatedFields: getSpecEnableRelatedFieldsFlag, IncludeTrackers: includeTrackersFlag, Plugins: plugins, } if err := apispec.Run(args); err != nil { return cmderr.AkitaErr{Err: err} } return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.