func (options Options) NewStateStore() (state.ClusterStorer, error) {
	var stateStore state.ClusterStorer

	switch options.StateStore {
	case "fs":
		logger.Info("Selected [fs] state store")
		stateStore = fs.NewFileSystemStore(&fs.FileSystemStoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
		})
	case "crd":
		logger.Info("Selected [crd] state store")
		stateStore = crd.NewCRDStore(&crd.CRDStoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
		})
	case "git":
		logger.Info("Selected [git] state store")
		if options.GitRemote == "" {
			return nil, errors.New("empty GitRemote url. Must specify the link to the remote git repo")
		}
		user, _ := gg.Global("user.name")
		email, _ := gg.Email()

		stateStore = git.NewJSONGitStore(&git.JSONGitStoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
			CommitConfig: &git.JSONGitCommitConfig{
				Name:   user,
				Email:  email,
				Remote: options.GitRemote,
			},
		})
	case "jsonfs":
		logger.Info("Selected [jsonfs] state store")
		stateStore = jsonfs.NewJSONFileSystemStore(&jsonfs.JSONFileSystemStoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
		})
	case "s3":
		logger.Info("Selected [s3] state store")
		client, err := minio.New(options.BucketEndpointURL, options.S3AccessKey, options.S3SecretKey, options.BucketSSL)
		if err != nil {
			return nil, err
		}
		stateStore = s3.NewJSONFS3Store(&s3.JSONS3StoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
			Client:      client,
			BucketOptions: &s3.S3BucketOptions{
				EndpointURL: options.BucketEndpointURL,
				BucketName:  options.BucketName,
			},
		})
	default:
		return nil, fmt.Errorf("state store [%s] has an invalid type [%s]", options.Name, options.StateStore)
	}

	return stateStore, nil
}
func (options Options) NewStateStore() (state.ClusterStorer, error) {
	var stateStore state.ClusterStorer

	switch options.StateStore {
	case "fs":
		logger.Info("Selected [fs] state store")
		stateStore = fs.NewFileSystemStore(&fs.FileSystemStoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
		})
	case "crd":
		logger.Info("Selected [crd] state store")
		stateStore = crd.NewCRDStore(&crd.CRDStoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
		})
	case "git":
		logger.Info("Selected [git] state store")
		if options.GitRemote == "" {
			return nil, errors.New("empty GitRemote url. Must specify the link to the remote git repo")
		}
		user, _ := gg.Global("user.name")
		email, _ := gg.Email()

		stateStore = git.NewJSONGitStore(&git.JSONGitStoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
			CommitConfig: &git.JSONGitCommitConfig{
				Name:   user,
				Email:  email,
				Remote: options.GitRemote,
			},
		})
	case "jsonfs":
		logger.Info("Selected [jsonfs] state store")
		stateStore = jsonfs.NewJSONFileSystemStore(&jsonfs.JSONFileSystemStoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
		})
	case "s3":
		logger.Info("Selected [s3] state store")
		client, err := minio.New(options.BucketEndpointURL, options.S3AccessKey, options.S3SecretKey, options.BucketSSL)
		if err != nil {
			return nil, err
		}
		stateStore = s3.NewJSONFS3Store(&s3.JSONS3StoreOptions{
			BasePath:    options.StateStorePath,
			ClusterName: options.Name,
			Client:      client,
			BucketOptions: &s3.S3BucketOptions{
				EndpointURL: options.BucketEndpointURL,
				BucketName:  options.BucketName,
			},
		})
	default:
		return nil, fmt.Errorf("state store [%s] has an invalid type [%s]", options.Name, options.StateStore)
	}

	return stateStore, nil
}
// NewStateStore returns clusterStorer object based on type.