diff --git a/cmd/dm/dm.go b/cmd/dm/dm.go index 2a28b8031..0eee56a8d 100644 --- a/cmd/dm/dm.go +++ b/cmd/dm/dm.go @@ -20,6 +20,7 @@ import ( "github.com/ghodss/yaml" "github.com/kubernetes/helm/pkg/common" + "github.com/kubernetes/helm/pkg/repo" "github.com/kubernetes/helm/pkg/util" "archive/tar" @@ -90,15 +91,15 @@ var usage = func() { os.Exit(0) } -func getCredential() *common.RegistryCredential { +func getCredential() *repo.Credential { *apitoken = strings.TrimSpace(*apitoken) if *apitoken == "" { *apitoken = strings.TrimSpace(os.Getenv("GITHUB_API_TOKEN")) } if *apitoken != "" { - return &common.RegistryCredential{ - APIToken: common.APITokenCredential(*apitoken), + return &repo.Credential{ + APIToken: repo.APITokenCredential(*apitoken), } } @@ -113,8 +114,8 @@ func getCredential() *common.RegistryCredential { *password = strings.TrimSpace(os.Getenv("GITHUB_PASSWORD")) } - return &common.RegistryCredential{ - BasicAuth: common.BasicAuthCredential{ + return &repo.Credential{ + BasicAuth: repo.BasicAuthCredential{ Username: *username, Password: *password, }, @@ -126,8 +127,8 @@ func getCredential() *common.RegistryCredential { if err != nil { log.Fatalf("Unable to read service account file: %v", err) } - return &common.RegistryCredential{ - ServiceAccount: common.JWTTokenCredential(string(b)), + return &repo.Credential{ + ServiceAccount: repo.JWTTokenCredential(string(b)), } } return nil diff --git a/pkg/common/types.go b/pkg/common/types.go index eb94da269..ed44382e5 100644 --- a/pkg/common/types.go +++ b/pkg/common/types.go @@ -180,92 +180,3 @@ type Resource struct { Properties map[string]interface{} `json:"properties,omitempty"` State *ResourceState `json:"state,omitempty"` } - -// TODO: Remove the following section when the refactoring of pkg/registry is complete. - -// BasicAuthCredential holds a username and password. -type BasicAuthCredential struct { - Username string `json:"username"` - Password string `json:"password"` -} - -// APITokenCredential defines an API token. -type APITokenCredential string - -// JWTTokenCredential defines a JWT token. -type JWTTokenCredential string - -// RegistryCredential holds a credential used to access a registry. -type RegistryCredential struct { - APIToken APITokenCredential `json:"apitoken,omitempty"` - BasicAuth BasicAuthCredential `json:"basicauth,omitempty"` - ServiceAccount JWTTokenCredential `json:"serviceaccount,omitempty"` -} - -// Registry describes a template registry -type Registry struct { - Name string `json:"name,omitempty"` // Friendly name for the registry - Type RegistryType `json:"type,omitempty"` // Technology implementing the registry - URL string `json:"url,omitempty"` // URL to the root of the registry - Format RegistryFormat `json:"format,omitempty"` // Format of the registry - CredentialName string `json:"credentialname,omitempty"` // Name of the credential to use -} - -// RegistryType defines the technology that implements a registry. -type RegistryType string - -// Constants that identify the supported registry types. -const ( - GithubRegistryType RegistryType = "github" - GCSRegistryType RegistryType = "gcs" -) - -// RegistryFormat is a semi-colon delimited string that describes the format -// of a registry. -type RegistryFormat string - -const ( - // Versioning. - - // VersionedRegistry identifies a versioned registry, where types appear under versions. - VersionedRegistry RegistryFormat = "versioned" - // UnversionedRegistry identifies an unversioned registry, where types appear under their names. - UnversionedRegistry RegistryFormat = "unversioned" - - // Organization. - - // CollectionRegistry identfies a collection registry, where types are grouped into collections. - CollectionRegistry RegistryFormat = "collection" - // OneLevelRegistry identifies a one level registry, where all types appear at the top level. - OneLevelRegistry RegistryFormat = "onelevel" -) - -// RegistryService maintains a set of registries that defines the scope of all -// registry based operations, such as search and type resolution. -type RegistryService interface { - // List all the registries - List() ([]*Registry, error) - // Create a new registry - Create(registry *Registry) error - // Get a registry - Get(name string) (*Registry, error) - // Get a registry with credential. - GetRegistry(name string) (*Registry, error) - // Delete a registry - Delete(name string) error - // Find a registry that backs the given URL - GetByURL(URL string) (*Registry, error) - // GetRegistryByURL returns a registry that handles the types for a given URL. - GetRegistryByURL(URL string) (*Registry, error) -} - -// CredentialProvider provides credentials for registries. -type CredentialProvider interface { - // Set the credential for a registry. - // May not be supported by some registry services. - SetCredential(name string, credential *RegistryCredential) error - - // GetCredential returns the specified credential or nil if there's no credential. - // Error is non-nil if fetching the credential failed. - GetCredential(name string) (*RegistryCredential, error) -}