Skip to content

Commit

Permalink
Run metal-ccm with Metal-Edit privileges (#108)
Browse files Browse the repository at this point in the history
* Run metal-ccm with Metal-Edit privileges

* Make HMAC auth type configurable
  • Loading branch information
simcod authored Feb 3, 2025
1 parent 27fb956 commit 1ae1db1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion metal/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func NewCloud(_ io.Reader) (cloudprovider.Interface, error) {
url := os.Getenv(constants.MetalAPIUrlEnvVar)
token := os.Getenv(constants.MetalAuthTokenEnvVar)
hmac := os.Getenv(constants.MetalAuthHMACEnvVar)
hmacAuthType := os.Getenv(constants.MetalAuthHMACAuthTypeEnvVar)
projectID := os.Getenv(constants.MetalProjectIDEnvVar)
partitionID := os.Getenv(constants.MetalPartitionIDEnvVar)
clusterID := os.Getenv(constants.MetalClusterIDEnvVar)
Expand Down Expand Up @@ -83,7 +84,11 @@ func NewCloud(_ io.Reader) (cloudprovider.Interface, error) {
return nil, fmt.Errorf("environment variable %q or %q is required", constants.MetalAuthTokenEnvVar, constants.MetalAuthHMACEnvVar)
}

metalclient, err = metalgo.NewDriver(url, token, hmac)
if hmacAuthType == "" {
hmacAuthType = "Metal-Admin"
}

metalclient, err = metalgo.NewDriver(url, token, hmac, metalgo.AuthType(hmacAuthType))
if err != nil {
return nil, fmt.Errorf("unable to initialize metal ccm:%w", err)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
//nolint
MetalAuthTokenEnvVar = "METAL_AUTH_TOKEN"
MetalAuthHMACEnvVar = "METAL_AUTH_HMAC"
MetalAuthHMACAuthTypeEnvVar = "METAL_AUTH_HMAC_AUTH_TYPE"
MetalProjectIDEnvVar = "METAL_PROJECT_ID"
MetalPartitionIDEnvVar = "METAL_PARTITION_ID"
MetalClusterIDEnvVar = "METAL_CLUSTER_ID"
Expand Down

0 comments on commit 1ae1db1

Please sign in to comment.