mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-18 13:54:23 -05:00
chore: fix unused parameter lint in new golangcilint version
This commit is contained in:
parent
68fc2b0811
commit
65903459a0
@ -29,7 +29,7 @@ type CloudKubeAPIWaiter struct{}
|
|||||||
// Wait waits for the Kubernetes API to be available.
|
// Wait waits for the Kubernetes API to be available.
|
||||||
// Note that the kubernetesClient must have the kubeconfig already set.
|
// Note that the kubernetesClient must have the kubeconfig already set.
|
||||||
func (w *CloudKubeAPIWaiter) Wait(ctx context.Context, kubernetesClient KubernetesClient) error {
|
func (w *CloudKubeAPIWaiter) Wait(ctx context.Context, kubernetesClient KubernetesClient) error {
|
||||||
funcAlwaysRetriable := func(err error) bool { return true }
|
funcAlwaysRetriable := func(_ error) bool { return true }
|
||||||
|
|
||||||
doer := &kubeDoer{kubeClient: kubernetesClient}
|
doer := &kubeDoer{kubeClient: kubernetesClient}
|
||||||
retrier := retry.NewIntervalRetrier(doer, 5*time.Second, funcAlwaysRetriable)
|
retrier := retry.NewIntervalRetrier(doer, 5*time.Second, funcAlwaysRetriable)
|
||||||
|
@ -54,7 +54,7 @@ func TestTFPlan(t *testing.T) {
|
|||||||
wantBackup: true,
|
wantBackup: true,
|
||||||
},
|
},
|
||||||
"workspace is empty": {
|
"workspace is empty": {
|
||||||
prepareFs: func(require *require.Assertions) file.Handler {
|
prepareFs: func(_ *require.Assertions) file.Handler {
|
||||||
return file.NewHandler(afero.NewMemMapFs())
|
return file.NewHandler(afero.NewMemMapFs())
|
||||||
},
|
},
|
||||||
tf: &stubUpgradePlanner{},
|
tf: &stubUpgradePlanner{},
|
||||||
|
@ -238,7 +238,7 @@ func TestSkipPhases(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateInputs(t *testing.T) {
|
func TestValidateInputs(t *testing.T) {
|
||||||
defaultConfig := func(csp cloudprovider.Provider) func(require *require.Assertions, fh file.Handler) {
|
defaultConfig := func(csp cloudprovider.Provider) func(require *require.Assertions, _ file.Handler) {
|
||||||
return func(require *require.Assertions, fh file.Handler) {
|
return func(require *require.Assertions, fh file.Handler) {
|
||||||
cfg := defaultConfigWithExpectedMeasurements(t, config.Default(), csp)
|
cfg := defaultConfigWithExpectedMeasurements(t, config.Default(), csp)
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ func TestValidateInputs(t *testing.T) {
|
|||||||
require.NoError(fh.WriteYAML(constants.ConfigFilename, cfg))
|
require.NoError(fh.WriteYAML(constants.ConfigFilename, cfg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preInitState := func(csp cloudprovider.Provider) func(require *require.Assertions, fh file.Handler) {
|
preInitState := func(csp cloudprovider.Provider) func(_ *require.Assertions, _ file.Handler) {
|
||||||
return func(require *require.Assertions, fh file.Handler) {
|
return func(require *require.Assertions, fh file.Handler) {
|
||||||
stateFile := defaultStateFile(csp)
|
stateFile := defaultStateFile(csp)
|
||||||
stateFile.ClusterValues = state.ClusterValues{}
|
stateFile.ClusterValues = state.ClusterValues{}
|
||||||
@ -332,7 +332,7 @@ func TestValidateInputs(t *testing.T) {
|
|||||||
wantPhases: newPhases(skipInitPhase, skipImagePhase), // No image upgrades on QEMU
|
wantPhases: newPhases(skipInitPhase, skipImagePhase), // No image upgrades on QEMU
|
||||||
},
|
},
|
||||||
"no config file errors": {
|
"no config file errors": {
|
||||||
createConfig: func(require *require.Assertions, fh file.Handler) {},
|
createConfig: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createState: postInitState(cloudprovider.GCP),
|
createState: postInitState(cloudprovider.GCP),
|
||||||
createMasterSecret: defaultMasterSecret,
|
createMasterSecret: defaultMasterSecret,
|
||||||
createAdminConfig: defaultAdminConfig,
|
createAdminConfig: defaultAdminConfig,
|
||||||
@ -344,7 +344,7 @@ func TestValidateInputs(t *testing.T) {
|
|||||||
createConfig: defaultConfig(cloudprovider.GCP),
|
createConfig: defaultConfig(cloudprovider.GCP),
|
||||||
createState: preInitState(cloudprovider.GCP),
|
createState: preInitState(cloudprovider.GCP),
|
||||||
createMasterSecret: defaultMasterSecret,
|
createMasterSecret: defaultMasterSecret,
|
||||||
createAdminConfig: func(require *require.Assertions, fh file.Handler) {},
|
createAdminConfig: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createTfState: defaultTfState,
|
createTfState: defaultTfState,
|
||||||
flags: applyFlags{},
|
flags: applyFlags{},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
@ -352,8 +352,8 @@ func TestValidateInputs(t *testing.T) {
|
|||||||
"[init] no admin config file, no master secret": {
|
"[init] no admin config file, no master secret": {
|
||||||
createConfig: defaultConfig(cloudprovider.GCP),
|
createConfig: defaultConfig(cloudprovider.GCP),
|
||||||
createState: preInitState(cloudprovider.GCP),
|
createState: preInitState(cloudprovider.GCP),
|
||||||
createMasterSecret: func(require *require.Assertions, fh file.Handler) {},
|
createMasterSecret: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createAdminConfig: func(require *require.Assertions, fh file.Handler) {},
|
createAdminConfig: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createTfState: defaultTfState,
|
createTfState: defaultTfState,
|
||||||
flags: applyFlags{},
|
flags: applyFlags{},
|
||||||
wantPhases: newPhases(skipImagePhase, skipK8sPhase),
|
wantPhases: newPhases(skipImagePhase, skipK8sPhase),
|
||||||
@ -363,16 +363,16 @@ func TestValidateInputs(t *testing.T) {
|
|||||||
createState: preInitState(cloudprovider.GCP),
|
createState: preInitState(cloudprovider.GCP),
|
||||||
createMasterSecret: defaultMasterSecret,
|
createMasterSecret: defaultMasterSecret,
|
||||||
createAdminConfig: defaultAdminConfig,
|
createAdminConfig: defaultAdminConfig,
|
||||||
createTfState: func(require *require.Assertions, fh file.Handler) {},
|
createTfState: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
flags: applyFlags{},
|
flags: applyFlags{},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"[create] only config, skip everything but infrastructure": {
|
"[create] only config, skip everything but infrastructure": {
|
||||||
createConfig: defaultConfig(cloudprovider.GCP),
|
createConfig: defaultConfig(cloudprovider.GCP),
|
||||||
createState: func(require *require.Assertions, fh file.Handler) {},
|
createState: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createMasterSecret: func(require *require.Assertions, fh file.Handler) {},
|
createMasterSecret: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createAdminConfig: func(require *require.Assertions, fh file.Handler) {},
|
createAdminConfig: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createTfState: func(require *require.Assertions, fh file.Handler) {},
|
createTfState: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
flags: applyFlags{
|
flags: applyFlags{
|
||||||
skipPhases: newPhases(skipInitPhase, skipAttestationConfigPhase, skipCertSANsPhase, skipHelmPhase, skipK8sPhase, skipImagePhase),
|
skipPhases: newPhases(skipInitPhase, skipAttestationConfigPhase, skipCertSANsPhase, skipHelmPhase, skipK8sPhase, skipImagePhase),
|
||||||
},
|
},
|
||||||
@ -380,19 +380,19 @@ func TestValidateInputs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"[create + init] only config file": {
|
"[create + init] only config file": {
|
||||||
createConfig: defaultConfig(cloudprovider.GCP),
|
createConfig: defaultConfig(cloudprovider.GCP),
|
||||||
createState: func(require *require.Assertions, fh file.Handler) {},
|
createState: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createMasterSecret: func(require *require.Assertions, fh file.Handler) {},
|
createMasterSecret: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createAdminConfig: func(require *require.Assertions, fh file.Handler) {},
|
createAdminConfig: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createTfState: func(require *require.Assertions, fh file.Handler) {},
|
createTfState: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
flags: applyFlags{},
|
flags: applyFlags{},
|
||||||
wantPhases: newPhases(skipImagePhase, skipK8sPhase),
|
wantPhases: newPhases(skipImagePhase, skipK8sPhase),
|
||||||
},
|
},
|
||||||
"[init] self-managed: config and state file exist, skip-phases=infrastructure": {
|
"[init] self-managed: config and state file exist, skip-phases=infrastructure": {
|
||||||
createConfig: defaultConfig(cloudprovider.GCP),
|
createConfig: defaultConfig(cloudprovider.GCP),
|
||||||
createState: preInitState(cloudprovider.GCP),
|
createState: preInitState(cloudprovider.GCP),
|
||||||
createMasterSecret: func(require *require.Assertions, fh file.Handler) {},
|
createMasterSecret: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createAdminConfig: func(require *require.Assertions, fh file.Handler) {},
|
createAdminConfig: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
createTfState: func(require *require.Assertions, fh file.Handler) {},
|
createTfState: func(_ *require.Assertions, _ file.Handler) {},
|
||||||
flags: applyFlags{
|
flags: applyFlags{
|
||||||
skipPhases: newPhases(skipInfrastructurePhase),
|
skipPhases: newPhases(skipInfrastructurePhase),
|
||||||
},
|
},
|
||||||
@ -414,7 +414,7 @@ func TestValidateInputs(t *testing.T) {
|
|||||||
createTfState: defaultTfState,
|
createTfState: defaultTfState,
|
||||||
stdin: "y\n",
|
stdin: "y\n",
|
||||||
wantPhases: newPhases(skipInitPhase, skipK8sPhase),
|
wantPhases: newPhases(skipInitPhase, skipK8sPhase),
|
||||||
assert: func(require *require.Assertions, assert *assert.Assertions, conf *config.Config, stateFile *state.State) {
|
assert: func(_ *require.Assertions, assert *assert.Assertions, conf *config.Config, _ *state.State) {
|
||||||
assert.NotEmpty(conf.KubernetesVersion)
|
assert.NotEmpty(conf.KubernetesVersion)
|
||||||
_, err := versions.NewValidK8sVersion(string(conf.KubernetesVersion), true)
|
_, err := versions.NewValidK8sVersion(string(conf.KubernetesVersion), true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
@ -196,7 +196,7 @@ func TestNoValidProviderAttestationCombination(t *testing.T) {
|
|||||||
{cloudprovider.OpenStack, variant.AWSNitroTPM{}},
|
{cloudprovider.OpenStack, variant.AWSNitroTPM{}},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run("", func(t *testing.T) {
|
t.Run("", func(_ *testing.T) {
|
||||||
_, err := createConfigWithAttestationVariant(test.provider, "", test.attestation)
|
_, err := createConfigWithAttestationVariant(test.provider, "", test.attestation)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
})
|
})
|
||||||
|
@ -122,7 +122,7 @@ func TestCreate(t *testing.T) {
|
|||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"config does not exist": {
|
"config does not exist": {
|
||||||
setupFs: func(a *require.Assertions, p cloudprovider.Provider) afero.Fs { return afero.NewMemMapFs() },
|
setupFs: func(_ *require.Assertions, _ cloudprovider.Provider) afero.Fs { return afero.NewMemMapFs() },
|
||||||
creator: &stubCloudCreator{
|
creator: &stubCloudCreator{
|
||||||
state: infraState,
|
state: infraState,
|
||||||
planDiff: true,
|
planDiff: true,
|
||||||
|
@ -67,7 +67,7 @@ func TestParseIDFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestIAMCreateAWS(t *testing.T) {
|
func TestIAMCreateAWS(t *testing.T) {
|
||||||
defaultFs := createFSWithConfig(*createConfig(cloudprovider.AWS))
|
defaultFs := createFSWithConfig(*createConfig(cloudprovider.AWS))
|
||||||
readOnlyFs := func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs {
|
readOnlyFs := func(_ *require.Assertions, _ cloudprovider.Provider, _ []string, _ []string) afero.Fs {
|
||||||
fs := afero.NewReadOnlyFs(afero.NewMemMapFs())
|
fs := afero.NewReadOnlyFs(afero.NewMemMapFs())
|
||||||
return fs
|
return fs
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ func TestIAMCreateAWS(t *testing.T) {
|
|||||||
|
|
||||||
func TestIAMCreateAzure(t *testing.T) {
|
func TestIAMCreateAzure(t *testing.T) {
|
||||||
defaultFs := createFSWithConfig(*createConfig(cloudprovider.Azure))
|
defaultFs := createFSWithConfig(*createConfig(cloudprovider.Azure))
|
||||||
readOnlyFs := func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs {
|
readOnlyFs := func(_ *require.Assertions, _ cloudprovider.Provider, _ []string, _ []string) afero.Fs {
|
||||||
fs := afero.NewReadOnlyFs(afero.NewMemMapFs())
|
fs := afero.NewReadOnlyFs(afero.NewMemMapFs())
|
||||||
return fs
|
return fs
|
||||||
}
|
}
|
||||||
@ -434,7 +434,7 @@ func TestIAMCreateAzure(t *testing.T) {
|
|||||||
|
|
||||||
func TestIAMCreateGCP(t *testing.T) {
|
func TestIAMCreateGCP(t *testing.T) {
|
||||||
defaultFs := createFSWithConfig(*createConfig(cloudprovider.GCP))
|
defaultFs := createFSWithConfig(*createConfig(cloudprovider.GCP))
|
||||||
readOnlyFs := func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs {
|
readOnlyFs := func(_ *require.Assertions, _ cloudprovider.Provider, _ []string, _ []string) afero.Fs {
|
||||||
fs := afero.NewReadOnlyFs(afero.NewMemMapFs())
|
fs := afero.NewReadOnlyFs(afero.NewMemMapFs())
|
||||||
return fs
|
return fs
|
||||||
}
|
}
|
||||||
@ -684,7 +684,7 @@ func TestValidateConfigWithFlagCompatibility(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createFSWithConfig(cfg config.Config) func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs {
|
func createFSWithConfig(cfg config.Config) func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs {
|
||||||
return func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs {
|
return func(require *require.Assertions, _ cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs {
|
||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
fileHandler := file.NewHandler(fs)
|
fileHandler := file.NewHandler(fs)
|
||||||
for _, f := range existingConfigFiles {
|
for _, f := range existingConfigFiles {
|
||||||
|
@ -438,12 +438,12 @@ func TestGenerateMasterSecret(t *testing.T) {
|
|||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"file does not exist": {
|
"file does not exist": {
|
||||||
createFileFunc: func(handler file.Handler) error { return nil },
|
createFileFunc: func(_ file.Handler) error { return nil },
|
||||||
fs: afero.NewMemMapFs,
|
fs: afero.NewMemMapFs,
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
"file not writeable": {
|
"file not writeable": {
|
||||||
createFileFunc: func(handler file.Handler) error { return nil },
|
createFileFunc: func(_ file.Handler) error { return nil },
|
||||||
fs: func() afero.Fs { return afero.NewReadOnlyFs(afero.NewMemMapFs()) },
|
fs: func() afero.Fs { return afero.NewReadOnlyFs(afero.NewMemMapFs()) },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,7 @@ func NewMaaPatchCmd() *cobra.Command {
|
|||||||
Long: "Patch the MAA's attestation policy.",
|
Long: "Patch the MAA's attestation policy.",
|
||||||
Args: cobra.MatchAll(
|
Args: cobra.MatchAll(
|
||||||
cobra.ExactArgs(1),
|
cobra.ExactArgs(1),
|
||||||
func(cmd *cobra.Command, args []string) error {
|
func(_ *cobra.Command, args []string) error {
|
||||||
if _, err := url.Parse(args[0]); err != nil {
|
if _, err := url.Parse(args[0]); err != nil {
|
||||||
return fmt.Errorf("argument %s is not a valid URL: %w", args[0], err)
|
return fmt.Errorf("argument %s is not a valid URL: %w", args[0], err)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func TestTerminate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"missing id file does not error": {
|
"missing id file does not error": {
|
||||||
stateFile: state.New(),
|
stateFile: state.New(),
|
||||||
setupFs: func(require *require.Assertions, stateFile *state.State) afero.Fs {
|
setupFs: func(require *require.Assertions, _ *state.State) afero.Fs {
|
||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
fileHandler := file.NewHandler(fs)
|
fileHandler := file.NewHandler(fs)
|
||||||
require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone))
|
require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone))
|
||||||
|
@ -254,7 +254,7 @@ func TestUpgradeApply(t *testing.T) {
|
|||||||
log: logger.NewTest(t),
|
log: logger.NewTest(t),
|
||||||
spinner: &nopSpinner{},
|
spinner: &nopSpinner{},
|
||||||
merger: &stubMerger{},
|
merger: &stubMerger{},
|
||||||
newInfraApplier: func(ctx context.Context) (cloudApplier, func(), error) {
|
newInfraApplier: func(_ context.Context) (cloudApplier, func(), error) {
|
||||||
return tc.terraformUpgrader, func() {}, nil
|
return tc.terraformUpgrader, func() {}, nil
|
||||||
},
|
},
|
||||||
applier: &stubConstellApplier{
|
applier: &stubConstellApplier{
|
||||||
|
@ -23,7 +23,7 @@ func TestAskToConfirm(t *testing.T) {
|
|||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "test",
|
Use: "test",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
ok, err := askToConfirm(cmd, "777")
|
ok, err := askToConfirm(cmd, "777")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func isCloudProvider(arg int) cobra.PositionalArgs {
|
func isCloudProvider(arg int) cobra.PositionalArgs {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(_ *cobra.Command, args []string) error {
|
||||||
if provider := cloudprovider.FromString(args[arg]); provider == cloudprovider.Unknown {
|
if provider := cloudprovider.FromString(args[arg]); provider == cloudprovider.Unknown {
|
||||||
return fmt.Errorf("argument %s isn't a valid cloud provider", args[arg])
|
return fmt.Errorf("argument %s isn't a valid cloud provider", args[arg])
|
||||||
}
|
}
|
||||||
|
@ -852,7 +852,7 @@ func TestCleanupWorkspace(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"no error if files do not exist": {
|
"no error if files do not exist": {
|
||||||
provider: cloudprovider.QEMU,
|
provider: cloudprovider.QEMU,
|
||||||
prepareFS: func(f file.Handler) error { return nil },
|
prepareFS: func(_ file.Handler) error { return nil },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{},
|
mapper: &stubCryptDevice{},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
"success with error on Load": {
|
"success with error on Load": {
|
||||||
@ -89,7 +89,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
"success with integrity": {
|
"success with integrity": {
|
||||||
@ -98,7 +98,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
integrity: true,
|
integrity: true,
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
"error on Init": {
|
"error on Init": {
|
||||||
@ -106,7 +106,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{initErr: assert.AnError},
|
mapper: &stubCryptDevice{initErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"error on Format": {
|
"error on Format": {
|
||||||
@ -114,7 +114,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError, formatErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError, formatErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"error on Activate": {
|
"error on Activate": {
|
||||||
@ -122,7 +122,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{activatePassErr: assert.AnError},
|
mapper: &stubCryptDevice{activatePassErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"error on diskInfo": {
|
"error on diskInfo": {
|
||||||
@ -130,7 +130,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", assert.AnError },
|
diskInfo: func(_ string) (string, error) { return "", assert.AnError },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"disk is already formatted": {
|
"disk is already formatted": {
|
||||||
@ -138,7 +138,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "ext4", nil },
|
diskInfo: func(_ string) (string, error) { return "ext4", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"error with integrity on wipe": {
|
"error with integrity on wipe": {
|
||||||
@ -147,7 +147,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
integrity: true,
|
integrity: true,
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError, wipeErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError, wipeErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"error on adding keyslot": {
|
"error on adding keyslot": {
|
||||||
@ -155,7 +155,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError, keySlotAddErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError, keySlotAddErr: assert.AnError},
|
||||||
kms: &fakeKMS{},
|
kms: &fakeKMS{},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"incorrect key length": {
|
"incorrect key length": {
|
||||||
@ -163,7 +163,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{},
|
mapper: &stubCryptDevice{},
|
||||||
kms: &fakeKMS{presetKey: []byte{0x1, 0x2, 0x3}},
|
kms: &fakeKMS{presetKey: []byte{0x1, 0x2, 0x3}},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"incorrect key length with error on Load": {
|
"incorrect key length with error on Load": {
|
||||||
@ -171,7 +171,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
||||||
kms: &fakeKMS{presetKey: []byte{0x1, 0x2, 0x3}},
|
kms: &fakeKMS{presetKey: []byte{0x1, 0x2, 0x3}},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"getKey fails": {
|
"getKey fails": {
|
||||||
@ -179,7 +179,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{},
|
mapper: &stubCryptDevice{},
|
||||||
kms: &fakeKMS{getDEKErr: assert.AnError},
|
kms: &fakeKMS{getDEKErr: assert.AnError},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"getKey fails with error on Load": {
|
"getKey fails with error on Load": {
|
||||||
@ -187,7 +187,7 @@ func TestOpenCryptDevice(t *testing.T) {
|
|||||||
volumeID: "volume0",
|
volumeID: "volume0",
|
||||||
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
mapper: &stubCryptDevice{loadErr: assert.AnError},
|
||||||
kms: &fakeKMS{getDEKErr: assert.AnError},
|
kms: &fakeKMS{getDEKErr: assert.AnError},
|
||||||
diskInfo: func(disk string) (string, error) { return "", nil },
|
diskInfo: func(_ string) (string, error) { return "", nil },
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ func TestRecover(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newStubKMS(setupErr, getDEKErr error) kmsFactory {
|
func newStubKMS(setupErr, getDEKErr error) kmsFactory {
|
||||||
return func(ctx context.Context, storageURI string, kmsURI string) (kms.CloudKMS, error) {
|
return func(_ context.Context, _ string, _ string) (kms.CloudKMS, error) {
|
||||||
if setupErr != nil {
|
if setupErr != nil {
|
||||||
return nil, setupErr
|
return nil, setupErr
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func isCloudProvider(arg int) cobra.PositionalArgs {
|
func isCloudProvider(arg int) cobra.PositionalArgs {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(_ *cobra.Command, args []string) error {
|
||||||
if provider := cloudprovider.FromString(args[arg]); provider == cloudprovider.Unknown {
|
if provider := cloudprovider.FromString(args[arg]); provider == cloudprovider.Unknown {
|
||||||
return fmt.Errorf("argument %s isn't a valid cloud provider", args[arg])
|
return fmt.Errorf("argument %s isn't a valid cloud provider", args[arg])
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ func isCloudProvider(arg int) cobra.PositionalArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isValidKind(arg int) cobra.PositionalArgs {
|
func isValidKind(arg int) cobra.PositionalArgs {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(_ *cobra.Command, args []string) error {
|
||||||
if kind := kindFromString(args[arg]); kind == unknown {
|
if kind := kindFromString(args[arg]); kind == unknown {
|
||||||
return fmt.Errorf("argument %s isn't a valid kind", args[arg])
|
return fmt.Errorf("argument %s isn't a valid kind", args[arg])
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ func getATLSConfigForClientFunc(issuer Issuer, validators []Validator) (func(*tl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this function will be called once for every client
|
// this function will be called once for every client
|
||||||
return func(chi *tls.ClientHelloInfo) (*tls.Config, error) {
|
return func(_ *tls.ClientHelloInfo) (*tls.Config, error) {
|
||||||
// generate nonce for this connection
|
// generate nonce for this connection
|
||||||
serverNonce, err := crypto.GenerateRandomBytes(crypto.RNGLengthDefault)
|
serverNonce, err := crypto.GenerateRandomBytes(crypto.RNGLengthDefault)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -142,7 +142,7 @@ func TestTLSConfig(t *testing.T) {
|
|||||||
serverConfig, err := CreateAttestationServerTLSConfig(tc.serverIssuer, tc.serverValidators)
|
serverConfig, err := CreateAttestationServerTLSConfig(tc.serverIssuer, tc.serverValidators)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, _ = io.WriteString(w, "hello")
|
_, _ = io.WriteString(w, "hello")
|
||||||
}))
|
}))
|
||||||
server.TLS = serverConfig
|
server.TLS = serverConfig
|
||||||
@ -196,7 +196,7 @@ func TestClientConnectionConcurrency(t *testing.T) {
|
|||||||
serverCfg, err := CreateAttestationServerTLSConfig(NewFakeIssuer(variant.Dummy{}), NewFakeValidators(variant.Dummy{}))
|
serverCfg, err := CreateAttestationServerTLSConfig(NewFakeIssuer(variant.Dummy{}), NewFakeValidators(variant.Dummy{}))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, _ = io.WriteString(w, "hello")
|
_, _ = io.WriteString(w, "hello")
|
||||||
}))
|
}))
|
||||||
server.TLS = serverCfg
|
server.TLS = serverCfg
|
||||||
@ -270,7 +270,7 @@ func TestServerConnectionConcurrency(t *testing.T) {
|
|||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
for i := 0; i < serverCount; i++ {
|
for i := 0; i < serverCount; i++ {
|
||||||
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, _ = io.WriteString(w, "hello")
|
_, _ = io.WriteString(w, "hello")
|
||||||
}))
|
}))
|
||||||
server.TLS = serverCfg
|
server.TLS = serverCfg
|
||||||
|
@ -57,7 +57,7 @@ func TestNewValidator(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for name, tc := range testCases {
|
for name, tc := range testCases {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(_ *testing.T) {
|
||||||
validator := NewValidator(tc.cfg, tc.logger)
|
validator := NewValidator(tc.cfg, tc.logger)
|
||||||
require.NotNil(validator)
|
require.NotNil(validator)
|
||||||
require.NotNil(validator.log)
|
require.NotNil(validator.log)
|
||||||
|
@ -91,7 +91,7 @@ func TestIMDSGetQuote(t *testing.T) {
|
|||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
"success": {
|
"success": {
|
||||||
client: newTestClient(func(req *http.Request) *http.Response {
|
client: newTestClient(func(_ *http.Request) *http.Response {
|
||||||
quote := quoteResponse{
|
quote := quoteResponse{
|
||||||
Quote: "test",
|
Quote: "test",
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ func TestIMDSGetQuote(t *testing.T) {
|
|||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
"bad status code": {
|
"bad status code": {
|
||||||
client: newTestClient(func(req *http.Request) *http.Response {
|
client: newTestClient(func(_ *http.Request) *http.Response {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusInternalServerError,
|
StatusCode: http.StatusInternalServerError,
|
||||||
Body: io.NopCloser(bytes.NewBufferString("")),
|
Body: io.NopCloser(bytes.NewBufferString("")),
|
||||||
@ -116,7 +116,7 @@ func TestIMDSGetQuote(t *testing.T) {
|
|||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"bad json": {
|
"bad json": {
|
||||||
client: newTestClient(func(req *http.Request) *http.Response {
|
client: newTestClient(func(_ *http.Request) *http.Response {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: io.NopCloser(bytes.NewBufferString("")),
|
Body: io.NopCloser(bytes.NewBufferString("")),
|
||||||
|
@ -104,7 +104,7 @@ func TestGetAttestationCert(t *testing.T) {
|
|||||||
wantValidateErr bool
|
wantValidateErr bool
|
||||||
}{
|
}{
|
||||||
"success": {
|
"success": {
|
||||||
crlServer: func(req *http.Request) *http.Response {
|
crlServer: func(_ *http.Request) *http.Response {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: io.NopCloser(bytes.NewReader(intermediateCert.Raw)),
|
Body: io.NopCloser(bytes.NewReader(intermediateCert.Raw)),
|
||||||
@ -136,14 +136,14 @@ func TestGetAttestationCert(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"intermediate cert cannot be fetched": {
|
"intermediate cert cannot be fetched": {
|
||||||
crlServer: func(req *http.Request) *http.Response {
|
crlServer: func(_ *http.Request) *http.Response {
|
||||||
return &http.Response{StatusCode: http.StatusNotFound}
|
return &http.Response{StatusCode: http.StatusNotFound}
|
||||||
},
|
},
|
||||||
getAkCert: defaultAkCertFunc,
|
getAkCert: defaultAkCertFunc,
|
||||||
wantIssueErr: true,
|
wantIssueErr: true,
|
||||||
},
|
},
|
||||||
"intermediate cert is not signed by root cert": {
|
"intermediate cert is not signed by root cert": {
|
||||||
crlServer: func(req *http.Request) *http.Response {
|
crlServer: func(_ *http.Request) *http.Response {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: io.NopCloser(bytes.NewReader(rootCert.Raw)),
|
Body: io.NopCloser(bytes.NewReader(rootCert.Raw)),
|
||||||
@ -153,7 +153,7 @@ func TestGetAttestationCert(t *testing.T) {
|
|||||||
wantValidateErr: true,
|
wantValidateErr: true,
|
||||||
},
|
},
|
||||||
"ak does not match ak cert public key": {
|
"ak does not match ak cert public key": {
|
||||||
crlServer: func(req *http.Request) *http.Response {
|
crlServer: func(_ *http.Request) *http.Response {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: io.NopCloser(bytes.NewReader(intermediateCert.Raw)),
|
Body: io.NopCloser(bytes.NewReader(intermediateCert.Raw)),
|
||||||
|
@ -176,7 +176,7 @@ type fakeInstanceClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func prepareFakeClient(ident *computepb.ShieldedInstanceIdentity, newErr, getIdentErr error) func(ctx context.Context, opts ...option.ClientOption) (gcpRestClient, error) {
|
func prepareFakeClient(ident *computepb.ShieldedInstanceIdentity, newErr, getIdentErr error) func(ctx context.Context, opts ...option.ClientOption) (gcpRestClient, error) {
|
||||||
return func(ctx context.Context, opts ...option.ClientOption) (gcpRestClient, error) {
|
return func(_ context.Context, _ ...option.ClientOption) (gcpRestClient, error) {
|
||||||
return &fakeInstanceClient{
|
return &fakeInstanceClient{
|
||||||
getIdentErr: getIdentErr,
|
getIdentErr: getIdentErr,
|
||||||
ident: ident,
|
ident: ident,
|
||||||
|
@ -308,7 +308,7 @@ func TestFailIssuer(t *testing.T) {
|
|||||||
"fail getAttestationKey": {
|
"fail getAttestationKey": {
|
||||||
issuer: NewIssuer(
|
issuer: NewIssuer(
|
||||||
newSimTPMWithEventLog,
|
newSimTPMWithEventLog,
|
||||||
func(tpm io.ReadWriter) (*tpmclient.Key, error) {
|
func(_ io.ReadWriter) (*tpmclient.Key, error) {
|
||||||
return nil, errors.New("failure")
|
return nil, errors.New("failure")
|
||||||
},
|
},
|
||||||
fakeGetInstanceInfo,
|
fakeGetInstanceInfo,
|
||||||
@ -320,7 +320,7 @@ func TestFailIssuer(t *testing.T) {
|
|||||||
"fail Attest": {
|
"fail Attest": {
|
||||||
issuer: NewIssuer(
|
issuer: NewIssuer(
|
||||||
newSimTPMWithEventLog,
|
newSimTPMWithEventLog,
|
||||||
func(tpm io.ReadWriter) (*tpmclient.Key, error) {
|
func(_ io.ReadWriter) (*tpmclient.Key, error) {
|
||||||
return &tpmclient.Key{}, nil
|
return &tpmclient.Key{}, nil
|
||||||
},
|
},
|
||||||
fakeGetInstanceInfo,
|
fakeGetInstanceInfo,
|
||||||
|
@ -185,7 +185,7 @@ func TestIMDSClient(t *testing.T) {
|
|||||||
wantTags: defaultWantTags,
|
wantTags: defaultWantTags,
|
||||||
},
|
},
|
||||||
"invalid imds response detected": {
|
"invalid imds response detected": {
|
||||||
server: newHTTPBufconnServer(func(writer http.ResponseWriter, request *http.Request) {
|
server: newHTTPBufconnServer(func(writer http.ResponseWriter, _ *http.Request) {
|
||||||
fmt.Fprintln(writer, "invalid-result")
|
fmt.Fprintln(writer, "invalid-result")
|
||||||
}),
|
}),
|
||||||
wantProviderIDErr: true,
|
wantProviderIDErr: true,
|
||||||
|
@ -28,7 +28,7 @@ type retrieableApplier interface {
|
|||||||
// retryApply retries the given retriable action.
|
// retryApply retries the given retriable action.
|
||||||
func retryApply(ctx context.Context, action retrieableApplier, retryInterval time.Duration, log debugLog) error {
|
func retryApply(ctx context.Context, action retrieableApplier, retryInterval time.Duration, log debugLog) error {
|
||||||
var retries int
|
var retries int
|
||||||
retriable := func(err error) bool {
|
retriable := func(_ error) bool {
|
||||||
// abort after maximumRetryAttempts tries.
|
// abort after maximumRetryAttempts tries.
|
||||||
if retries >= maximumRetryAttempts {
|
if retries >= maximumRetryAttempts {
|
||||||
return false
|
return false
|
||||||
|
@ -66,7 +66,7 @@ func TestATLSCredentials(t *testing.T) {
|
|||||||
go func() {
|
go func() {
|
||||||
var err error
|
var err error
|
||||||
defer func() { errChan <- err }()
|
defer func() { errChan <- err }()
|
||||||
conn, err := grpc.DialContext(context.Background(), "", grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
conn, err := grpc.DialContext(context.Background(), "", grpc.WithContextDialer(func(_ context.Context, _ string) (net.Conn, error) {
|
||||||
return lis.Dial()
|
return lis.Dial()
|
||||||
}), grpc.WithTransportCredentials(clientCreds))
|
}), grpc.WithTransportCredentials(clientCreds))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
@ -80,7 +80,7 @@ func TestInstall(t *testing.T) {
|
|||||||
wantFiles: map[string][]byte{"/destination": []byte("file-contents")},
|
wantFiles: map[string][]byte{"/destination": []byte("file-contents")},
|
||||||
},
|
},
|
||||||
"download fails": {
|
"download fails": {
|
||||||
server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }),
|
server: newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(500) }),
|
||||||
component: &components.Component{
|
component: &components.Component{
|
||||||
Url: serverURL,
|
Url: serverURL,
|
||||||
Hash: "sha256:abc",
|
Hash: "sha256:abc",
|
||||||
@ -89,7 +89,7 @@ func TestInstall(t *testing.T) {
|
|||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"dataurl works": {
|
"dataurl works": {
|
||||||
server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }),
|
server: newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(500) }),
|
||||||
component: &components.Component{
|
component: &components.Component{
|
||||||
Url: "data:text/plain,file-contents",
|
Url: "data:text/plain,file-contents",
|
||||||
Hash: "",
|
Hash: "",
|
||||||
@ -98,7 +98,7 @@ func TestInstall(t *testing.T) {
|
|||||||
wantFiles: map[string][]byte{"/destination": []byte("file-contents")},
|
wantFiles: map[string][]byte{"/destination": []byte("file-contents")},
|
||||||
},
|
},
|
||||||
"broken dataurl fails": {
|
"broken dataurl fails": {
|
||||||
server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }),
|
server: newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(500) }),
|
||||||
component: &components.Component{
|
component: &components.Component{
|
||||||
Url: "data:file-contents",
|
Url: "data:file-contents",
|
||||||
Hash: "",
|
Hash: "",
|
||||||
@ -129,7 +129,7 @@ func TestInstall(t *testing.T) {
|
|||||||
fs: &afero.Afero{Fs: afero.NewMemMapFs()},
|
fs: &afero.Afero{Fs: afero.NewMemMapFs()},
|
||||||
hClient: &hClient,
|
hClient: &hClient,
|
||||||
clock: testclock.NewFakeClock(time.Time{}),
|
clock: testclock.NewFakeClock(time.Time{}),
|
||||||
retriable: func(err error) bool { return false },
|
retriable: func(_ error) bool { return false },
|
||||||
}
|
}
|
||||||
|
|
||||||
err := inst.Install(context.Background(), tc.component)
|
err := inst.Install(context.Background(), tc.component)
|
||||||
@ -388,7 +388,7 @@ func TestDownloadToTempDir(t *testing.T) {
|
|||||||
wantFile: []byte("file-contents"),
|
wantFile: []byte("file-contents"),
|
||||||
},
|
},
|
||||||
"download fails": {
|
"download fails": {
|
||||||
server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }),
|
server: newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(500) }),
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"creating temp file fails on RO fs": {
|
"creating temp file fails on RO fs": {
|
||||||
@ -397,7 +397,7 @@ func TestDownloadToTempDir(t *testing.T) {
|
|||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"content length mismatch": {
|
"content length mismatch": {
|
||||||
server: newHTTPBufconnServer(func(writer http.ResponseWriter, request *http.Request) {
|
server: newHTTPBufconnServer(func(writer http.ResponseWriter, _ *http.Request) {
|
||||||
writer.Header().Set("Content-Length", "1337")
|
writer.Header().Set("Content-Length", "1337")
|
||||||
writer.WriteHeader(200)
|
writer.WriteHeader(200)
|
||||||
}),
|
}),
|
||||||
@ -607,7 +607,7 @@ func newHTTPBufconnServer(handlerFunc http.HandlerFunc) httpBufconnServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newHTTPBufconnServerWithBody(body []byte) httpBufconnServer {
|
func newHTTPBufconnServerWithBody(body []byte) httpBufconnServer {
|
||||||
return newHTTPBufconnServer(func(writer http.ResponseWriter, request *http.Request) {
|
return newHTTPBufconnServer(func(writer http.ResponseWriter, _ *http.Request) {
|
||||||
if _, err := writer.Write(body); err != nil {
|
if _, err := writer.Write(body); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -615,7 +615,7 @@ func newHTTPBufconnServerWithBody(body []byte) httpBufconnServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newHTTPBufconnServerWithState(state chan int, body []byte) httpBufconnServer {
|
func newHTTPBufconnServerWithState(state chan int, body []byte) httpBufconnServer {
|
||||||
return newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) {
|
return newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
switch <-state {
|
switch <-state {
|
||||||
case 500:
|
case 500:
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
|
@ -69,7 +69,7 @@ func GetClientStreamInterceptor(l *slog.Logger) grpc.DialOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func middlewareLogger(l *slog.Logger) logging.Logger {
|
func middlewareLogger(l *slog.Logger) logging.Logger {
|
||||||
return logging.LoggerFunc(func(ctx context.Context, lvl logging.Level, msg string, fields ...any) {
|
return logging.LoggerFunc(func(_ context.Context, lvl logging.Level, msg string, fields ...any) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:]) // skip [Callers, LoggerFunc]
|
runtime.Callers(2, pcs[:]) // skip [Callers, LoggerFunc]
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ func TestNotEmptySlice(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAll(t *testing.T) {
|
func TestAll(t *testing.T) {
|
||||||
c := func(i int, s string) *Constraint {
|
c := func(_ int, s string) *Constraint {
|
||||||
return Equal(s, "abc")
|
return Equal(s, "abc")
|
||||||
}
|
}
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
|
@ -138,7 +138,7 @@ func TestUpdate(t *testing.T) {
|
|||||||
// create tls config and start the server
|
// create tls config and start the server
|
||||||
serverConfig, err := atls.CreateAttestationServerTLSConfig(nil, []atls.Validator{validator})
|
serverConfig, err := atls.CreateAttestationServerTLSConfig(nil, []atls.Validator{validator})
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, _ = io.WriteString(w, "hello")
|
_, _ = io.WriteString(w, "hello")
|
||||||
}))
|
}))
|
||||||
server.TLS = serverConfig
|
server.TLS = serverConfig
|
||||||
|
@ -175,7 +175,7 @@ func (r *AutoscalingStrategyReconciler) findObjectsForDeployment(ctx context.Con
|
|||||||
// scalingGroupChangePredicate filters events on scaling group resources.
|
// scalingGroupChangePredicate filters events on scaling group resources.
|
||||||
func scalingGroupChangePredicate() predicate.Predicate {
|
func scalingGroupChangePredicate() predicate.Predicate {
|
||||||
return predicate.Funcs{
|
return predicate.Funcs{
|
||||||
CreateFunc: func(e event.CreateEvent) bool {
|
CreateFunc: func(_ event.CreateEvent) bool {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
UpdateFunc: func(e event.UpdateEvent) bool {
|
UpdateFunc: func(e event.UpdateEvent) bool {
|
||||||
@ -198,10 +198,10 @@ func scalingGroupChangePredicate() predicate.Predicate {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DeleteFunc: func(e event.DeleteEvent) bool {
|
DeleteFunc: func(_ event.DeleteEvent) bool {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
GenericFunc: func(e event.GenericEvent) bool {
|
GenericFunc: func(_ event.GenericEvent) bool {
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ func (r *PendingNodeReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
|||||||
// joining, leaving, node becoming ready or node receiving a provider id.
|
// joining, leaving, node becoming ready or node receiving a provider id.
|
||||||
func nodeStateChangePredicate() predicate.Predicate {
|
func nodeStateChangePredicate() predicate.Predicate {
|
||||||
return predicate.Funcs{
|
return predicate.Funcs{
|
||||||
CreateFunc: func(e event.CreateEvent) bool {
|
CreateFunc: func(_ event.CreateEvent) bool {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
UpdateFunc: func(e event.UpdateEvent) bool {
|
UpdateFunc: func(e event.UpdateEvent) bool {
|
||||||
@ -181,10 +181,10 @@ func nodeStateChangePredicate() predicate.Predicate {
|
|||||||
receivedProviderID := len(oldNode.Spec.ProviderID) == 0 && len(newNode.Spec.ProviderID) != 0
|
receivedProviderID := len(oldNode.Spec.ProviderID) == 0 && len(newNode.Spec.ProviderID) != 0
|
||||||
return becameReady || receivedProviderID
|
return becameReady || receivedProviderID
|
||||||
},
|
},
|
||||||
DeleteFunc: func(e event.DeleteEvent) bool {
|
DeleteFunc: func(_ event.DeleteEvent) bool {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
GenericFunc: func(e event.GenericEvent) bool {
|
GenericFunc: func(_ event.GenericEvent) bool {
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ func TestCreateNode(t *testing.T) {
|
|||||||
getErr: tc.getSKUCapacityErr,
|
getErr: tc.getSKUCapacityErr,
|
||||||
updateErr: tc.updateScaleSetErr,
|
updateErr: tc.updateScaleSetErr,
|
||||||
},
|
},
|
||||||
capacityPollerGenerator: func(resourceGroup, scaleSet string, wantedCapacity int64) capacityPoller {
|
capacityPollerGenerator: func(_, _ string, _ int64) capacityPoller {
|
||||||
return poller
|
return poller
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (w *NodeJoinWatcher) SetupWithManager(mgr ctrl.Manager) error {
|
|||||||
Named("node-join-watcher").
|
Named("node-join-watcher").
|
||||||
Watches(
|
Watches(
|
||||||
client.Object(&corev1.Node{}),
|
client.Object(&corev1.Node{}),
|
||||||
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request {
|
handler.EnqueueRequestsFromMapFunc(func(_ context.Context, obj client.Object) []ctrl.Request {
|
||||||
return []ctrl.Request{{
|
return []ctrl.Request{{
|
||||||
NamespacedName: types.NamespacedName{Name: obj.GetName()},
|
NamespacedName: types.NamespacedName{Name: obj.GetName()},
|
||||||
}}
|
}}
|
||||||
@ -70,7 +70,7 @@ func nodeJoinLeavePredicate() predicate.Predicate {
|
|||||||
return predicate.Funcs{
|
return predicate.Funcs{
|
||||||
// CreateFunc is not specified => never filter out create events
|
// CreateFunc is not specified => never filter out create events
|
||||||
// DeleteFunc is not specified => never filter out delete events
|
// DeleteFunc is not specified => never filter out delete events
|
||||||
UpdateFunc: func(e event.UpdateEvent) bool { return false },
|
UpdateFunc: func(_ event.UpdateEvent) bool { return false },
|
||||||
GenericFunc: func(e event.GenericEvent) bool { return false },
|
GenericFunc: func(_ event.GenericEvent) bool { return false },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ func (r *ClusterResource) Configure(_ context.Context, req resource.ConfigureReq
|
|||||||
return dialer.New(nil, validator, &net.Dialer{})
|
return dialer.New(nil, validator, &net.Dialer{})
|
||||||
}
|
}
|
||||||
|
|
||||||
r.newApplier = func(ctx context.Context, validator atls.Validator) *constellation.Applier {
|
r.newApplier = func(ctx context.Context, _ atls.Validator) *constellation.Applier {
|
||||||
return constellation.NewApplier(&tfContextLogger{ctx: ctx}, &nopSpinner{}, constellation.ApplyContextTerraform, newDialer)
|
return constellation.NewApplier(&tfContextLogger{ctx: ctx}, &nopSpinner{}, constellation.ApplyContextTerraform, newDialer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user