( ctx context.Context, container appext.Container, flags *flags, )
| 214 | } |
| 215 | |
| 216 | func run( |
| 217 | ctx context.Context, |
| 218 | container appext.Container, |
| 219 | flags *flags, |
| 220 | ) (retErr error) { |
| 221 | if err := validateFlags(flags); err != nil { |
| 222 | return err |
| 223 | } |
| 224 | |
| 225 | workspace, err := getBuildableWorkspace(ctx, container, flags) |
| 226 | if err != nil { |
| 227 | return err |
| 228 | } |
| 229 | |
| 230 | uploader, err := bufcli.NewModuleUploader(container) |
| 231 | if err != nil { |
| 232 | return err |
| 233 | } |
| 234 | |
| 235 | var uploadOptions []bufmodule.UploadOption |
| 236 | if flags.GitMetadata { |
| 237 | gitMetadataUploadOptions, err := getGitMetadataUploadOptions(ctx, container, flags) |
| 238 | if err != nil { |
| 239 | return err |
| 240 | } |
| 241 | uploadOptions = append(uploadOptions, gitMetadataUploadOptions...) |
| 242 | // Accept any additional labels the user has set using `--label` |
| 243 | if len(flags.Labels) > 0 { |
| 244 | uploadOptions = append(uploadOptions, bufmodule.UploadWithLabels(xslices.ToUniqueSorted(flags.Labels)...)) |
| 245 | } |
| 246 | } else { |
| 247 | // Otherwise, we parse the flags set individually by the user. |
| 248 | if labelUploadOption := getLabelUploadOption(flags); labelUploadOption != nil { |
| 249 | uploadOptions = append(uploadOptions, labelUploadOption) |
| 250 | } |
| 251 | } |
| 252 | if flags.Create { |
| 253 | createModuleVisibility, err := bufmodule.ParseModuleVisibility(flags.CreateVisibility) |
| 254 | if err != nil { |
| 255 | return err |
| 256 | } |
| 257 | uploadOptions = append( |
| 258 | uploadOptions, |
| 259 | bufmodule.UploadWithCreateIfNotExist(createModuleVisibility, flags.CreateDefaultLabel), |
| 260 | ) |
| 261 | } |
| 262 | if flags.SourceControlURL != "" { |
| 263 | uploadOptions = append(uploadOptions, bufmodule.UploadWithSourceControlURL(flags.SourceControlURL)) |
| 264 | } |
| 265 | if flags.ExcludeUnnamed { |
| 266 | uploadOptions = append(uploadOptions, bufmodule.UploadWithExcludeUnnamed()) |
| 267 | } |
| 268 | |
| 269 | commits, err := uploader.Upload(ctx, workspace, uploadOptions...) |
| 270 | if err != nil { |
| 271 | return err |
| 272 | } |
| 273 | if len(commits) == 0 { |
no test coverage detected