Replace Non-ASCII symbols

Update golanci version, because we need to add asciicheck linter.
Because of update appears some gosec issues.

Closes: #312

Change-Id: I54759e7301f0fb9dcb60eb7d9a2d1e9cebfaf359
This commit is contained in:
Vladislav Kuzmin 2020-07-31 18:22:16 +04:00 committed by Bijaya Sharma
parent d5508aaa76
commit 43fad9ad85
8 changed files with 30 additions and 28 deletions

View File

@ -210,3 +210,4 @@ linters:
- varcheck # Finds unused global variables and constants
- whitespace # Tool for detection of leading and trailing whitespace NOTE(howell): This linter does _not_ check for trailing whitespace in multiline strings
- golint # Finds all coding style mistakes
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers

View File

@ -106,21 +106,22 @@ func copyBMHStatus(ctx context.Context, cFrom client.Client, cTo client.Client,
}
// Copy the Status field from old BMH to new BMH
log.Debugf("Copying BareMetalHost status to target cluster")
for _, toHost := range toHosts.Items {
for i := range toHosts.Items {
var found bool
t := metav1.Now()
for _, fromHost := range fromHosts.Items {
if fromHost.Name == toHost.Name {
toHost.Status = fromHost.Status
if fromHost.Name == toHosts.Items[i].Name {
toHosts.Items[i].Status = fromHost.Status
found = true
break
}
}
if !found {
return errors.Errorf("BMH with the same name %s/%s not found in the source cluster", toHost.Name, namespace)
return errors.Errorf("BMH with the same name %s/%s not found in the source cluster",
toHosts.Items[i].Name, namespace)
}
toHost.Status.LastUpdated = &t
err = cTo.Status().Update(ctx, &toHost)
toHosts.Items[i].Status.LastUpdated = &t
err = cTo.Status().Update(ctx, &toHosts.Items[i])
if err != nil {
return errors.Wrap(err, "failed to update BareMetalHost status")
}
@ -135,21 +136,21 @@ func pauseUnpauseBMHs(ctx context.Context, crClient client.Client, namespace str
if err != nil {
return errors.Wrap(err, "failed to list BMH objects")
}
for _, host := range hosts.Items {
annotations := host.GetAnnotations()
for i := range hosts.Items {
annotations := hosts.Items[i].GetAnnotations()
if annotations == nil {
host.Annotations = map[string]string{}
hosts.Items[i].Annotations = map[string]string{}
}
if pause {
log.Debugf("Pausing BareMetalHost object %s/%s", host.Name, namespace)
host.Annotations[bmh.PausedAnnotation] = "true"
log.Debugf("Pausing BareMetalHost object %s/%s", hosts.Items[i].Name, namespace)
hosts.Items[i].Annotations[bmh.PausedAnnotation] = "true"
} else {
log.Debugf("Unpausing BareMetalHost object %s/%s", host.Name, namespace)
delete(host.Annotations, bmh.PausedAnnotation)
log.Debugf("Unpausing BareMetalHost object %s/%s", hosts.Items[i].Name, namespace)
delete(hosts.Items[i].Annotations, bmh.PausedAnnotation)
}
if err := crClient.Update(ctx, &host); err != nil {
if err := crClient.Update(ctx, &hosts.Items[i]); err != nil {
return errors.Wrapf(err, "error updating BareMetalHost %q %s/%s",
host.GroupVersionKind(), host.GetNamespace(), host.GetName())
hosts.Items[i].GroupVersionKind(), hosts.Items[i].GetNamespace(), hosts.Items[i].GetName())
}
}
return nil

View File

@ -424,7 +424,7 @@ func (c *Config) PersistConfig() error {
}
// Write the Airship Config file
err = ioutil.WriteFile(c.loadedConfigPath, airshipConfigYaml, 0644)
err = ioutil.WriteFile(c.loadedConfigPath, airshipConfigYaml, 0600)
if err != nil {
return err
}

View File

@ -755,7 +755,7 @@ users:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQXhEdzk2RUY4SXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBNU1qa3hOekF6TURsYUZ3MHlNREE1TWpneE56QXpNVEphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXV6R0pZdlBaNkRvaTQyMUQKSzhXSmFaQ25OQWQycXo1cC8wNDJvRnpRUGJyQWd6RTJxWVZrek9MOHhBVmVSN1NONXdX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UGY4eVpjMUtwdmZhUDVhM0lRZmxiV0czbGpUemNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
`
err := ioutil.WriteFile(kubeConfigPath, []byte(kubeConfigContent), 0644)
err := ioutil.WriteFile(kubeConfigPath, []byte(kubeConfigContent), 0600)
require.NoError(t, err)
err = conf.ImportFromKubeConfig(kubeConfigPath)
@ -827,7 +827,7 @@ func TestImportErrors(t *testing.T) {
//nolint: lll
kubeConfigContent := "malformed content"
err := ioutil.WriteFile(kubeConfigPath, []byte(kubeConfigContent), 0644)
err := ioutil.WriteFile(kubeConfigPath, []byte(kubeConfigContent), 0600)
require.NoError(t, err)
err = conf.ImportFromKubeConfig(kubeConfigPath)

View File

@ -64,7 +64,7 @@ func NewApplier(f cmdutil.Factory, streams genericclioptions.IOStreams) *Applier
Streams: streams,
ManifestReaderFactory: utils.DefaultManifestReaderFactory,
Driver: &Adaptor{
СliUtilsApplier: cliapply.NewApplier(f, streams),
CliUtilsApplier: cliapply.NewApplier(f, streams),
},
}
}
@ -183,7 +183,7 @@ type Driver interface {
// Adaptor is implementation of driver interface
type Adaptor struct {
СliUtilsApplier *cliapply.Applier
CliUtilsApplier *cliapply.Applier
Factory cmdutil.Factory
}
@ -193,7 +193,7 @@ func (a *Adaptor) Initialize(p poller.Poller) error {
// Code below is copied from cli-utils package and used the same way as in upstream:
// https://github.com/kubernetes-sigs/cli-utils/blob/v0.14.0/cmd/apply/cmdapply.go#L35-L46
// Skip error checking is done in a same way as in upstream usage of this package
err := a.СliUtilsApplier.SetFlags(cmd)
err := a.CliUtilsApplier.SetFlags(cmd)
if err != nil {
return err
}
@ -206,20 +206,20 @@ func (a *Adaptor) Initialize(p poller.Poller) error {
cmd.Flags().MarkHidden("server-side") //nolint:errcheck
cmd.Flags().MarkHidden("force-conflicts") //nolint:errcheck
cmd.Flags().MarkHidden("field-manager") //nolint:errcheck
err = a.СliUtilsApplier.Initialize(cmd)
err = a.CliUtilsApplier.Initialize(cmd)
if err != nil {
return err
}
// status poller needs to be set only after the Initialize method is executed
if p != nil {
a.СliUtilsApplier.StatusPoller = p
a.CliUtilsApplier.StatusPoller = p
}
return nil
}
// Run perform apply operation
func (a *Adaptor) Run(ctx context.Context, infos []*resource.Info, options cliapply.Options) <-chan applyevent.Event {
return a.СliUtilsApplier.Run(ctx, infos, options)
return a.CliUtilsApplier.Run(ctx, infos, options)
}
// NewInventoryDocument returns default config map with invetory Id to group up the objects

View File

@ -181,11 +181,11 @@ func InitConfig(t *testing.T) (conf *config.Config, cleanup func(*testing.T)) {
testDir, cleanup := TempDir(t, "airship-test")
configPath := filepath.Join(testDir, "config")
err := ioutil.WriteFile(configPath, []byte(testConfigYAML), 0666)
err := ioutil.WriteFile(configPath, []byte(testConfigYAML), 0600)
require.NoError(t, err)
kubeConfigPath := filepath.Join(testDir, "kubeconfig")
err = ioutil.WriteFile(kubeConfigPath, []byte(testKubeConfigYAML), 0666)
err = ioutil.WriteFile(kubeConfigPath, []byte(testKubeConfigYAML), 0600)
require.NoError(t, err)
conf = config.NewConfig()

View File

@ -85,7 +85,7 @@ func updateGolden(t *testing.T, test *CmdTest, actual []byte) {
t.Logf("Created %s", goldenDir)
goldenFilePath := filepath.Join(goldenDir, test.Name+goldenFileSuffix)
t.Logf("Updating golden file: %s", goldenFilePath)
err = ioutil.WriteFile(goldenFilePath, normalize(actual), 0666)
err = ioutil.WriteFile(goldenFilePath, normalize(actual), 0600)
require.NoErrorf(t, err, "Failed to update golden file at %s", goldenFilePath)
}

View File

@ -3,7 +3,7 @@ set -x
tools_bin_dir="${BASH_SOURCE%/*}"
download_url=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
version=v1.23.8
version=v1.29.0
if ! curl -sfL "$download_url" | sh -s -- -b "$tools_bin_dir/bin" "$version"; then
printf "Something went wrong while installing golangci-lint\n" 1>&2