...
1 package layer
2
3 import (
4 "fmt"
5
6 "github.com/google/go-containerregistry/pkg/v1/types"
7 )
8
9
10 const YAML types.MediaType = "yaml"
11
12
13
14 type Type string
15
16
17 const (
18 Infra Type = "infrastructure"
19 Runtime Type = "runtime"
20 Config Type = "config"
21 )
22
23 func (t Type) String() string {
24 return string(t)
25 }
26
27
28 func (t Type) IsValid() error {
29 if IsType(t.String()) {
30 return nil
31 }
32 return fmt.Errorf("invalid warehouse layer type %s: expected one of %s",
33 t, []Type{Infra, Runtime, Config})
34 }
35
36
37 func IsType(s string) bool {
38 switch Type(s) {
39 case Infra, Runtime, Config:
40 return true
41 default:
42 return false
43 }
44 }
45
View as plain text