Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: common/config/projectName.go

Issue 2626433004: Move "common/config" common types into cfgtypes. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | common/config/projectName_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/config/projectName.go
diff --git a/common/config/projectName.go b/common/config/projectName.go
deleted file mode 100644
index cd1d3bb8cbda958272258cc05fabc8c81032aac2..0000000000000000000000000000000000000000
--- a/common/config/projectName.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2016 The LUCI Authors. All rights reserved.
-// Use of this source code is governed under the Apache License, Version 2.0
-// that can be found in the LICENSE file.
-
-package config
-
-import (
- "errors"
- "flag"
- "fmt"
-)
-
-// ProjectName is a luci-config project name.
-//
-// A valid project name may only include:
-// - Lowercase letters [a-z]
-// - Numbers [0-9]
-// - Hyphen (-)
-// - Underscore (_)
-//
-// It also must begin with a letter.
-//
-// See:
-// https://github.com/luci/luci-py/blob/8e594074929871a9761d27e814541bc0d7d84744/appengine/components/components/config/common.py#L41
-type ProjectName string
-
-var _ flag.Value = (*ProjectName)(nil)
-
-// Validate returns an error if the supplied ProjectName is not a valid project
-// name.
-func (p ProjectName) Validate() error {
- if len(p) == 0 {
- return errors.New("cannot have empty name")
- }
-
- for idx, r := range p {
- switch {
- case r >= 'a' && r <= 'z':
-
- case (r >= '0' && r <= '9'), r == '-', r == '_':
- if idx == 0 {
- return errors.New("must begin with a letter")
- }
-
- default:
- return fmt.Errorf("invalid character at %d (%c)", idx, r)
- }
- }
-
- return nil
-}
-
-// String implements flag.Value.
-func (p *ProjectName) String() string {
- return string(*p)
-}
-
-// Set implements flag.Value.
-func (p *ProjectName) Set(v string) error {
- vp := ProjectName(v)
- if err := vp.Validate(); err != nil {
- return err
- }
- *p = vp
- return nil
-}
« no previous file with comments | « no previous file | common/config/projectName_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698