// secret creates secret with AWS credentials and sets up volume and volume mount
secret creates secret with AWS credentials and sets up volume and volume mount
// secret creates secret with AWS credentials and sets up volume and volume mount
func secret(jobName string, namespace string, params secretParams) (*secretPack, error) {
	suffix, err := users.CryptoRandomToken(3)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	secret := &v1.Secret{
		ObjectMeta: metav1.ObjectMeta{
			Name:      fmt.Sprintf("%v-%v", jobName, suffix),
			Namespace: namespace,
		},
		StringData: map[string]string{
			"token": params.token,
		},
	}
	if params.aws != nil {
		var tokenLine = ""
		if params.aws.sessionToken != "" {
			tokenLine = fmt.Sprintf("aws_session_token=%v", params.aws.sessionToken)
		}
		secret.StringData["aws-credentials"] = fmt.Sprintf(
			`[default]
aws_access_key_id=%v
aws_secret_access_key=%v
%v
`, params.aws.accessKeyID, params.aws.secretAccessKey, tokenLine)
	}
	volume := &v1.Volume{
		Name: "aws-credentials",
		VolumeSource: v1.VolumeSource{
			Secret: &v1.SecretVolumeSource{
				SecretName: secret.Name,
			},
		},
	}
	mount := &v1.VolumeMount{
		Name:      volume.Name,
		ReadOnly:  true,
		MountPath: constants.TelekubeMountDir,
	}
	return &secretPack{secret: secret, volume: volume, mount: mount}, nil
}
func secret ( jobName string , namespace string , params secretParams ) ( * secretPack , error ) { suffix , err := users . CryptoRandomToken ( 3 ) if err != nil { return nil , trace . Wrap ( err ) } secret := & v1 . Secret { ObjectMeta : metav1 . ObjectMeta { Name : fmt . Sprintf ( " " , jobName , suffix ) , Namespace : namespace , } , StringData : map [ string ] string { " " : params . token , } , } if params . aws != nil { var tokenLine = " " if params . aws . sessionToken != " " { tokenLine = fmt . Sprintf ( " " , params . aws . sessionToken ) } secret . StringData [ " " ] = fmt . Sprintf ( `[default]
aws_access_key_id=%v
aws_secret_access_key=%v
%v
` , params . aws . accessKeyID , params . aws . secretAccessKey , tokenLine ) } volume := & v1 . Volume { Name : " " , VolumeSource : v1 . VolumeSource { Secret : & v1 . SecretVolumeSource { SecretName : secret . Name , } , } , } mount := & v1 . VolumeMount { Name : volume . Name , ReadOnly : true , MountPath : constants . TelekubeMountDir , } return & secretPack { secret : secret , volume : volume , mount : mount } , nil }
secret creates secret with AWS credentials and sets up volume and volume mount
secret creates secret with AWS credentials and sets up volume and volume mount