github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/cmd/names.go (about)

     1  // Copyright 2012, 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package cmd
     5  
     6  import (
     7  	"regexp"
     8  
     9  	"github.com/juju/names"
    10  )
    11  
    12  const (
    13  	ContainerSnippet     = "(/[a-z]+/" + names.NumberSnippet + ")"
    14  	ContainerSpecSnippet = "([a-z]+:)?"
    15  )
    16  
    17  var (
    18  	validMachineOrNewContainer = regexp.MustCompile("^" + ContainerSpecSnippet + names.MachineSnippet + "$")
    19  )
    20  
    21  // IsMachineOrNewContainer returns whether spec is a valid machine id
    22  // or new container definition.
    23  func IsMachineOrNewContainer(spec string) bool {
    24  	return validMachineOrNewContainer.MatchString(spec)
    25  }