Documentation
¶
Overview ¶
Copyright Project Harbor Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright Project Harbor Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright Project Harbor Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright Project Harbor Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright Project Harbor Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright Project Harbor Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright Project Harbor Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func AddCredentialsToConfigFile(credential Credential, configPath string) error
- func ApplyDataFile(harborDataPath, harborConfigPath string) error
- func ContextWithClient() (context.Context, *v2client.HarborAPI, error)
- func CreateConfigFile(configPath string) error
- func CreateDataFile(dataFilePath string, initialConfigPath string) error
- func Decrypt(key []byte, ciphertext string) (string, error)
- func DefaultCredentialName(username, server string) string
- func DetermineConfigPath(cfgFile string, userSpecifiedConfig bool) (string, error)
- func EmptyStringValidator(variable string) func(string) error
- func Encrypt(key, plaintext []byte) (string, error)
- func EnsureConfigFileExists(harborConfigPath string) error
- func FormatCreatedTime(timestamp string) (string, error)
- func FormatSize(size int64) string
- func FormatUrl(url string) string
- func GenerateEncryptionKey() error
- func GetClient() (*v2client.HarborAPI, error)
- func GetClientByConfig(clientConfig *harbor.ClientSetConfig) *v2client.HarborAPI
- func GetClientByCredentialName(credentialName string) (*v2client.HarborAPI, error)
- func GetDataPaths() (harborDataPath string, harborDataDir string)
- func GetEncryptionKey() ([]byte, error)
- func InitConfig(cfgFile string, userSpecifiedConfig bool)
- func ParseHarborErrorCode(err error) string
- func ParseHarborErrorMsg(err error) string
- func ParseProjectRepo(projectRepo string) (string, string)
- func ParseProjectRepoReference(projectRepoReference string) (string, string, string)
- func PrintFormat[T any](resp T, format string) error
- func PrintPayloadInJSONFormat(payload any)
- func PrintPayloadInYAMLFormat(payload any)
- func ReadConfig(harborConfigPath string) error
- func SanitizeServerAddress(server string) string
- func SetKeyringProvider(provider KeyringProvider)
- func StorageStringToBytes(storage string) (int64, error)
- func UpdateConfigFile(config *HarborConfig) error
- func UpdateCredentialsInConfigFile(updatedCredential Credential, configPath string) error
- func UpdateDataFile(dataFilePath string, newConfigPath string) error
- func ValidateConfigPath(configPath string) bool
- func ValidateEmail(email string) bool
- func ValidateFL(name string) bool
- func ValidatePassword(password string) error
- func ValidateProjectName(projectName string) bool
- func ValidateRegistryName(rn string) bool
- func ValidateStorageLimit(sl string) error
- func ValidateTagName(tagName string) bool
- func ValidateURL(rawURL string) error
- func ValidateUserName(username string) bool
- type Credential
- type EnvironmentKeyring
- type FileKeyring
- type HarborConfig
- type HarborData
- type HarborErrorPayload
- type KeyringProvider
- type MockKeyring
- type Once
- type SystemKeyring
Constants ¶
const KeyringService = "harbor-cli"
const KeyringUser = "harbor-cli-encryption-key"
Variables ¶
var ( CurrentHarborData *HarborData CurrentHarborConfig *HarborConfig )
var ConfigInitialization = &Once{}
Functions ¶
func AddCredentialsToConfigFile ¶ added in v0.0.2
func AddCredentialsToConfigFile(credential Credential, configPath string) error
func ApplyDataFile ¶ added in v0.0.3
Helper function to update or create the data file
func ContextWithClient ¶ added in v0.0.2
func CreateConfigFile ¶ added in v0.0.2
func CreateDataFile ¶ added in v0.0.3
func DefaultCredentialName ¶ added in v0.0.6
func DetermineConfigPath ¶ added in v0.0.3
Helper function to determine the config path
func EmptyStringValidator ¶ added in v0.0.6
func EnsureConfigFileExists ¶ added in v0.0.3
Helper function to ensure config file exists
func FormatCreatedTime ¶ added in v0.0.2
func FormatSize ¶ added in v0.0.2
func GenerateEncryptionKey ¶ added in v0.0.4
func GenerateEncryptionKey() error
func GetClientByConfig ¶
func GetClientByConfig(clientConfig *harbor.ClientSetConfig) *v2client.HarborAPI
func GetClientByCredentialName ¶
Returns Harbor v2 client after resolving the credential name
func GetDataPaths ¶ added in v0.0.3
Helper function to get data paths
func GetEncryptionKey ¶ added in v0.0.4
func InitConfig ¶ added in v0.0.3
func ParseHarborErrorCode ¶ added in v0.0.6
func ParseHarborErrorMsg ¶ added in v0.0.6
func ParseProjectRepo ¶ added in v0.0.2
func ParseProjectRepoReference ¶ added in v0.0.2
func PrintFormat ¶ added in v0.0.3
func PrintPayloadInJSONFormat ¶
func PrintPayloadInJSONFormat(payload any)
func PrintPayloadInYAMLFormat ¶ added in v0.0.3
func PrintPayloadInYAMLFormat(payload any)
func ReadConfig ¶ added in v0.0.3
Helper function to read the config file using Viper
func SanitizeServerAddress ¶ added in v0.0.3
func SetKeyringProvider ¶ added in v0.0.4
func SetKeyringProvider(provider KeyringProvider)
func StorageStringToBytes ¶ added in v0.0.6
func UpdateConfigFile ¶ added in v0.0.4
func UpdateConfigFile(config *HarborConfig) error
UpdateConfigFile updates the YAML config file on disk with the values in the given HarborConfig, and also updates the in-memory CurrentHarborConfig.
func UpdateCredentialsInConfigFile ¶ added in v0.0.3
func UpdateCredentialsInConfigFile(updatedCredential Credential, configPath string) error
func UpdateDataFile ¶ added in v0.0.3
func ValidateConfigPath ¶ added in v0.0.3
func ValidateEmail ¶ added in v0.0.2
func ValidateFL ¶ added in v0.0.2
func ValidatePassword ¶ added in v0.0.2
check if the password format is vaild
func ValidateProjectName ¶ added in v0.0.2
check if the project name is valid
func ValidateRegistryName ¶ added in v0.0.2
func ValidateStorageLimit ¶ added in v0.0.2
func ValidateTagName ¶ added in v0.0.2
check if the tag name is valid
func ValidateURL ¶ added in v0.0.6
func ValidateUserName ¶ added in v0.0.2
ValidateUserName checks if the username is valid by length and allowed characters.
Types ¶
type Credential ¶
type Credential struct {
Name string `yaml:"name"`
Username string `yaml:"username"`
Password string `yaml:"password"`
ServerAddress string `yaml:"serveraddress"`
}
func GetCredentials ¶ added in v0.0.2
func GetCredentials(credentialName string) (Credential, error)
type EnvironmentKeyring ¶ added in v0.0.5
type EnvironmentKeyring struct {
EnvVarName string
}
EnvironmentKeyring implements KeyringProvider using environment variables
func (*EnvironmentKeyring) Delete ¶ added in v0.0.5
func (e *EnvironmentKeyring) Delete(service, user string) error
func (*EnvironmentKeyring) Get ¶ added in v0.0.5
func (e *EnvironmentKeyring) Get(service, user string) (string, error)
func (*EnvironmentKeyring) Set ¶ added in v0.0.5
func (e *EnvironmentKeyring) Set(service, user, password string) error
type FileKeyring ¶ added in v0.0.5
type FileKeyring struct {
BaseDir string
}
FileKeyring implements KeyringProvider using files in a directory
func (*FileKeyring) Delete ¶ added in v0.0.5
func (f *FileKeyring) Delete(service, user string) error
func (*FileKeyring) Get ¶ added in v0.0.5
func (f *FileKeyring) Get(service, user string) (string, error)
func (*FileKeyring) Set ¶ added in v0.0.5
func (f *FileKeyring) Set(service, user, password string) error
type HarborConfig ¶ added in v0.0.2
type HarborConfig struct {
CurrentCredentialName string `mapstructure:"current-credential-name" yaml:"current-credential-name"`
Credentials []Credential `mapstructure:"credentials" yaml:"credentials"`
}
func GetCurrentHarborConfig ¶ added in v0.0.3
func GetCurrentHarborConfig() (*HarborConfig, error)
type HarborData ¶ added in v0.0.3
type HarborData struct {
ConfigPath string `mapstructure:"configpath" yaml:"configpath"`
}
func GetCurrentHarborData ¶ added in v0.0.3
func GetCurrentHarborData() (*HarborData, error)
func ReadDataFile ¶ added in v0.0.3
func ReadDataFile(dataFilePath string) (HarborData, error)
type HarborErrorPayload ¶ added in v0.0.6
type KeyringProvider ¶ added in v0.0.4
type KeyringProvider interface {
Set(service, user, password string) error
Get(service, user string) (string, error)
Delete(service, user string) error
}
func GetKeyringProvider ¶ added in v0.0.5
func GetKeyringProvider() KeyringProvider
GetKeyringProvider selects the appropriate keyring provider
type MockKeyring ¶ added in v0.0.4
type MockKeyring struct {
// contains filtered or unexported fields
}
func NewMockKeyring ¶ added in v0.0.4
func NewMockKeyring() *MockKeyring
func (*MockKeyring) Delete ¶ added in v0.0.4
func (m *MockKeyring) Delete(service, user string) error
func (*MockKeyring) Get ¶ added in v0.0.4
func (m *MockKeyring) Get(service, user string) (string, error)
func (*MockKeyring) Set ¶ added in v0.0.4
func (m *MockKeyring) Set(service, user, password string) error
type SystemKeyring ¶ added in v0.0.4
type SystemKeyring struct{}
func (*SystemKeyring) Delete ¶ added in v0.0.4
func (s *SystemKeyring) Delete(service, user string) error
func (*SystemKeyring) Get ¶ added in v0.0.4
func (s *SystemKeyring) Get(service, user string) (string, error)
func (*SystemKeyring) Set ¶ added in v0.0.4
func (s *SystemKeyring) Set(service, user, password string) error