mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-12 07:59:29 -05:00
fix ci-lint issues (#287)
Signed-off-by: Fabian Kammel <fk@edgeless.systems>
This commit is contained in:
parent
085f548333
commit
ba5a3aefe3
@ -224,7 +224,7 @@ func (k *KubeWrapper) InitCluster(
|
|||||||
|
|
||||||
// Store the received k8sVersion in a ConfigMap, overwriting exisiting values (there shouldn't be any).
|
// Store the received k8sVersion in a ConfigMap, overwriting exisiting values (there shouldn't be any).
|
||||||
// Joining nodes determine the kubernetes version they will install based on this ConfigMap.
|
// Joining nodes determine the kubernetes version they will install based on this ConfigMap.
|
||||||
if err := k.setupK8sVersionConfigMap(ctx, k8sVersion, true); err != nil {
|
if err := k.setupK8sVersionConfigMap(ctx, k8sVersion); err != nil {
|
||||||
return nil, fmt.Errorf("failed to setup k8s version ConfigMap: %v", err)
|
return nil, fmt.Errorf("failed to setup k8s version ConfigMap: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ func (k *KubeWrapper) setupClusterAutoscaler(instance metadata.InstanceMetadata,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setupK8sVersionConfigMap applies a ConfigMap (cf. server-side apply) to consistently store the installed k8s version.
|
// setupK8sVersionConfigMap applies a ConfigMap (cf. server-side apply) to consistently store the installed k8s version.
|
||||||
func (k *KubeWrapper) setupK8sVersionConfigMap(ctx context.Context, k8sVersion string, forceConflicts bool) error {
|
func (k *KubeWrapper) setupK8sVersionConfigMap(ctx context.Context, k8sVersion string) error {
|
||||||
if !versions.IsSupportedK8sVersion(k8sVersion) {
|
if !versions.IsSupportedK8sVersion(k8sVersion) {
|
||||||
return fmt.Errorf("supplied k8s version is not supported: %v", k8sVersion)
|
return fmt.Errorf("supplied k8s version is not supported: %v", k8sVersion)
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func (c *ServiceAccountCreator) createServiceAccountGCP(ctx context.Context, cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ServiceAccountCreator) createServiceAccountAzure(ctx context.Context, cl azureclient,
|
func (c *ServiceAccountCreator) createServiceAccountAzure(ctx context.Context, cl azureclient,
|
||||||
stat state.ConstellationState, config *config.Config,
|
stat state.ConstellationState, _ *config.Config,
|
||||||
) (string, state.ConstellationState, error) {
|
) (string, state.ConstellationState, error) {
|
||||||
if err := cl.SetState(stat); err != nil {
|
if err := cl.SetState(stat); err != nil {
|
||||||
return "", state.ConstellationState{}, fmt.Errorf("setting state while creating service account: %w", err)
|
return "", state.ConstellationState{}, fmt.Errorf("setting state while creating service account: %w", err)
|
||||||
|
@ -119,23 +119,23 @@ func (v *Validators) Warnings() string {
|
|||||||
sb := &strings.Builder{}
|
sb := &strings.Builder{}
|
||||||
|
|
||||||
if v.pcrs[0] == nil || v.pcrs[1] == nil {
|
if v.pcrs[0] == nil || v.pcrs[1] == nil {
|
||||||
writeFmt(sb, warningStr, "BIOS")
|
writeWarnFmt(sb, "BIOS")
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.pcrs[2] == nil || v.pcrs[3] == nil {
|
if v.pcrs[2] == nil || v.pcrs[3] == nil {
|
||||||
writeFmt(sb, warningStr, "OPROM")
|
writeWarnFmt(sb, "OPROM")
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.pcrs[4] == nil || v.pcrs[5] == nil {
|
if v.pcrs[4] == nil || v.pcrs[5] == nil {
|
||||||
writeFmt(sb, warningStr, "MBR")
|
writeWarnFmt(sb, "MBR")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GRUB measures kernel command line and initrd into pcrs 8 and 9
|
// GRUB measures kernel command line and initrd into pcrs 8 and 9
|
||||||
if v.pcrs[8] == nil {
|
if v.pcrs[8] == nil {
|
||||||
writeFmt(sb, warningStr, "kernel command line")
|
writeWarnFmt(sb, "kernel command line")
|
||||||
}
|
}
|
||||||
if v.pcrs[9] == nil {
|
if v.pcrs[9] == nil {
|
||||||
writeFmt(sb, warningStr, "initrd")
|
writeWarnFmt(sb, "initrd")
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.String()
|
return sb.String()
|
||||||
@ -166,6 +166,10 @@ func (v *Validators) checkPCRs(pcrs map[uint32][]byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func writeWarnFmt(sb *strings.Builder, args ...any) {
|
||||||
|
writeFmt(sb, warningStr, args...)
|
||||||
|
}
|
||||||
|
|
||||||
func writeFmt(sb *strings.Builder, fmtStr string, args ...any) {
|
func writeFmt(sb *strings.Builder, fmtStr string, args ...any) {
|
||||||
sb.WriteString(fmt.Sprintf(fmtStr, args...))
|
sb.WriteString(fmt.Sprintf(fmtStr, args...))
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ func readIds(fileHandler file.Handler) (clusterIDsFile, error) {
|
|||||||
|
|
||||||
// verifyCompletion handles the completion of CLI arguments. It is frequently called
|
// verifyCompletion handles the completion of CLI arguments. It is frequently called
|
||||||
// while the user types arguments of the command to suggest completion.
|
// while the user types arguments of the command to suggest completion.
|
||||||
func verifyCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
func verifyCompletion(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||||
switch len(args) {
|
switch len(args) {
|
||||||
case 0:
|
case 0:
|
||||||
return []string{"gcp", "azure"}, cobra.ShellCompDirectiveNoFileComp
|
return []string{"gcp", "azure"}, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
@ -24,7 +24,7 @@ func GetScalingGroupsFromConfig(stat state.ConstellationState, config *config.Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGCPInstances(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
|
func getGCPInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
|
||||||
if len(stat.GCPControlPlanes) == 0 {
|
if len(stat.GCPControlPlanes) == 0 {
|
||||||
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation without any instance")
|
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no control-plane workers available, can't create Constellation without any instance")
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ func getAzureInstances(stat state.ConstellationState, _ *config.Config) (control
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getQEMUInstances(stat state.ConstellationState, config *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
|
func getQEMUInstances(stat state.ConstellationState, _ *config.Config) (controlPlanes, workers cloudtypes.ScalingGroup, err error) {
|
||||||
controlPlaneMap := stat.QEMUControlPlane
|
controlPlaneMap := stat.QEMUControlPlane
|
||||||
if len(controlPlaneMap) == 0 {
|
if len(controlPlaneMap) == 0 {
|
||||||
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no controlPlanes available, can't create Constellation without any instance")
|
return cloudtypes.ScalingGroup{}, cloudtypes.ScalingGroup{}, errors.New("no controlPlanes available, can't create Constellation without any instance")
|
||||||
|
@ -164,7 +164,7 @@ func getCertificate(issuer Issuer, priv, pub any, nonce []byte) (*tls.Certificat
|
|||||||
|
|
||||||
// processCertificate parses the certificate and verifies it.
|
// processCertificate parses the certificate and verifies it.
|
||||||
// If successful returns the certificate and its hashed public key, an error otherwise.
|
// If successful returns the certificate and its hashed public key, an error otherwise.
|
||||||
func processCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) (*x509.Certificate, []byte, error) {
|
func processCertificate(rawCerts [][]byte, _ [][]*x509.Certificate) (*x509.Certificate, []byte, error) {
|
||||||
// parse certificate
|
// parse certificate
|
||||||
if len(rawCerts) == 0 {
|
if len(rawCerts) == 0 {
|
||||||
return nil, nil, errors.New("rawCerts is empty")
|
return nil, nil, errors.New("rawCerts is empty")
|
||||||
|
@ -137,7 +137,7 @@ func (s *Server) IssueJoinTicket(ctx context.Context, req *joinproto.IssueJoinTi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getK8sVersion reads the k8s version from a VolumeMount that is backed by the k8s-version ConfigMap.
|
// getK8sVersion reads the k8s version from a VolumeMount that is backed by the k8s-version ConfigMap.
|
||||||
func (s *Server) getK8sVersion(ctx context.Context) (string, error) {
|
func (s *Server) getK8sVersion(_ context.Context) (string, error) {
|
||||||
fileContent, err := s.file.Read(filepath.Join(constants.ServiceBasePath, "k8s-version"))
|
fileContent, err := s.file.Read(filepath.Join(constants.ServiceBasePath, "k8s-version"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("could not read k8s version file: %v", err)
|
return "", fmt.Errorf("could not read k8s version file: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user