-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: static credentials provider (#3)
* feat: add simple static credential provider Initial implementation, adding the scaffolding and simple functionality where it just reads a file and returns it to stdout. * fix: log error before exiting * refactor: Tidy up error handling and tests Co-authored-by: Jimmi Dyson <[email protected]>
- Loading branch information
1 parent
66eb734
commit d7640c9
Showing
10 changed files
with
608 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2022 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/mesosphere/kubelet-image-credential-provider-shim/pkg/credentialprovider" | ||
) | ||
|
||
const ( | ||
//nolint:gosec // not credentials | ||
defaultCredentialsFile = "/etc/kubernetes/image-credentials.json" | ||
) | ||
|
||
func main() { | ||
logger := logrus.New() | ||
|
||
rootCmd := &cobra.Command{ | ||
Use: "static-credential-provider <credentials-file>", | ||
Short: "Static credential provider for Kubelet", | ||
Args: cobra.MaximumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
credentialsFile := defaultCredentialsFile | ||
if len(args) == 1 { | ||
credentialsFile = args[0] | ||
} | ||
provider, err := credentialprovider.NewStaticProvider(credentialsFile) | ||
if err != nil { | ||
return fmt.Errorf("error initializing static credential provider: %w", err) | ||
} | ||
|
||
err = credentialprovider.NewCredentialProvider(provider).Run(context.TODO()) | ||
if err != nil { | ||
return fmt.Errorf("error running static credential provider: %w", err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
if err := rootCmd.Execute(); err != nil { | ||
logger.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.