// CheckDefaultWorkloadStorage implements ClusterMetadataChecker.
481050
func (k *kubernetesClient) CheckDefaultWorkloadStorage(cluster string, storageProvisioner *caas.StorageProvisioner) error {
	preferredStorage, ok := jujuPreferredWorkloadStorage[cluster]
	if !ok {
		return errors.NotFoundf("cluster %q", cluster)
	}
	return storageClassMatches(preferredStorage, storageProvisioner)
}
833359
func (c *Config) StorageDefaultFilesystemSource() (string, bool) {
	bs := c.asString(StorageDefaultFilesystemSourceKey)
	return bs, bs != ""
}
473820
func GetDefaultVolSpecs(
	ctx context.Context,
	spec *api.VolumeSpec,
	isUpdate bool,
) (*api.VolumeSpec, error) {
	storPolicy, err := policy.Inst()
	if err != nil {
		return nil, status.Errorf(codes.Internal, "Unable to get storage policy instance %v", err)
	}

	var policy *api.SdkStoragePolicy
	// check if custom policy passed with volume
	if spec.GetStoragePolicy() != "" {
		inspReq := &api.SdkOpenStoragePolicyInspectRequest{
			// name of storage policy specified in volSpecs
			Name: spec.GetStoragePolicy(),
		}
		// inspect will make sure user will atleast have read access
		customPolicy, customErr := storPolicy.Inspect(ctx, inspReq)
		if customErr != nil {
			return nil, customErr
		}

		policy = customPolicy.GetStoragePolicy()
	} else {
		// check if default storage policy is set
		defPolicy, err := storPolicy.DefaultInspect(context.Background(), &api.SdkOpenStoragePolicyDefaultInspectRequest{})
		if err != nil {
			// err means there is policy stored, but we are not able to retrive it
			// hence we are not allowing volume create operation
			return nil, status.Errorf(codes.Internal, "Unable to get default policy details %v", err)
		} else if defPolicy.GetStoragePolicy() == nil {
			// no default storage policy found
			return spec, nil
		}
		policy = defPolicy.GetStoragePolicy()
	}

	// track volume created using storage policy
	spec.StoragePolicy = policy.GetName()
	// check if volume update request, if allowupdate is set
	// return spec received as it is
	if isUpdate && policy.GetAllowUpdate() {
		if !policy.IsPermitted(ctx, api.Ownership_Write) {
			return nil, status.Errorf(codes.PermissionDenied, "Cannot use storage policy %v", policy.GetName())
		}
		return spec, nil
	}

	return mergeVolumeSpecsPolicy(spec, policy.GetPolicy(), policy.GetForce())
}
1170290
func (vm *volumeManager) verifyVolumesMountedFunc(podName types.UniquePodName, expectedVolumes []string) wait.ConditionFunc {
	return func() (done bool, err error) {
		return len(vm.getUnmountedVolumes(podName, expectedVolumes)) == 0, nil
	}
}
429656
func (s *Config) CheckAndSetDefaults() error {
	if s.Bucket == "" {
		return trace.BadParameter("missing parameter Bucket")
	}
	if s.Session == nil {
		// create an AWS session using default SDK behavior, i.e. it will interpret
		// the environment and ~/.aws directory just like an AWS CLI tool would:
		sess, err := awssession.NewSessionWithOptions(awssession.Options{
			SharedConfigState: awssession.SharedConfigEnable,
		})
		if err != nil {
			return trace.Wrap(err)
		}
		// override the default environment (region + credentials) with the values
		// from the YAML file:
		if s.Region != "" {
			sess.Config.Region = aws.String(s.Region)
		}
		s.Session = sess
	}
	return nil
}
1265627
func (s *SMBFileShareInfo) SetDefaultStorageClass(v string) *SMBFileShareInfo {
	s.DefaultStorageClass = &v
	return s
}
865019
func (a *KubeCSR) CheckAndSetDefaults() error {
	if len(a.CSR) == 0 {
		return trace.BadParameter("missing parameter 'csr'")
	}
	return nil
}
167710
func newStorageMetaDoc(meta *Metadata) storageMetaDoc {
	var doc storageMetaDoc

	// Ignore metadata.ID. It will be set by storage later.

	doc.Checksum = meta.Checksum()
	doc.ChecksumFormat = meta.ChecksumFormat()
	doc.Size = meta.Size()
	if meta.Stored() != nil {
		stored := meta.Stored()
		doc.Stored = metadocTimeToUnix(*stored)
	}

	doc.Started = metadocTimeToUnix(meta.Started)
	if meta.Finished != nil {
		doc.Finished = metadocTimeToUnix(*meta.Finished)
	}
	doc.Notes = meta.Notes

	doc.Model = meta.Origin.Model
	doc.Machine = meta.Origin.Machine
	doc.Hostname = meta.Origin.Hostname
	doc.Version = meta.Origin.Version
	doc.Series = meta.Origin.Series

	return doc
}
408535
func (s *CreateSMBFileShareInput) SetDefaultStorageClass(v string) *CreateSMBFileShareInput {
	s.DefaultStorageClass = &v
	return s
}
846671
func (s *NFSFileShareInfo) SetDefaultStorageClass(v string) *NFSFileShareInfo {
	s.DefaultStorageClass = &v
	return s
}
995626
func (status Status) KnownWorkloadStatus() bool {
	if ValidWorkloadStatus(status) {
		return true
	}
	switch status {
	case Error: // include error so that we can filter on what the spec says is valid
		return true
	default:
		return false
	}
}
776933
func (c *ClusterNameV2) CheckAndSetDefaults() error {
	// make sure we have defaults for all metadata fields
	err := c.Metadata.CheckAndSetDefaults()
	if err != nil {
		return trace.Wrap(err)
	}

	if c.Spec.ClusterName == "" {
		return trace.BadParameter("cluster name is required")
	}

	return nil
}
295791
func (sc *stateCheckpoint) GetDefaultCPUSet() cpuset.CPUSet {
	sc.mux.RLock()
	defer sc.mux.RUnlock()

	return sc.cache.GetDefaultCPUSet()
}
199634
func defaultClusterObject(
	clusterID string,
	initialCAConfig api.CAConfig,
	raftCfg api.RaftConfig,
	encryptionConfig api.EncryptionConfig,
	initialUnlockKeys []*api.EncryptionKey,
	rootCA *ca.RootCA,
	fips bool,
	defaultAddressPool []string,
	subnetSize uint32,
	vxlanUDPPort uint32) *api.Cluster {
	var caKey []byte
	if rcaSigner, err := rootCA.Signer(); err == nil {
		caKey = rcaSigner.Key
	}

	return &api.Cluster{
		ID: clusterID,
		Spec: api.ClusterSpec{
			Annotations: api.Annotations{
				Name: store.DefaultClusterName,
			},
			Orchestration: api.OrchestrationConfig{
				TaskHistoryRetentionLimit: defaultTaskHistoryRetentionLimit,
			},
			Dispatcher: api.DispatcherConfig{
				HeartbeatPeriod: gogotypes.DurationProto(dispatcher.DefaultHeartBeatPeriod),
			},
			Raft:             raftCfg,
			CAConfig:         initialCAConfig,
			EncryptionConfig: encryptionConfig,
		},
		RootCA: api.RootCA{
			CAKey:      caKey,
			CACert:     rootCA.Certs,
			CACertHash: rootCA.Digest.String(),
			JoinTokens: api.JoinTokens{
				Worker:  ca.GenerateJoinToken(rootCA, fips),
				Manager: ca.GenerateJoinToken(rootCA, fips),
			},
		},
		UnlockKeys:         initialUnlockKeys,
		FIPS:               fips,
		DefaultAddressPool: defaultAddressPool,
		SubnetSize:         subnetSize,
		VXLANUDPPort:       vxlanUDPPort,
	}
}
435692
func (api *CloudAPIV4) DefaultCloud() (params.StringResult, error) {
	controllerModel, err := api.ctlrBackend.Model()
	if err != nil {
		return params.StringResult{}, err
	}
	return params.StringResult{
		Result: names.NewCloudTag(controllerModel.Cloud()).String(),
	}, nil
}
127401
func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile {
	configFile, err := Load(Dir())
	if err != nil {
		fmt.Fprintf(stderr, "WARNING: Error loading config file: %v\n", err)
	}
	if !configFile.ContainsAuth() {
		configFile.CredentialsStore = credentials.DetectDefaultStore(configFile.CredentialsStore)
	}
	return configFile
}
1269487
func (c *Conn) ReadDefaultConfigFile() error {
	ret := C.rados_conf_read_file(c.cluster, nil)
	if ret == 0 {
		return nil
	} else {
		return RadosError(int(ret))
	}
}